Skip to content

fix: coalesce redundant ACP tool updates - #442

Merged
pedronauck merged 1 commit into
compozy:mainfrom
franciscpd:fix-acp-overflow
Aug 20, 2026
Merged

pedronauck merged 1 commit into
compozy:mainfrom
franciscpd:fix-acp-overflow

Conversation

@franciscpd

@franciscpd franciscpd commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What & why

ACP providers can emit hundreds of state-equivalent updates for one tool call. Those duplicates could fill the active prompt's bounded event channel, stall delivery, and disconnect an otherwise healthy provider.

This change keeps one canonical projection per tool call during the active prompt. It suppresses only redundant nonterminal updates while preserving new title, name, kind, input, or prechecked state, plus terminal results and prompt completion in order.

Release notes

🐛 Bug Fixes

  • Prevent repeated ACP tool updates from overflowing active prompts while retaining meaningful metadata and terminal results.

How you verified it

  • CGO_ENABLED=1 go test -race ./internal/acp -count=1 passed.
  • make gate-full passed with current fingerprint 30cbf15585f325c8a17d58b4c427baeed5765eac. Commit and tag signing were disabled only inside the test process so temporary Git repositories did not inherit the operator's global signing settings.
  • Public runtime QA sent 1,100 identical in-progress updates, then a terminal update. Both the initial prompt and a follow-up prompt completed with one canonical call/result pair and no provider disconnect.
  • Francisross validated the signed branch build in the installed runtime and confirmed normal behavior. Codex implemented and verified the change.

QA

Final status: PASS — the repeated update burst completed twice through the public session surface with no duplicate durable events or provider disconnect.

Coverage: Ada walked J-15 through the CLI, UDS, ACP subprocess, persistence, and follow-up prompt paths using a deterministic provider.

Issues: None found during the passing run.

Blocked / needs human: None.

Full report: 2026-08-20-acp-tool-update-burst.md

Impact

  • CLI, HTTP, UDS, Web, and site contracts are unchanged. The public event shapes remain the same; only state-equivalent duplicate nonterminal updates are removed.
  • No config.toml key, default, migration, OpenAPI schema, native tool descriptor, or official skill behavior changes.
  • The reliability behavior is covered by focused ACP tests and the committed QA scenario, charter, journey, and report.

Compozy Impact Audit

  • Native tools: No impact — checked internal/tools native IDs, descriptors, digests, and capability gates; no native tool contract changed.
  • Extensibility and hooks: No impact — checked internal/hooks, internal/extension, MCP and bridge registries, and config lifecycle. ToolPrechecked remains part of meaningful per-call state, and no hook, resource, or config surface changed.
  • Workspace data isolation: No impact — the projection is prompt-scoped under activePromptState.sendMu, keyed by the current prompt's tool_call_id, discarded at prompt end, and never enters global, workspace, or session stores or caches. Existing event correlation is unchanged.
  • Official Compozy skill: No impact — checked skills/compozy/; no public tool ID, CLI path, hook event, capability, extension resource, or memory, network, or task behavior changed.

  • make gate passes locally (make gate-full passed before review)
  • New or changed behavior is covered by tests
  • The agent contribution is named above and Francisross verified the result

Summary by CodeRabbit

  • Bug Fixes

    • Reduced duplicate tool-call updates, helping prevent notification queue overflow during rapid tool activity.
    • Preserved meaningful tool-call changes, including titles, names, types, inputs, status, and completion results.
    • Improved handling and ordering of tool-call results, including failed tool executions.
  • Tests

    • Added coverage for bursty tool updates, incremental enrichments, terminal results, and tool calls without identifiers.

Fixes #439

@franciscpd
franciscpd requested a review from pedronauck as a code owner August 20, 2026 20:02
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

@franciscpd is attempting to deploy a commit to the Compozy Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 383a09fd-fb21-40a4-9e1a-cf149fd9e36a

📥 Commits

Reviewing files that changed from the base of the PR and between 249b0b4 and b5b7f27.

⛔ Files ignored due to path filters (5)
  • docs/qa/charters/CH-acp-tool-update-burst.md is excluded by !**/*.md
  • docs/qa/journeys/J-15-operate-session-via-cli-api.md is excluded by !**/*.md
  • docs/qa/reports/2026-08-20-acp-tool-update-burst.md is excluded by !**/*.md
  • docs/qa/scenarios/RT-acp-tool-update-burst.md is excluded by !**/*.md
  • docs/superpowers/plans/2026-08-20-acp-tool-call-overflow.md is excluded by !**/*.md
📒 Files selected for processing (5)
  • internal/acp/agent_process_prompt.go
  • internal/acp/client_prompt_contract_test.go
  • internal/acp/client_test_support_test.go
  • internal/acp/handlers_test.go
  • internal/acp/types_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The ACP prompt now tracks SHA-256-based tool-call projections, suppresses redundant updates, merges meaningful metadata changes, and preserves deferred results. Tests cover burst coalescing, incremental enrichment, terminal results, failures, and calls without identifiers.

Changes

Tool-call update coalescing

Layer / File(s) Summary
Tool-call projection and merge logic
internal/acp/agent_process_prompt.go
The prompt stores metadata projections for each identified tool call. It compares title, name, kind, input digest, input presence, and prechecked state before emitting updates.
Event delivery and regression coverage
internal/acp/agent_process_prompt.go, internal/acp/client_prompt_contract_test.go, internal/acp/client_test_support_test.go, internal/acp/handlers_test.go, internal/acp/types_test.go
Duplicate tool-call events are suppressed while meaningful enrichments, results, failures, and identifier-free calls remain observable. Tests cover a 1,000-update burst and event ordering.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to b5b7f

The change coalesces redundant nonterminal ACP tool updates while preserving meaningful state and terminal results; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant ToolUpdateBurst
  participant ACPPrompt
  participant EventBuffer
  participant Client
  ToolUpdateBurst->>ACPPrompt: send tool-call updates
  ACPPrompt->>ACPPrompt: compare and merge projection
  ACPPrompt->>EventBuffer: emit only meaningful tool-call update
  ToolUpdateBurst->>ACPPrompt: send completed result
  ACPPrompt->>EventBuffer: emit tool result and done events
  Client->>EventBuffer: collect prompt events
Loading

Suggested reviewers: pedronauck

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: coalescing redundant ACP tool updates.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds prompt-scoped coalescing for repeated nonterminal ACP tool updates while retaining metadata enrichments, terminal results, and event order.

  • Tracks one canonical projection per tool-call ID under the existing prompt send lock.
  • Adds unit, translation, and subprocess tests covering bounded delivery and meaningful updates.
  • Adds the QA scenario, journey coverage, implementation plan, and passing runtime report.

Confidence Score: 5/5

The PR appears safe to merge because no concrete blocking or independently actionable non-blocking issue remains.

The coalescing state is scoped to one active prompt, guarded by the existing send lock, bypassed for empty identifiers and terminal results, and covered at unit, translation, subprocess, and public QA layers.

Important Files Changed

Filename Overview
internal/acp/agent_process_prompt.go Adds prompt-scoped projection tracking and suppresses only repeated correlated nonterminal tool-call events while preserving terminal event handling.
internal/acp/types_test.go Covers bounded burst delivery, canonical enrichment retention, terminal ordering, and uncorrelated empty-ID behavior.
internal/acp/client_prompt_contract_test.go Verifies a real ACP subprocess prompt completes through more than 1,024 redundant updates with the expected call/result/done sequence.
internal/acp/client_test_support_test.go Adds the deterministic subprocess fixture used to generate the repeated ACP update burst.
internal/acp/handlers_test.go Confirms translation preserves title, kind, input, and successful or failed terminal results.
docs/qa/reports/2026-08-20-acp-tool-update-burst.md Records the passing public runtime QA flow, follow-up prompt, durable event readback, and teardown evidence.

Sequence Diagram

sequenceDiagram
    participant Provider as ACP provider
    participant Handler as ACP update handler
    participant Prompt as Active prompt state
    participant Stream as Bounded event stream
    Provider->>Handler: initial tool call
    Handler->>Prompt: tool_call projection
    Prompt->>Stream: emit initial call
    loop repeated nonterminal updates
        Provider->>Handler: tool_call_update
        Handler->>Prompt: projected update
        Prompt-->>Prompt: merge and suppress if unchanged
    end
    Provider->>Handler: completed or failed update
    Handler->>Prompt: tool_result
    Prompt->>Stream: emit terminal result
    Prompt->>Stream: emit prompt completion
Loading

Reviews (1): Last reviewed commit: "fix: coalesce redundant ACP tool updates" | Re-trigger Greptile

@pedronauck
pedronauck merged commit 7d1f9fd into compozy:main Aug 20, 2026
31 of 33 checks passed
This was referenced Sep 1, 2026
This was referenced Sep 27, 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.

ACP tool-call update bursts overflow notification queue and kill healthy sessions

2 participants