[PR #1525] [MERGED] feat(models): enable Kimi k2 ⇄ Claude trajectory handoff #9961

Closed
opened 2026-02-16 18:14:28 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1525
Author: @ricardo-agz
Created: 8/1/2025
Status: Merged
Merged: 8/1/2025
Merged by: @thdxr

Base: devHead: normalize-claude-tool-call-id


📝 Commits (1)

  • d2ac289 normalize tool call ids for claude patch

📊 Changes

1 file changed (+61 additions, -38 deletions)

View changed files

📝 packages/opencode/src/provider/transform.ts (+61 -38)

📄 Description

Summary

Bugfix to allow trajectories started on a non-anthropic model to be resumed with Claude without losing state.

Problem

Switching providers mid-run failed due to schema and ID incompatibilities:
  - Anthropic requires tool_use.id to match /^[a-zA-Z0-9_-]+$/.

Fix

Normalize function in ProviderTransform in packages/opencode/src/provider/transform.ts so invalid tool call ids get fixed before being sent to Claude

Testing

Running one trajectory with tool calls using Kimi k2 then using that same session ID and continuing with Claude no longer yields errors like:
AI_APICallError: messages.7.content.0.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1525 **Author:** [@ricardo-agz](https://github.com/ricardo-agz) **Created:** 8/1/2025 **Status:** ✅ Merged **Merged:** 8/1/2025 **Merged by:** [@thdxr](https://github.com/thdxr) **Base:** `dev` ← **Head:** `normalize-claude-tool-call-id` --- ### 📝 Commits (1) - [`d2ac289`](https://github.com/anomalyco/opencode/commit/d2ac289e91929c97bfee0c122da412bef2ded9ab) normalize tool call ids for claude patch ### 📊 Changes **1 file changed** (+61 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/provider/transform.ts` (+61 -38) </details> ### 📄 Description ### Summary Bugfix to allow trajectories started on a non-anthropic model to be resumed with Claude without losing state. ### Problem Switching providers mid-run failed due to schema and ID incompatibilities:   - Anthropic requires `tool_use.id` to match `/^[a-zA-Z0-9_-]+$/`. ### Fix Normalize function in ProviderTransform in `packages/opencode/src/provider/transform.ts` so invalid tool call ids get fixed before being sent to Claude ### Testing Running one trajectory with tool calls using Kimi k2 then using that same session ID and continuing with Claude no longer yields errors like: `AI_APICallError: messages.7.content.0.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:28 -05:00
yindo closed this issue 2026-02-16 18:14:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9961