-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(agent): cap fork turns and bubble fork permission prompts #5737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { AsyncLocalStorage } from 'node:async_hooks'; | |
| import type { Content } from '@google/genai'; | ||
| import type { Config } from '../../config/config.js'; | ||
| import type { SubagentConfig } from '../../subagents/types.js'; | ||
| import { BUBBLE_APPROVAL_MODE } from '../../subagents/types.js'; | ||
|
|
||
| export const FORK_SUBAGENT_TYPE = 'fork'; | ||
|
|
||
|
|
@@ -33,10 +34,17 @@ export const FORK_AGENT = { | |
| tools: ['*'], | ||
| systemPrompt: | ||
| 'You are a forked worker process. Follow the directive in the conversation history. Execute tasks directly using available tools. Do not spawn sub-agents.', | ||
| approvalMode: 'default', | ||
| // `bubble` surfaces this fork's permission prompts to the parent's Background- | ||
| // tasks UI; a detached fork has no inline UI, so 'default' would auto-deny them. | ||
| approvalMode: BUBBLE_APPROVAL_MODE, | ||
| level: 'session' as const, | ||
| } satisfies SubagentConfig; | ||
|
|
||
| // Turn cap for a detached fork — fire-and-forget background work nobody awaits, | ||
| // so an unbounded reasoning loop burns tokens silently. Matches claude-code's | ||
| // fork cap of 200. | ||
| export const FORK_DEFAULT_MAX_TURNS = 200; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The constant name Either rename to — Claude 3.5 Sonnet via Qwen Code /review |
||
|
|
||
| // Recursive-fork guard. A fork child keeps the `agent` tool in its declarations | ||
| // for byte-identical cache parity with the parent, so tool-availability | ||
| // stripping is no longer an option. Instead, mark the async frame as "inside a | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] The
RunConfigfor forks includes onlymax_turnswith nomax_time_minutes. A fork doing 199 turns of expensive tool calls (long shell commands, large file I/O, network requests) could still run for hours and accumulate significant API costs. The workflow orchestrator applies both a turn cap (50) and a time cap (10 minutes) for defense in depth; the fork path has only one axis of protection.Consider adding a time cap as a second safety net:
— Claude 3.5 Sonnet via Qwen Code /review