Repository navigation
feat(core): Add subagent_wakeup config to end the turn after subagent tool calls - #66990
balazsmiklos85 wants to merge 6 commits into
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
subagent_wakeup config to end the turn after subagent tool callssubagent_wakeup config to end the turn after subagent tool calls
There was a problem hiding this comment.
I couldn't get this working: as written, every model step crashes, whatever the setting is.
How I checked: I ran the closest tests and tsc on this branch and on the base. packages/core/test/session-runner.test.ts has 253 failures with the PR (263 pass on the base), and they all come from ReferenceError: config is not defined in the runner. tsc -b reports the same error (TS2552), plus type errors in the two new test scenarios. In packages/schema, 6 existing tests in test/config.test.ts now fail (0 on the base), because the new default writes subagent_wakeup: true into every encoded config.
Public API: this adds the config key subagent_wakeup (boolean). Existing configs keep working, but because it has a decoding default, the key is now written into every encoded config document. That changes the schema's round-trip output and makes the setting impossible to turn off from a lower-priority config (see inline comment).
The main concerns are inline: the undefined config service, how the default interacts with config precedence, and the Code Mode structured-output tool being replaced. Also, the setting's name and description say it stops the parent from being woken. What it actually does is end the parent's turn after a subagent call; the parent is still woken by every child report, including in the nested A→B→C case described in #64073. Please run the tests locally before the next push (the checklist says they weren't run).
There was a problem hiding this comment.
Both blockers from my last review are fixed: the runner now gets the Config service, so steps no longer crash, and the decoding default is gone. session-runner.test.ts passes 265/0, packages/schema/test/config.test.ts passes 11/0, and tsc is clean in packages/core. The two new runner scenarios show the turn ending after a subagent call when the setting is false and continuing when it is true.
One thing still blocks the merge: bun run check:generated in packages/protocol now fails with "Generated OpenAPI document is stale" (it passes on the base). Please run bun run generate in packages/protocol and commit the updated openapi.json, plus anything else it regenerates.
Public API: adds the optional config key subagent_wakeup (boolean; unset behaves as true) to Config.Info and to the OpenAPI config schema once that is regenerated. It's backwards compatible: existing configs and clients are unaffected.
Two smaller points are inline: the Code Mode structured-output interaction, and the user-facing description of the key, which doesn't match what the setting does.
| CodeModeAgents.sessionMarker(loaded.session.id, loaded.session.metadata)?.structured === true | ||
| ? CodeModeAgents.OUTPUT_TOOL | ||
| : undefined | ||
| subagentWakeup === false |
There was a problem hiding this comment.
Noted that this is intentional. To spell out the consequence: with subagent_wakeup: false in a user's config, a structured Code Mode agent session (codemode_agents) no longer ends its turn when it calls CodeModeAgents.OUTPUT_TOOL. After recording its output, the model is asked again. subagent_wakeup is about the parent waiting on subagents, so it seems unrelated to how structured children finish. Letting endsTurnTool match either tool (e.g. a small set) would keep both working with little extra code.
| warming: ConfigWarming.Warming.pipe(optional).annotate({ | ||
| description: "Keep recently active sessions warm with transient model requests (default: false)", | ||
| }), | ||
| subagent_wakeup: Schema.Boolean.pipe(optional).annotate({ |
There was a problem hiding this comment.
This description is what users see in the config schema, but the setting doesn't control a wakeup "as the subagent starts". When it is false, the parent's turn ends right after it calls the subagent tool, and the parent is still woken by each subagent report. Something like "End the agent's turn after it starts a subagent, so it waits for the subagent's report instead of continuing (default: true)" would match the behaviour.
There was a problem hiding this comment.
This is a boolean flag. When a user thinks about a flag, the question they ask is "What does this flag to when it is set to true?" Why would phrase what the false does just because true is the current behavior and my change is the false behavior? This does not make sense.
There was a problem hiding this comment.
Fair point: describing what true does is the better convention, and I shouldn't have flipped it. My concern is accuracy, not polarity. "Wake up the parent as the subagent starts" doesn't match the code. With true, the parent's turn simply continues after the subagent call, so the model is asked again in the same turn. With false, the turn ends there. In both cases the parent is still woken by the subagent's report. A wording based on true along these lines would describe that accurately:
Keep the agent's turn going after it starts a background subagent (default: true). When false, the turn ends after the
subagentcall and the agent resumes when the subagent reports back.
The stale OpenAPI document (bun run generate in packages/protocol) from my last review is still outstanding.
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 72-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Hopefully fixes #64073
Type of change
What does this PR do?
After #63382 subagents always run in the background. This PR adds a new config field that let's the user configure that even though the subagents are still running in the background, the parent agent would not be woken until it finishes.
Pro:
Con:
How did you verify your code works?
I wrote some tests, and hope that there is some kind of CI process that will run with the PR. If not, then I'll set up a local
bunand run the tests locally.Screenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Public API: adds the optional
subagent_wakeupconfig key (backwards compatible)