Skip to content

Bound and clear the ACP compaction prose buffer - #3013

Open
bradhallett wants to merge 1 commit into
get-bb:mainfrom
bradhallett:fix/acp-compaction-dialect-scope
Open

Bound and clear the ACP compaction prose buffer#3013
bradhallett wants to merge 1 commit into
get-bb:mainfrom
bradhallett:fix/acp-compaction-dialect-scope

Conversation

@bradhallett

Copy link
Copy Markdown
Contributor

AGENT GENERATED

Human comments

Follow-up to #2293, addressing the two review findings SlopCop left on the merged commit (eece92f8):

  1. Major — "OMP text rule applies to all ACP agents": already fixed on main by Scope compaction outcome parsing to OMP #2957, which moved end-turn compaction classification behind the dialect (compactionOutcomeForEndTurn(dialect, …) with dialect.id !== "omp" short-circuiting to completed). No further change needed; this PR builds on that shape.
  2. Medium — "unbounded compaction message text, no cleanup in finishCompaction": still open on main; this PR fixes it.

What was wrong

  • handleAgentNotification accumulated every agent_message_chunk streamed during a compaction prompt into session.compactionAgentMessage for every dialect, even though only the omp dialect ever reads the text — unbounded growth on a long-lived session.
  • The accumulation had no size limit.
  • The buffer was only reset at startCompaction, so after a compaction completed, the text stayed resident until the next compaction began.

What changed

  • Accumulation is now gated on collectsCompactionAgentMessage(session.dialect) — the dialect module owns the "does this dialect parse compaction prose" decision, so non-omp dialects carry no classifier state at all.
  • Accumulation clamps at 64 KiB (COMPACTION_AGENT_MESSAGE_CAP), keeping the head of the message: omp's failure/no-op prose ("Compaction failed: …", "Nothing to compact") leads its compaction report.
  • The buffer is cleared in finishCompaction — the single settlement funnel that success, failure, and interrupt all route through. The now-redundant reset at startCompaction is removed; session-creation initialization covers the first compaction.
  • fake-acp-agent.mjs gains FAKE_ACP_COMPACT_AGENT_MESSAGES (JSON string array; one message per /compact request, last entry repeats) so one session can exercise sequential compactions with different prose.
  • SDK bump 0.4.40 → 0.4.41 (bridge dist output changes).

How you verified

  • Three new regression tests, each mutation-checked (revert the guard, confirm the test fails, restore):
    • failure prose within the cap still classifies the turn failed — kills a tail-keeping clamp;
    • failure prose past the cap is ignored and the turn completes with thread/compacted — kills cap removal;
    • a second compaction in the same session classifies independently after a failed first one — kills removal of the finishCompaction clear.
  • The accumulation dialect gate is behaviorally invisible by construction (no non-omp code reads the buffer), so it is covered by Scope compaction outcome parsing to OMP #2957's existing generic/OpenCode completed-outcome regressions rather than a test that could not fail.
  • Package gates: turbo run test typecheck --filter=@bb/provider-bridge-acp --force — 18/18 test files, typecheck clean; oxfmt --check clean; oxlint zero new findings (the pre-existing bb(no-comments) hits in the .mjs harness are identical to main: 15 before, 15 after); check-npm-version-guard PASS at 0.4.41.

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.

1 participant