Skip to content

Commit 341c35d

Browse files
committed
Allow browser-use in free mode
1 parent 560b7ad commit 341c35d

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

common/src/__tests__/free-agents.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import {
88
} from '../constants/free-agents'
99

1010
describe('free mode agent model allowlist', () => {
11+
test('allows the browser-use subagent with its bundled model', () => {
12+
expect(
13+
isFreeModeAllowedAgentModel(
14+
'browser-use',
15+
'google/gemini-3.1-flash-lite-preview',
16+
),
17+
).toBe(true)
18+
})
19+
1120
test('allows Gemini Pro for the thinker subagent but not the freebuff root', () => {
1221
expect(
1322
isFreeModeAllowedAgentModel('base2-free', FREEBUFF_GEMINI_PRO_MODEL_ID),

common/src/constants/free-agents.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export const FREE_MODE_AGENT_MODELS: Record<string, Set<string>> = {
5454
'researcher-web': new Set(['google/gemini-3.1-flash-lite-preview']),
5555
'researcher-docs': new Set(['google/gemini-3.1-flash-lite-preview']),
5656

57+
// Browser automation
58+
'browser-use': new Set(['google/gemini-3.1-flash-lite-preview']),
59+
5760
// Command execution
5861
basher: new Set(['google/gemini-3.1-flash-lite-preview']),
5962

web/src/app/api/v1/chat/completions/__tests__/completions.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)