fix(browser): reset action counter for each agent session and let it ignore internal actions (#24228)

This commit is contained in:
cynthialong0-0
2026-03-31 08:23:19 -07:00
committed by GitHub
parent e293424bb4
commit 3982a252bb
6 changed files with 51 additions and 7 deletions

View File

@@ -980,5 +980,29 @@ describe('BrowserManager', () => {
/maximum action limit \(3\)/,
);
});
it('should NOT increment action counter when shouldCount is false', async () => {
const limitedConfig = makeFakeConfig({
agents: {
browser: {
maxActionsPerTask: 1,
},
},
});
const manager = new BrowserManager(limitedConfig);
// Multiple calls with isInternal: true should NOT exhaust the limit
await manager.callTool('evaluate_script', {}, undefined, true);
await manager.callTool('evaluate_script', {}, undefined, true);
await manager.callTool('evaluate_script', {}, undefined, true);
// This should still work
await manager.callTool('take_snapshot', {});
// Next one should throw (limit 1 allows exactly 1 call with >= check)
await expect(manager.callTool('take_snapshot', {})).rejects.toThrow(
/maximum action limit \(1\)/,
);
});
});
});