Skip to content

perf(server): index OpenCode text by message and drop unused tool parts - #251

Merged
leoisadev1 merged 3 commits into
mainfrom
fix/opencode-part-index
Sep 14, 2026
Merged

leoisadev1 merged 3 commits into
mainfrom
fix/opencode-part-index

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Problem

The legacy OpenCode adapter retained every part in a Map<string, Part>, including growing tool output, and scanned that map on each assistant metadata event. It also accumulated unused live turn items. Long sessions kept payloads that no reader needed. Individually removed text parts could also be emitted again after late assistant metadata arrived.

Adaptation

  • Keep only per-message text and reasoning state for later PATCH edits and delta merging.
  • Emit tool lifecycle events without caching tool input or output in the session map.
  • Remove the unused live turn-item history array.
  • Clear cached text for both whole-message and individual-part removal events.

This does not change native event log filtering. That belongs to the projection performance work already merged through #240. OpenCode Go stays on Mastra.

Upstream

Adapted from pingdotgg/t3code#9684, #9738, and #10116.

Verification

  • vp test run apps/server/src/provider/Layers/OpenCodeAdapter.test.ts — 44 tests passed, including individual part removal and late assistant metadata after 24 completed tool parts.
  • Server typecheck passed.
  • Targeted lint and formatting passed.

Made with GPT-5.6 Sol in T3 Code through the Codex harness.

The adapter kept every OpenCode part, including tool input and output,
and scanned that map on each assistant metadata event. Keep only
per-message text state for later PATCH edits, emit tool lifecycle
without retaining payloads, and drop the unused live turn-item history.

Native log filtering stays with the projection-perf logger work.
OpenCode Go stays on Mastra.

Adapted from pingdotgg#9684, pingdotgg#9738, and pingdotgg#10116.

Made with Grok 4.6 High in Grok Build via Orca.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
akeru-bot-landing Building Building Preview Sep 10, 2026 6:32pm UTC

Request Review

@github-actions github-actions Bot added type:provider Agent provider contribution. vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This update clears retained OpenCode text state when an individual message part is removed, so later assistant metadata updates cannot re-emit content that OpenCode has deleted. Regression coverage and provider documentation were updated alongside the adapter behavior.

Confidence Score: 5/5

Safe to merge; there are no outstanding blocking findings.

The previously reported stale-content issue is resolved in the current code: message.part.removed removes the corresponding retained text part, preventing a later message.updated event from emitting deleted content. greptile-apps[bot] resolved the prior thread without explanation.

Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Comment thread apps/server/src/provider/Layers/OpenCodeAdapter.ts
# Conflicts:
#	apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
#	apps/server/src/provider/Layers/OpenCodeAdapter.ts
#	docs/internals/providers.md
@leoisadev1
leoisadev1 merged commit a5ea58b into main Sep 14, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the fix/opencode-part-index branch September 14, 2026 03:24
This was referenced Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L type:provider Agent provider contribution. 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.

1 participant