Repository navigation
feat(subagents): apply the turn engine's retry guards and a turn ceiling - #2125
Merged
Merged
Conversation
Subagents ran on the shared turn engine with its guards switched off. They now get the full policy: empty turns are nudged, malformed XML/JSON tool calls are fed back for correction (text tool calls are parsed at all), truncated replies are continued, the shared repeated-call guard replaces the subagent's own copy, and the run is bounded by a turn ceiling whose last turn asks for a tool-free answer. The ceiling is the headless maxTurns unless the new nanocoder.headless.subagentMaxTurns sets its own. Every guard stop fails the run with SubagentLoopStopError, so partial output still reaches the parent. The engine's recordToolFreeTurns policy flag, which only subagents used, is removed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
nc-review could not produce a verdict this run (agent exit |
jay23606
added a commit
to jay23606/nanocoder
that referenced
this pull request
Nov 12, 2026
…ing (Nano-Collective#2125) Subagents ran on the shared turn engine with its guards switched off. They now get the full policy: empty turns are nudged, malformed XML/JSON tool calls are fed back for correction (text tool calls are parsed at all), truncated replies are continued, the shared repeated-call guard replaces the subagent's own copy, and the run is bounded by a turn ceiling whose last turn asks for a tool-free answer. The ceiling is the headless maxTurns unless the new nanocoder.headless.subagentMaxTurns sets its own. Every guard stop fails the run with SubagentLoopStopError, so partial output still reaches the parent. The engine's recordToolFreeTurns policy flag, which only subagents used, is removed. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
11 of 18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR turns on, for subagents, the guards they skipped when they moved onto the turn engine in #2113 (decision 4: "subagents adopting the guards: yes, as a deliberate separate PR with a changeset"). They now get the same retry limits and turn ceiling as
--plainand ACP.What was wrong
#2113 kept subagents' old behaviour by switching engine features off. That behaviour had gaps:
maxTruncatedTurnsfixed for--plain.Change
maxTurns: getSubagentMaxTurns().executeToolCall, which refuses them with the subagent-specific "not available to this subagent" result.SubagentLoopStopError. The parent therefore getssuccess: false, an error naming the setting, and the partial output, as the repeated-call stop already did.nanocoder.headless.subagentMaxTurns: the turn ceiling for each delegated run, minimum 1. When unset it is the headlessmaxTurns(default 200, andNANOCODER_MAX_TURNSapplies). The default is never lower than the headless one.getSubagentMaxTurns()lives inconfig/index.ts.loadHeadlessConfignow reads the file block even when the env var is set. The env var still overridesmaxTurnsexactly as before.schemas/agents.config.schema.json).recordToolFreeTurnspolicy flag is removed, since only subagents used it. One consequence is that a subagent's final answer is now recorded, so auto-compaction can run after it, as it does in plain and ACP. TheonTurnRecordedsession-view update now also shows the final assistant message.docs/features/subagents.md(Loop Protection lists every limit and the ceiling),docs/configuration/index.md(Headless table gainssubagentMaxTurns, and the Retry Limits text no longer says ACP and subagents are exempt; that was stale), and theRetryLimitsConfigcomments.Tests
guarded: falseexceptions from refactor(subagents): run the subagent loop on the shared turn engine #2113 are gone.subagent-executor.spec.ts:subagentMaxTurns, after a final turn that offers no tools, and returns its partial outputconfig/index.spec.ts:maxTurnsand the env var when unsetsubagentMaxTurnsloads, wins over the env var, and is clamped to at least 1tsc --noEmit,biome check,knip(both passes), and the schema generator. AVA one directory at a time:subagents109,agent-loop48,config465,acp358,plain86,tools/agent-tool+verify91.Changeset: minor (new behaviour plus a new config option).
Next
Finite-only usage counting (decision 1, with a changeset), then the two TUI PRs.
🤖 Generated with Claude Code