refactor(schema): coalesce tool replay data into native by rekram1-node · Pull Request #57286 · anomalyco/opencode · GitHub
Skip to content

refactor(schema): coalesce tool replay data into native - #57286

Merged
rekram1-node merged 1 commit into
v2.1from
tool-native-merge
Oct 20, 2026
Merged

rekram1-node merged 1 commit into
v2.1from
tool-native-merge

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Change

Correction for the v2.1 integration in #57260: store all tool provider replay data in one tool.native, rather than keeping result data in tool.state.native.

 tool
-  native?                  # call data
+  native?                  # call + result data, shallow-merged
   state: completed | error
-    native?                # result data
  • Success and failure events already use native; projection now merges it into the existing tool-level native in core, the client, TUI and CLI.
  • Missing result data keeps call data intact. On duplicate keys, the result value wins.
  • Replay sends the whole merged blob: calls and local results only on the same model, provider-run results within the same provider. Protocol lowering reads the keys it needs.
  • Old stored/imported providerResultState merges into native at the existing legacy read boundary. No database migration or alias for the unreleased state.native shape.
  • Export redaction and generated clients follow the single field. Tool status and readable result content are unchanged.

Why one field

This avoids a second native at another nesting level, a one-off resultNative name, or a tool-specific { call, result } envelope. Protocol implementations must keep different call/result values under different keys; this constraint is documented on Native. Current Anthropic hosted calls carry no replay data, while Responses hosted calls and results carry the same itemId, so neither loses data in the merge.

Scope

Targets v2.1, not dev. Merge this first to update #57260. Event schemas, compaction, keepID, credential behavior and the hosted-tool fallback PR are untouched.

Verification

  • Root bun run check passes; changed-file lint passes.
  • Schema: 89 tests pass. Core projector/runner/message/tool-event tests: 304 pass.
  • Server session imports: 5 pass. TUI data/stream transport: 120 pass. CLI import/export: 5 pass.
  • Regenerated protocol, client and www outputs; all three check:generated scripts pass.
  • Independent review found no issues.

Live Anthropic verification

Tested this branch end-to-end through the standalone CLI with server-side web_search and web_fetch. Both completed, and sessions continued successfully after restarting the CLI. Also tested a failed web_fetch and continued that session successfully.

Inspected the isolated stored sessions and captured next-request bodies: replay data exists only on tool.native (not state.native), and success/error result blocks are replayed unchanged, including encrypted search content. Follow-up messages made no new tool calls.

@rekram1-node
rekram1-node merged commit 6a576e0 into v2.1 Oct 20, 2026
21 checks passed
@rekram1-node
rekram1-node deleted the tool-native-merge branch October 20, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant