Skip to content

fix: map opencode tool results#3

Open
krrish-berri-2 wants to merge 2 commits into
mainfrom
codex/accept-bare-litellm-models
Open

fix: map opencode tool results#3
krrish-berri-2 wants to merge 2 commits into
mainfrom
codex/accept-bare-litellm-models

Conversation

@krrish-berri-2

@krrish-berri-2 krrish-berri-2 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • emit stable tool ids and names for OpenCode tool updates
  • convert completed OpenCode tool parts into agent.tool_result events with output/content
  • keep pending empty tool inputs from replacing later concrete inputs

Verification

  • npm test
  • Render deploy dep-d8jojls8aovs73d92o60 live on 190a086
  • platform smoke via runtime opencode-anthropic streamed agent.tool_use with id/name/input and agent.tool_result output=hello world

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.delta on reasoning parts and dedicated thinking_delta / reasoning-delta types) now emit agent.thinking with thinking, content: [{type:"thinking",text}], and model. Plain text deltas still map to agent.message.

Tools: Tool parts are centralized in toolPartEvent. Pending/running updates become agent.tool_use with stable id, name, status, and input (empty {} is dropped on pending so later concrete args are not overwritten). Completed parts (or output/error) become agent.tool_result with tool_use_id, content, and optional output / error.

README documents the agent.thinking payload; test/anthropic.test.mjs locks 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/anthropic.mjs
Comment on lines +102 to +103
const thinking = thinkingText(props);
if (thinking) return thinkingEvent(thinking, ctx.model);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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