Skip to content

fix(acp): await child background work - #31

Merged
danielkov merged 2 commits into
mainfrom
fix/acp-structured-subagent-completion
Aug 26, 2026
Merged

fix(acp): await child background work#31
danielkov merged 2 commits into
mainfrom
fix/acp-structured-subagent-completion

Conversation

@danielkov

Copy link
Copy Markdown
Contributor

Summary

Makes nested Kit ACP turns wait for child-owned background work and synthesize its results before resolving subagent, prompt, or fork. Applies structured completion to ACP v1 and v2 while preserving depth-0 explicit background behavior.

Motivation

A child could emit a provisional final response while a detached descendant was still running, causing the root-visible call to finish and leaving the descendant unsupervised. Fixes #28.

Impact

Nested subagent calls remain active until their background work reaches quiescence. Cancelling or closing the owning session now cooperatively cancels descendants and force-cancels tasks that do not settle within the bounded grace period.

Technical details

Structured completion boundary

Only ACP drivers started below depth 0 use structured completion. At a provisional terminal boundary, the actor waits for owned background work, consumes the published result, and drives a replacement synthesis turn until the child returns a final response with no active work.

Race-free completion handoff

Background jobs track activity generations and terminal publication by tool call ID. The actor cannot resolve between execution finishing and the task manager publishing the corresponding completion event, avoiding invisible or duplicate autonomous continuations.

Validation

  • cargo fmt --all -- --check
  • cargo test --quiet
  • git diff --check

@danielkov
danielkov force-pushed the fix/acp-structured-subagent-completion branch from 40b59d8 to e624386 Compare August 26, 2026 19:50
@danielkov
danielkov enabled auto-merge (squash) August 26, 2026 19:50
@danielkov
danielkov merged commit 557b54b into main Aug 26, 2026
2 checks passed
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.

Subagent turns can return while owned background tasks are still running

1 participant