1- import { describe , it , expect } from 'vitest' ;
1+ import { describe , it , expect , vi } from 'vitest' ;
22import { PROGRAM_REGISTRY } from '@lib/programs/program-registry' ;
33import {
44 DEFAULT_AGENT_MODEL ,
@@ -23,6 +23,17 @@ import {
2323} from '@lib/agent/runner/switchboard' ;
2424import { modelCapabilities } from '@lib/agent/runner/switchboard/models' ;
2525
26+ // RUN_SURFACE is read live in flagRunnerOverride; a getter lets a test flip it.
27+ const envState = vi . hoisted ( ( ) => ( {
28+ runSurface : 'local' as 'cloud' | 'local' ,
29+ } ) ) ;
30+ vi . mock ( '@env' , async ( importOriginal ) => ( {
31+ ...( await importOriginal < typeof import ( '@env' ) > ( ) ) ,
32+ get RUN_SURFACE ( ) {
33+ return envState . runSurface ;
34+ } ,
35+ } ) ) ;
36+
2637const PROGRAM_IDS = PROGRAM_REGISTRY . map ( ( c ) => c . id ) ;
2738
2839describe ( 'switchboard PROGRAM_BINDINGS' , ( ) => {
@@ -163,6 +174,30 @@ describe('switchboard resolveHarness — pi flag is gated to posthog-integration
163174 expect ( pick ) . toEqual ( { harness : Harness . pi , model : GPT5_4_MODEL } ) ;
164175 } ) ;
165176
177+ it ( 'disables the pi flag on the cloud run surface, even for posthog-integration' , ( ) => {
178+ envState . runSurface = 'cloud' ;
179+ try {
180+ const pick = resolveHarness ( {
181+ program : 'posthog-integration' ,
182+ flags : { [ WIZARD_USE_PI_HARNESS_FLAG_KEY ] : 'true' } ,
183+ } ) ;
184+ expect ( pick ) . toEqual ( {
185+ harness : Harness . anthropic ,
186+ model : DEFAULT_AGENT_MODEL ,
187+ } ) ;
188+ } finally {
189+ envState . runSurface = 'local' ;
190+ }
191+ } ) ;
192+
193+ it ( 'keeps the pi flag on the local run surface for posthog-integration' , ( ) => {
194+ const pick = resolveHarness ( {
195+ program : 'posthog-integration' ,
196+ flags : { [ WIZARD_USE_PI_HARNESS_FLAG_KEY ] : 'true' } ,
197+ } ) ;
198+ expect ( pick . harness ) . toBe ( Harness . pi ) ;
199+ } ) ;
200+
166201 it ( 'ignores the pi flag for self-driving — stays on the anthropic default' , ( ) => {
167202 const pick = resolveHarness ( {
168203 program : 'self-driving' ,
@@ -319,6 +354,20 @@ describe('switchboard wizard-pi-effort flag', () => {
319354 } ) . thinkingLevel ,
320355 ) . toBeUndefined ( ) ;
321356 } ) ;
357+
358+ it ( 'is inert on the cloud surface even with the pi flag on' , ( ) => {
359+ envState . runSurface = 'cloud' ;
360+ try {
361+ expect (
362+ modelCapabilities ( GPT5_4_MODEL , {
363+ [ WIZARD_USE_PI_HARNESS_FLAG_KEY ] : 'true' ,
364+ [ WIZARD_PI_EFFORT_FLAG_KEY ] : 'high' ,
365+ } ) . thinkingLevel ,
366+ ) . toBe ( 'low' ) ;
367+ } finally {
368+ envState . runSurface = 'local' ;
369+ }
370+ } ) ;
322371} ) ;
323372
324373describe ( 'switchboard resolveSequence — orchestrator stays flag-gated' , ( ) => {
0 commit comments