Skip to content

Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy

Rust

stream: fall back to accumulated args when output_item.done omits arguments

Raine Virta0ac87b9d6f35
diff --git a/src/translate/stream.ts b/src/translate/stream.ts
index 20c08a8..40c174b 100644
--- a/src/translate/stream.ts
+++ b/src/translate/stream.ts
@@ -230,12 +230,18 @@ async function runStream(
const state = blocksByIndex.get(outputIndex)
if (!state) continue
if (state.kind === "tool") {
- if (!state.hadDelta && typeof item.arguments === "string" && item.arguments.length) {
- emit("content_block_delta", {
- type: "content_block_delta",
- index: state.index,
- delta: { type: "input_json_delta", partial_json: item.arguments },
- })
+ if (!state.hadDelta) {
+ const finalArgs =
+ (typeof item.arguments === "string" && item.arguments.length
+ ? item.arguments
+ : state.argsAccum) || ""
+ if (finalArgs.length) {
+ emit("content_block_delta", {
+ type: "content_block_delta",
+ index: state.index,
+ delta: { type: "input_json_delta", partial_json: finalArgs },
+ })
+ }
}
}
emit("content_block_stop", { type: "content_block_stop", index: state.index })