Repository navigation
refactor(acp): run ACP prompt turns on the shared turn engine - #2102
Merged
Merged
Conversation
runTurn's hand-written loop becomes a TurnEngineAdapter: the session's messages are the engine's history, streaming goes to agent_message_chunk / agent_thought_chunk, the per-call announce / permission / timeline / execute sequence moves into executeTools unchanged, and the plan and walkthrough fallbacks move into onFinalAnswer. The engine result maps onto the same stopReasons as before, including the notice and "not run" results on a guard stop. compactOptions becomes a per-turn function so ACP reads the session's aggressive-compact preset at compaction time, as it did before. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
No changeset foundThis PR does not add a changeset, so it will not appear in the changelog or trigger a release. If the change is user-facing, add one: pnpm changesetPick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated If this PR is docs-only or a chore that needs no release note, you can ignore this — or run |
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
…ollective#2102) runTurn's hand-written loop becomes a TurnEngineAdapter: the session's messages are the engine's history, streaming goes to agent_message_chunk / agent_thought_chunk, the per-call announce / permission / timeline / execute sequence moves into executeTools unchanged, and the plan and walkthrough fallbacks move into onFinalAnswer. The engine result maps onto the same stopReasons as before, including the notice and "not run" results on a guard stop. compactOptions becomes a per-turn function so ACP reads the session's aggressive-compact preset at compaction time, as it did before. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
9 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.
Step 2 of moving the agent loops onto the shared turn engine (#2097). ACP's
runTurnnow runs onrunTurnEngineinstead of its own hand-written loop. Nothing about how it behaves is meant to change.What moved where
runTurnkeeps its per-prompt setup: the turn id, the walkthrough lifecycle,wrotePlan, usage accumulation,withTurnUsageandstopWithNotice. Its loop is now aTurnEngineAdapter<'cancelled'>:session.messages, written at every stephistorysession.systemMessage; none meansend_turngetSystemMessage+ mappingprepareTurn(the disabled-tools list taken at the start of the turn is kept for the per-call checks, as before)agent_message_chunk/agent_thought_chunkstreaming, with leading whitespace trimmed from reasoningbeginModelCallrecordUsageonModelResponsepartitionUnknownToolCallswithout an offered-name filterpartitionToolCallsaggressiveCompactcompactOptionswrite_planfallback, then the walkthrough nudgeonFinalAnswerask_user, approval, plugin vote, permission, timeline capture, execution,write_tasksplan updateexecuteTools. The code is moved unchanged. A cancelled permission returns{stop, results}, so the cancellation results are still recordedThe engine's result maps onto the same
stopReasons as before:completed, no reply and no system message giveend_turncancelledmax_turn_requestsstopWithNotice: a repeated call givesmax_turn_requests, and malformed or empty turns giveend_turn. A repeated stop on valid calls still records anError: not run.result for each call.Engine change:
compactOptionsis now a function that is read every turn. ACP needs this to pick upsession.aggressiveCompactat compaction time, as the old loop did. Plain is updated to match.The ACP copy of
FINAL_TURN_INSTRUCTIONand its own guards, parsing, capping and compaction calls are gone. Ignoring whitespace,acp-conversation.tsis +100/−240. The rest of the raw diff is the tool-execution block re-indented into the adapter.Behaviour
No change intended. The contract spec from #2097 ran these same scenarios against the old ACP loop, and it still passes against the new one.
Tests
source/acpspecs pass unmodified, including the timeline, queued-tool, permission and plan-fallback tests.source/agent-loop/turn-engine.contract.spec.ts(plain + ACP) passes.tsc --noEmit,biome check,knip(both passes), and AVA oversource/acp,source/agent-loop,source/plain,source/subagentsandsource/hooks(468 + 624 passed), plusno-ink-fast-paths.No changeset: this is a refactor with no user-visible change.
Conflict note: #2095 (tune tool mode) adds
nativeToolsDisabled: session.nativeToolsDisabledto ACP'smodeOverrides. If that merges first, the line moves intoprepareTurn'smodeOverrideshere. Whichever lands second needs a one-line rebase.Next in the sequence
🤖 Generated with Claude Code