Skip to content

perf(server): reduce OpenCode streaming memory - #307

Merged
rynfar merged 4 commits into
pylonfrom
upstream/2026-09-06-opencode-stream-memory
Sep 6, 2026
Merged

perf(server): reduce OpenCode streaming memory#307
rynfar merged 4 commits into
pylonfrom
upstream/2026-09-06-opencode-stream-memory

Conversation

@rynfar

@rynfar rynfar commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Long OpenCode sessions retained tool output that Pylon never reads and repeatedly scanned text parts from earlier messages. Streaming progress also serialized growing tool output into native event logs.

Port four upstream performance fixes (#9684, #9689, #9738, and #10116): drop unused tool history and tool-part caches, index text parts by message, and omit repeated running-tool progress from native logs. Final tool results, errors, client events, and native rollback remain intact. The port preserves Pylon’s session incarnation ownership and turn admission. It does not introduce upstream’s separate token accounting feature.

Validation: 194 focused OpenCode adapter, event logger, and provider service tests passed; server package typecheck and targeted lint passed. Regression coverage includes late message metadata, completed-text edits, reconnects, part removal, and long histories.

Model: GPT-6 Astra. Harness: Codex.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

t3dotgg and others added 4 commits September 6, 2026 09:09
(cherry picked from commit f2e3764c257a7e27c8171d7dd1e38d4383074206)
(cherry picked from commit ec8b2119c377f5c1dbe6235b221ef98eca31a96e)
Do not retain OpenCode tool parts after emitting their runtime events. The remaining cache readers need text, reasoning, or step-usage parts, not tool input and output.

Keep tool lifecycle events, output bytes, late-role assistant text, and usage handling unchanged. Add focused lifecycle coverage and verify retained memory through the real adapter.

Created with GPT-6 Astra (preview) in Codex.

(cherry picked from commit c8f77e0d441264efb0acfac312e852c81ae3da83)
Adapt upstream 281b92b48810062275798dd4107364384ebaf432 without introducing per-turn token accounting. Preserve Pylon session incarnation ownership and admission, interruption, and rollback semantics.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 13.6 KiB −15 B (−0.1%) 15.1 KiB
Codex Thread snapshot wire 7.1 KiB 7.1 KiB −9 B (−0.1%) 7.3 KiB
Codex Live turn WebSocket wire 6.6 KiB 6.5 KiB −6 B (−0.1%) 7.8 KiB
Codex Live turn WebSocket decoded 56.5 KiB 56.5 KiB 0 B (0.0%) 66.4 KiB
Codex Live turn messages 8 8 0 (0.0%) 21
Claude Total thread wire 13.8 KiB 13.6 KiB −146 B (−1.0%) 15.1 KiB
Claude Thread snapshot wire 7.1 KiB 7.1 KiB +2 B (+0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.7 KiB 6.5 KiB −148 B (−2.2%) 7.8 KiB
Claude Live turn WebSocket decoded 58.1 KiB 57.3 KiB −840 B (−1.4%) 66.4 KiB
Claude Live turn messages 8 8 0 (0.0%) 21

Baseline: c966815 · PR result: 33378cc · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 111.2 KiB
  • Claude decoded thread snapshot: 111.9 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@rynfar rynfar changed the title perf(server): keep OpenCode streaming memory bounded perf(server): reduce OpenCode streaming memory Sep 6, 2026
@rynfar
rynfar merged commit 1e96766 into pylon Sep 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants