Skip to content

fix(opencode): revert from the first removed assistant message - #212

Merged
leoisadev1 merged 2 commits into
mainfrom
fix/opencode-revert-boundary
Sep 13, 2026
Merged

leoisadev1 merged 2 commits into
mainfrom
fix/opencode-revert-boundary

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Problem

OpenCode rollback used the last retained assistant message and omitted the required id when removing every turn. Native revert is inclusive of the targeted message, and OpenCode keeps reverted history until the next prompt, so the adapter could leave extra turns or fail the revert.

Adaptation

Target the first removed assistant message, always send its id to session.revert, and read the native revert boundary back from session.get. readThread stops at session.revert.messageID instead of slicing the local transcript. OpenCode Go stays on Mastra.

Upstream

Adapted from pingdotgg/t3code#9924.

Scope

  • apps/server/src/provider/Layers/OpenCodeAdapter.ts
  • focused adapter tests
  • docs/internals/providers.md

Independent of child-session abort (#210) and CLI probes (#205).

Verification

  • vp test run apps/server/src/provider/Layers/OpenCodeAdapter.test.ts — 33 tests passed, including zero through three requested turns, consecutive rollbacks, a shared user-message boundary, and an empty thread.
  • Targeted lint passed. Server typecheck reports no new errors in the changed files.

No live OpenCode CLI or browser pass: this is adapter protocol behavior covered by the recorded mock.

Made with Grok 4.6 High in Grok Build via Orca.

OpenCode rollback used the last retained message and omitted the required
id when removing all turns. Target the first removed assistant message
and read back the native revert boundary, including when multiple
assistant messages share a preceding user message. OpenCode keeps
reverted history until the next prompt.

Adapted from pingdotgg#9924.

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 5:37pm UTC

Request Review

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

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This update corrects OpenCode rollback handling by targeting the assistant message being removed and reading the transcript only through OpenCode’s native revert boundary. Focused coverage documents zero-through-three-turn rollback behavior, repeated rollbacks, shared user boundaries, and empty threads.

Confidence Score: 5/5

Safe to merge.

No outstanding issues require follow-up.

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

@leoisadev1

Copy link
Copy Markdown
Member Author

This is Leo's agent. Independent integration diagnosis against actual main b9b6d23 and PR head 493d2cb finds exactly one conflict, in docs/internals/providers.md. Preserve both adjacent paragraphs: main's bounded OpenCode discovery and serialized inventory description, followed by this PR's first-removed-assistant rollback and native revert-boundary description. These describe separate behavior; neither should be discarded. No implementation file conflicts in the merge-tree result. Existing rollback code acceptance remains provisional until this integration is pushed, focused adapter tests are rerun, and fresh exact-head Greptile and required Repository checks pass. Worker delivery and repair execution remain unverified because the authorized Orca CLI is unavailable.

…oundary

# Conflicts:
#	apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
#	docs/internals/providers.md
@leoisadev1
leoisadev1 merged commit 60f601f into main Sep 13, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the fix/opencode-revert-boundary branch September 13, 2026 21:02
This was referenced Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 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