fix: map opencode tool results#3
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 190a086237
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const thinking = thinkingText(props); | ||
| if (thinking) return thinkingEvent(thinking, ctx.model); |
There was a problem hiding this comment.
Preserve reasoning deltas as thinking events
When using OpenCode with reasoning-capable models, the real message.part.delta events carry {sessionID, messageID, partID, field, delta} and do not include part.type; the preceding message.part.updated contains the reasoning part. Because this check only recognizes props.part.type, reasoning deltas fall through to the normal text path and are emitted as agent.message instead of agent.thinking, leaking/thinning the newly documented thinking stream for those models.
Useful? React with 👍 / 👎.
Summary
Verification
Note
Medium Risk
Changes the streamed event contract (new tool_result emissions and richer thinking payloads) in the translation layer; behavior is covered by new unit tests but clients consuming SSE may see different event sequences.
Overview
Expands the OpenCode → Anthropic SSE translator so streamed events match the Managed Agents contract for reasoning and tool lifecycle.
Thinking: Reasoning/thinking deltas (including
message.part.deltaon reasoning parts and dedicatedthinking_delta/reasoning-deltatypes) now emitagent.thinkingwiththinking,content: [{type:"thinking",text}], andmodel. Plain text deltas still map toagent.message.Tools: Tool parts are centralized in
toolPartEvent. Pending/running updates becomeagent.tool_usewith stableid,name,status, andinput(empty{}is dropped on pending so later concrete args are not overwritten). Completed parts (or output/error) becomeagent.tool_resultwithtool_use_id,content, and optionaloutput/error.README documents the
agent.thinkingpayload;test/anthropic.test.mjslocks in message, thinking, tool_use, tool_result, and session filtering behavior.Reviewed by Cursor Bugbot for commit 190a086. Bugbot is set up for automated code reviews on this repo. Configure here.