Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: V2 ACP adapter persists every streamed tool_call_update, Devin file writes bloat statev2.sqlite #16428

Closeddarjss(GitHub profile, opens in a new tab) opened this issue 1 comment

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Add Devin through the ACP registry (acpRegistry, agent devin).
  2. Ask it to create a ~150 line file in one write.
  3. Count the events written for that tool call: SELECT count(*) FROM orchestration_events WHERE event_type = 'turn-item.updated' AND payload_json LIKE '%<toolCallId>%'.

Deterministic version without Devin: inject one tool_call and then 200 tool_call_updates into AcpAdapterV2. Each update carries the file so far as a diff content block plus rawInput, and the last one has status: "completed". Then count turn_item.updated events for the file_change item.

Expected behavior

A streamed tool call persists a bounded number of snapshots, as V1 did after #7279 fixed #6556. decideToolCallUpdateEmission emits on status/title changes, on 256+ chars of growth, every 10th skipped update, and always on completed/failed.

Actual behavior

V2 persists every streamed tool_call_update as a full turn-item.updated plus a node.updated. Each snapshot repeats the whole file so far, so the bytes grow quadratically with file size.

Devin streams file writes as it generates them when T3 sends cognition.ai/messageGrouping in clientCapabilities._meta, which AcpRegistryAdapterV2 does. I captured the raw ACP traffic with T3's exact initialize capabilities. Writing a 4.5 KB file produced 1,156 tool_call_updates in 17 s. Without that meta flag, the same prompt produced 3.

The 200-update repro above against main (76d3c96fd5) gives:

file_change updates persistedSerialized bytes
main202849 KB
with the gate below2289.5 KB

On my server (184 threads, three weeks of mostly Devin use), statev2.sqlite grew to 17.8 GB:

event_typeRowsPayload
turn-item.updated1,919,2966.0 GB
node.updated1,584,6361.8 GB
message.updated102,796658 MB
all others73,694~310 MB

One Devin write of a 79 line file produced 2,194 turn-item.updated events in 32 s. 15,486 of the last 23,026 turn-item.updated rows were pending snapshots. The DB compresses 27x with zstd, so nearly all of it is repeated content.

Cause: #7279's gate still runs in AcpSessionRuntime.handleSessionUpdate (AcpSessionRuntime.ts:2895), but it only filters the runtime's event queue. AcpAdapterV2 registers its own runtime.handleSessionUpdate(...) handler and calls emitTool for every ToolCallUpdated from parseSessionUpdateEvent, so V2 never goes through the gate. ThreadLiveEventCoalescer only throttles the live push, not what is written.

Possible fix: in emitTool, run decideToolCallUpdateEmission for updates without a projectedStatus. Keep merging every update into context.tools, and skip only the persisted write. Turn-end terminalization passes a projectedStatus, so tools it closes still get their latest merged state written. A background tool that keeps running after the turn can lag by up to 9 updates until its next write, which matches V1. This is about 25 lines in AcpAdapterV2.ts plus a regression test in AcpAdapterV2.test.ts, which fails on main with 202 updates. I can open a PR if this approach works for you.

Impact

Major degradation or frequent failure

Version or commit

Nightly 0.0.46-nightly.20261003.2632. Code reading and repro on main 76d3c96fd5.

Environment

Headless t3 service on Linux (Ubuntu, x86_64), Devin CLI 3000.11.3 via the ACP registry.

Logs or stack traces

No errors. The cost shows up as event volume. Related: #14701 (slow reads on large databases) and #15707 (event write stalls).

Workaround

None found in the app.

Investigated and written with Claude Opus 5.5 via Claude Code.

  1. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks @darjss for the excellent report, the repro numbers and database breakdown made this very easy to verify.

    What I found

    • This reproduces on current main (1f2b10c25b). It looks like the bound added for #6556 in #7279 doesn't apply on the V2 path. #14701 and #15707 are downstream symptoms of this kind of growth rather than duplicates.
    • decideToolCallUpdateEmission still runs, but only inside AcpSessionRuntime's queue handler. handleSessionUpdate is multicast and AcpAdapterV2 registers its own handler; its root tool_call / tool_call_update path calls emitTool on every ToolCallUpdated.
    • emitTool always merges into context.tools and offers both node.updated and turn_item.updated, and ProviderEventIngestor writes both. ThreadLiveEventCoalescer only collapses the live websocket push, so it doesn't limit statev2.sqlite.
    • Devin makes this sharp because AcpRegistryAdapterV2 sends cognition.ai/messageGrouping, but any ACP agent that streams tool updates is affected. File writes are stored as a file_change whose diffStr is the patch so far (acpToolCallDiffPatch), so each persisted snapshot repeats the whole file.
    • There's a second call site: the child-session branch (sessionId !== rootSessionId) writes turn_item.updated directly without going through emitTool. Devin routes non-root agents by rewriting sessionId to parentAgentId, so subagent file writes would stay unbounded if only emitTool is gated.

    Likely fix area

    The approach you outlined lines up with what I found. Details that seem important for it in AcpAdapterV2.ts:

    • Keep merging every update into context.tools (and the background-task, hydration, and subagent bookkeeping), and skip only the node.updated / turn_item.updated offers. Still call rearmDeferredFinalize when a write is skipped.
    • Let updates with a projectedStatus bypass the gate. Turn-end terminalizeOpenForegroundTools / terminalizeOpenRunOwnedItems pass "completed" / "interrupted", and the gate only forces an emit for completed / failed, so an interrupted tool could otherwise lose its final write.
    • Keep lastEmittedDetailLength and skippedSinceEmit beside the merged tool, since context.tools changes even when the write is skipped.
    • Apply the same gate to the child-session branch.
    • A regression test in AcpAdapterV2.test.ts (1 tool_call + 200 growing updates) would be expected to land around ~22 persisted rows: the first update, every 10th change, the completed update, and the turn-end write.

    One limit worth noting: toolCallProgressLength counts detail, text content blocks, and rawOutput text, but not diff newText or rawInput. So streamed file writes coalesce on the every-10th heartbeat rather than on 256 characters of growth. That's the existing V1 rule and matches your 849 KB → 89.5 KB numbers; snapshots still contain the whole file, so very large writes can still grow the log.

    Since you offered to open a PR, linking it to this issue would help reviewers connect the two. A maintainer will decide on the fix direction.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsvia-triage

Sign in to join this conversation.