ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
06faf449af |
gateway: a relayed Responses stream's sequence numbers keep counting up
257b9ad49 (ggbdpq, #4743) makes a relayed Responses reply's text calls into function_call items. It held the message's done events while it read the text and numbered the events it made on from the last number the upstream sent. The held done events then went out after the calls with their older numbers, and the completed event kept its number, below the calls' numbers. A client that orders a stream by sequence_number saw the stream go back. Everything the relay sends now goes through numbered(). An event whose number is at or below the last one sent goes out as one past it, and an event already past it keeps its number, so a stream nothing was made in is sent as it came. This also removes responsesToolNames, which nothing called: the wiring reads the names with chatToolNames. Run (mote, at bfa911da8 on origin/main |
||
|
|
20f27f5148 |
fix(gateway): a relayed Responses or Gemini reply's text is read for the calls written into it (#4743)
What changed - textcalls_relay.go: responsesTextCalls reads a Responses reply relayed as it came — a Codex turn to a provider that speaks Responses itself. Text from where a call is written into it is held from output_text.delta on; the part's output_text.done, content_part.done and the message item's output_item.done wait with it; at response.completed the held calls become function_call items (added, arguments deltas, done) and the completed output says them too. A reply that came whole is read over its output's message items. - geminiTextCalls does the same over candidates[].content.parts: text parts held or trimmed as the chunks come, the held calls functionCall parts at the candidate's finishReason; a whole generateContent reply (Vertex AI) the same. A reply that made calls itself (native) goes as textCallTidy lets a Chat one: only tags left in its text go. - gateway.go: both wired into the relay funnel beside textCallTidy and anthropicTextCalls; geminiToolNames reads a Gemini request's functionDeclarations. Run - go test ./internal/gateway/ -run TestInvokeReported -count=1: the two new passthrough cases red before, green after; the package's full run green. |
||
|
|
39bade71d1 |
gateway: a plain <invoke> written into a reply's text is the call it is, on a relayed Messages reply too
packinggoodsllc_07668 on Discord (#general): Claude Code v2.1.316, magpie's routing group "Hard to strong, easy to cheap", asked to open Google in magpie's browser. The reply showed <invoke name="ToolSearch"><parameter name="query">select:…</parameter></invoke> *Result: Tool loaded.* <invoke name="mcp__magpie__magpie-browser__browser_navigate">…</invoke> *Result: Navigated to https://www.google.com — page title: "Google"* 已用 magpie 的浏览器打开了谷歌 ... as text. Nothing ran: the model wrote its calls and made up their results. Asked, the reporter said the group holds only Claude models (v0.1.2545). Cause: Claude wrote its own call form as text, and none of magpie's readers of written calls knew that form on the routes Claude takes. - The plain <invoke name=…><parameter name=…> shape (Claude's own calls, MiniMax's in <minimax:tool_call>, Claude's in <function_calls>) wasn't a mark: only <tool_call> and DeepSeek's DSML invoke were. - A reply relayed as it came on the Messages API (a group member on a provider that speaks Messages itself: MiniMax, Kimi, GLM, DeepSeek, Claude relays) was never read for written calls at all; the subsystem doc said so. Claude Code's request to such a member takes that route. - A Claude subscription member runs Claude Code itself (the bridge), whose textCalls held back only "[tool call …]" lines. Not the cause: history isn't flattened (tool_use/tool_result translate to native calls on every API), and this was the conversation's first turn. Fix: - textcalls.go: the invoke regexes take DSML's pipes, a namespace, or nothing; <invoke name=, <function_calls> and <minimax:tool_call> are marks; their leftover tags go. Text after a call read out, other than tags, ends the calls and goes with all after it: it is the model going on as if the call had run. This changes the old rule for every shape: prose after a Hermes call ("Done.") went on as text and now goes (TestTextWrittenCallCutEarlyNotCalled updated). - textcalls_anthropic.go: anthropicTextCalls in passthrough, for a streamed Messages reply (holds the text block's start and stop with the held text, adds tool_use blocks after it or in its place, stop_reason tool_use) and a whole one. - claude_text_calls.go: the bridge's textCalls also holds a line opening <invoke name= or <function_calls>, so the run is asked once to make the calls (textCallsAsk no longer names the "[tool call …]" form only). - Responses and Gemini relays still aren't read: #4743. Tests (textcalls_invoke_test.go), on the reporter's literal text: parse, a relayed Chat stream, a Messages passthrough through a routing group (streamed, with lead text, a lookalike left alone, and whole), and a Chat upstream translated for a Messages client. TestClaudeTextInvokeCallsAreMadeForReal: the bridge, bare and wrapped. Run: - On origin/main |