@@ -184,6 +184,13 @@ describe('/api/v1/chat/completions POST endpoint', () => {
184184 status : 'running' ,
185185 }
186186 }
187+ if ( runId === 'run-browser-use-child' ) {
188+ return {
189+ agent_id : 'browser-use' ,
190+ ancestor_run_ids : [ 'run-free' ] ,
191+ status : 'running' ,
192+ }
193+ }
187194 if ( runId === 'run-completed' ) {
188195 return {
189196 agent_id : 'agent-123' ,
@@ -917,6 +924,40 @@ describe('/api/v1/chat/completions POST endpoint', () => {
917924 expect ( body . error ) . toBe ( 'free_mode_invalid_agent_model' )
918925 } )
919926
927+ it ( 'allows browser-use as a free-mode subagent under a freebuff root' , async ( ) => {
928+ const req = new NextRequest (
929+ 'http://localhost:3000/api/v1/chat/completions' ,
930+ {
931+ method : 'POST' ,
932+ headers : allowedFreeModeHeaders ( 'test-api-key-new-free-gemini' ) ,
933+ body : JSON . stringify ( {
934+ model : 'google/gemini-3.1-flash-lite-preview' ,
935+ stream : false ,
936+ codebuff_metadata : {
937+ run_id : 'run-browser-use-child' ,
938+ client_id : 'test-client-id-123' ,
939+ cost_mode : 'free' ,
940+ } ,
941+ } ) ,
942+ } ,
943+ )
944+
945+ const response = await postChatCompletions ( {
946+ req,
947+ getUserInfoFromApiKey : mockGetUserInfoFromApiKey ,
948+ logger : mockLogger ,
949+ trackEvent : mockTrackEvent ,
950+ getUserUsageData : mockGetUserUsageData ,
951+ getAgentRunFromId : mockGetAgentRunFromId ,
952+ fetch : mockFetch ,
953+ insertMessageBigquery : mockInsertMessageBigquery ,
954+ loggerWithContext : mockLoggerWithContext ,
955+ checkSessionAdmissible : mockCheckSessionAdmissibleAllow ,
956+ } )
957+
958+ expect ( response . status ) . toBe ( 200 )
959+ } )
960+
920961 it ( 'rejects standalone free-mode reviewer runs even when the model is allowlisted' , async ( ) => {
921962 const req = new NextRequest (
922963 'http://localhost:3000/api/v1/chat/completions' ,
0 commit comments