perf(server): stop caching unused OpenCode tool parts - #9738
Conversation
Created with GPT-6 Astra (preview) in Codex.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, self-contained OpenCode memory optimization that stops retaining large tool parts while preserving emitted lifecycle events and non-tool processing. The added adapter coverage exercises the affected ordering and lifecycle behavior, with no product-default, schema, security, or deployment impact. You can add or adjust custom eligibility rules. Learn more. |
## What's Changed * perf(server): use one query for buffered provider events by @t3dotgg in pingdotgg/t3code#9706 * perf(relay): avoid repeated activity decoding by @t3dotgg in pingdotgg/t3code#9708 * perf(web): stop continuous chat status animations by @t3dotgg in pingdotgg/t3code#9709 * fix(mobile): preserve saved work after storage read failures by @t3dotgg in pingdotgg/t3code#9710 * perf(web): stop replaying terminal buffers on rollover by @t3dotgg in pingdotgg/t3code#9707 * feat(web): preview pull request links by @maria-rcks in pingdotgg/t3code#9631 * perf(client): reduce thread-list update work by @t3dotgg in pingdotgg/t3code#9716 * fix(server): settle inactive threads with open PRs by @Gigioxx in pingdotgg/t3code#9610 * fix(server): bound slow-client event buffers by @t3dotgg in pingdotgg/t3code#9715 * test(server): allow either valid file-search match by @t3dotgg in pingdotgg/t3code#9720 * fix(web): match provider settings layout for disconnected devices by @flamboh in pingdotgg/t3code#9619 * fix(web): keep the slash menu above the composer when vertical space is short by @Mnigos in pingdotgg/t3code#9625 * fix(mobile): remove provider setup by @juliusmarminge in pingdotgg/t3code#9721 * perf(web): stop rendering hidden terminals by @t3dotgg in pingdotgg/t3code#9718 * fix(mobile): read file-backed image drafts before enabling them by @t3dotgg in pingdotgg/t3code#9713 * perf(server): replay only the selected thread by @t3dotgg in pingdotgg/t3code#9726 * fix(web): mute composer helper text by @jakeleventhal in pingdotgg/t3code#9654 * feat(web): unpin threads from the sidebar multi-select menu by @gsimone in pingdotgg/t3code#9651 * perf(web): reuse timeline rows while text streams by @t3dotgg in pingdotgg/t3code#9725 * fix(relay): bound stalled push requests by @t3dotgg in pingdotgg/t3code#9734 * perf(server): stop caching unused OpenCode tool parts by @t3dotgg in pingdotgg/t3code#9738 * fix(web): fold single trailing activity by @maria-rcks in pingdotgg/t3code#9739 * fix(web): show project settings for new threads by @maria-rcks in pingdotgg/t3code#9743 * perf(mobile): bound the parsed review cache by @t3dotgg in pingdotgg/t3code#9749 **Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260904.1279...v0.0.39-nightly.20260904.1280 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260904.1280
OpenCode retained tool input and output in a session map even though no reader used those cached parts.
Skip tool parts in that map. Keep text, reasoning, usage tracking, and emitted tool events unchanged.
Validation:
Part of the performance audit, item S6. Other session maps remain separate work.
Created with GPT-6 Astra (preview) in Codex.
Note
Low Risk
Targeted memory optimization with no change to emitted events; covered by an expanded adapter test suite.
Overview
OpenCode session handling no longer stores tool message parts in
partById. Onmessage.part.updated, only non-tool parts are cached; tool lifecycle still uses the incoming part, soitem.started/item.updated/item.completedand text deltas behave the same while large tool I/O is not retained in memory.A new adapter test covers tool states (pending → running → completed/error) arriving before late assistant
message.updatedrole metadata, asserting event order and payloads still match expectations.Reviewed by Cursor Bugbot for commit 5c02db1. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Stop caching unused OpenCode tool parts in
OpenCodeAdapterChanges
message.part.updatedhandling in OpenCodeAdapter.ts so incoming tool parts are no longer stored incontext.partById; non-tool parts continue to be cached. The original part is still passed to downstream message-role and usage-processing logic. Adds a test covering pending, running, completed, and error tool-part lifecycle updates.Macroscope summarized 5c02db1.