fix(acp): derive v2 state from loop lifecycle - #15
Merged
Conversation
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.
Summary
Derive ACP v2
RunningandIdleupdates from authoritative agent loop lifecycle events instead of host calls toLoopDriver::next. This prevents no-work drives from reporting phantom turns while preserving lifecycle reporting across tools, background suspension, approvals, cancellation, failures, and autonomous background continuations.Motivation
ACP hosts may call
LoopDriver::nextafter a background task completion even when the result was already consumed by the active loop. Synthesizing state around that call produces an emptyRunning→Idlecycle, which clients render as an additional zero-duration turn.Impact
ACP v2 clients now observe session state only when an owned logical turn starts and finishes. Background completion payloads remain available as structured notification content while their human-readable summaries are bounded.
The change releases
agentkit-loop0.10.10,agentkit-task-manager0.10.7,agentkit-acpandagentkit0.10.11,agentkit-adapter-completions0.10.7, andagentkit-provider-anthropic0.10.8.Technical details
Paired logical-turn lifecycle
The loop tracks one active logical turn across model tool-call continuations and approval handling. No-work
AwaitingInputemits no lifecycle events; terminal completion, background suspension, cancellation, and post-start errors emit one matchingTurnFinished. Error cleanup repairs unanswered calls and ensures retries use a fresh turn identity.ACP prompt ownership and cancellation
ACP maps owned loop start/finish events to
Running/Idleand uses owner epochs to linearize prompt admission with terminal state publication. Cancellation checkpoints preserveCancelledacross completion and error races, while autonomous inference remains independently cancellable.Background delivery
Background suspension appends one synthetic detach result before ending the logical turn. Task-manager wakeups resume pending background work without inventing ACP turns, approved asynchronous tasks preserve their originating task turn, and detached completions carry full structured results with bounded text summaries.