Skip to content

feat(core): Add subagent_wakeup config to end the turn after subagent tool calls - #66990

Closed
balazsmiklos85 wants to merge 6 commits into
anomalyco:devfrom
balazsmiklos85:64073_dont_wake_foreground
Closed

balazsmiklos85 wants to merge 6 commits into
anomalyco:devfrom
balazsmiklos85:64073_dont_wake_foreground

Conversation

@balazsmiklos85

@balazsmiklos85 balazsmiklos85 commented Nov 28, 2026 •

Copy link
Copy Markdown

Issue for this PR

Hopefully fixes #64073

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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:

  • architecturally the removed forground path refactor(core): remove the unused foreground path from SubagentJob #63223 does not need to be readded
  • background running of subagents remains the default
  • users have a choice if their parent agent's context should be messed up with the wake up back and forth
  • even with the config, the users still have a choice to manually wake the parent agent just by writing to it.

Con:

  • nothing.

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 bun and run the tests locally.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Public API: adds the optional subagent_wakeup config key (backwards compatible)

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.

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.

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title #64073 Add subagent_wakeup config to end the turn after subagent tool calls doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@balazsmiklos85 balazsmiklos85 changed the title #64073 Add subagent_wakeup config to end the turn after subagent tool calls feat(core): Add subagent_wakeup config to end the turn after subagent tool calls Nov 28, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread packages/core/src/session/runner/llm.ts Resolved
Comment thread packages/schema/src/config.ts Resolved
@balazsmiklos85
balazsmiklos85 marked this pull request as draft November 28, 2026 16:51
@balazsmiklos85
balazsmiklos85 marked this pull request as ready for review November 29, 2026 12:42

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 subagent call 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.

@balazsmiklos85
balazsmiklos85 marked this pull request as draft November 29, 2026 13:13
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Dec 1, 2026
@github-actions github-actions Bot closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]:Restore Foreground Subagent Execution

1 participant