Skip to content

fix(server): report undecodable tool calls across APIs - #3690

Merged
inureyes merged 6 commits into
lablup:mainfrom
Jaeyeong-CHOI:fix/3626-tool-call-parse-error
Dec 2, 2026
Merged

inureyes merged 6 commits into
lablup:mainfrom
Jaeyeong-CHOI:fix/3626-tool-call-parse-error

Conversation

@Jaeyeong-CHOI

Copy link
Copy Markdown
Contributor

Report undecodable tool calls across server APIs

Fixes #3626. Chat, Responses and Anthropic now distinguish an ordinary text answer from a generation that attempted a tool call but produced no usable call. This applies to both buffered and streamed requests: a failed stream ends with its API’s error event rather than reporting success. A valid sibling is still returned, and reaching the output-token limit is not a parser failure.

The parser records rejected calls after recognizing a tool-call region. Python REPL prompts, Markdown quotes and prose action notes are not Functionary or Command R invocations; regression tests cover these alongside malformed calls.

Verification on DGX Spark: formatting and workspace all-target Clippy passed with default features and with CUDA. The CPU route filter passed 673 tests (one ignored), and the tool_calls filter passed 586. With CUDA enabled, all 16 scripted route tests and all 568 parser-module tests passed. These are scripted-provider tests, not live model inference. The unfiltered workspace test suite was not run.

@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority labels Dec 2, 2026
…rse-error

# Conflicts:
#	src/server/routes/tool_call_stream_route_tests.rs
The parse-error dispatch returned the first parser that recorded any rejection. The undelimited Pythonic scan claims `[name(...)]` anywhere in prose, so an answer such as "Count them with [len(items)] in Python." on a request with tools now failed with `tool_call_parse_error` (HTTP 500 on chat) because `len` is not a declared tool. On main it was returned as content.

The dispatcher now falls through to the plain-content path when an undelimited Pythonic match has only undeclared names, and when a parser rejected regions on a request without tools, matching the previous behavior there. Delimited regions with undeclared names still fail as the issue specifies.

Adds a parser test and a chat route test for the prose case (both fail without this change), and a route test that the chat, Responses and Anthropic streams carry the parse error without leaking `<tool_call>` markup or emitting a call.

Refs lablup#3626, lablup#3690
@inureyes

inureyes commented Dec 2, 2026

Copy link
Copy Markdown
Member

Maintainer hardening pass against #3626.

Merge with main. Merged origin/main (including #3696, Anthropic stop semantics). The only conflict was tool_call_stream_route_tests.rs: kept main's scripted_app_with/finish_with(StopKind) harness and the Anthropic stop tests, and kept this PR's post_expect helper and parse-error tests on top of it. The anthropic.rs and streaming_anthropic.rs changes merged cleanly; the parse-error return happens before the new stop-sequence logic, so both behaviors hold.

Finding (fixed in f85bd62). The dispatcher returned the first parser that recorded any rejection. The undelimited Pythonic scan claims [name(...)] anywhere in prose, so a tool-enabled answer like "Count them with [len(items)] in Python." became tool_call_parse_error (500 on chat) because len is undeclared; main returned it as content. The dispatcher now falls through to the plain-content path for an undelimited Pythonic match with only undeclared names, and for rejections on a request without tools (matching main there). Delimited regions with undeclared names still fail, as the issue specifies.

Added tests. A parser test and a chat route test for the prose case (both fail on the previous head), and a route test that the chat, Responses and Anthropic streams end with the parse error without leaking <tool_call> markup or emitting a call.

Reviewed, no change. Error shapes match each API (chat 500 / data: {"error"} then [DONE]; Responses failed with type and code; Anthropic api_error with the tool_call_parse_error: prefix and no code). Valid siblings win, length is never a failure, and streamed Responses output is rebuilt from the parser on failure.

Validation (DGX Spark, default features). cargo fmt --check and cargo clippy --all-targets -D warnings clean. Lib tests filtered on server::, tool_call, tool_parser, anthropic, responses: 4695 passed, 5 failed; the 5 are server::webui::catalog tests asserting the model is runnable on the current backend, whose code this PR does not touch; their failure reason is "architecture is not runnable on the current backend" on this host build. CUDA clippy was not rerun; the change is backend-independent.

@inureyes
inureyes merged commit 69e358d into lablup:main Dec 2, 2026
36 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Dec 2, 2026
inureyes added a commit to Jaeyeong-CHOI/mlxcel that referenced this pull request Dec 4, 2026
A parser-level test for the slash-keeping tag names: an invoke to an undeclared tool whose body uses a slashed key is still dropped with an `unknown tool` error (the lablup#3690 reporting path), and a `<x/>` tag or an unclosed slashed key absorbs only the rest of its own invoke body, so the enclosing `</invoke>` is still found and the following invokes parse intact.

Refs lablup#3738
inureyes added a commit that referenced this pull request Dec 4, 2026
* fix(server): keep '/' in MiniMax M3 tool-call tag names

* test(server): pin MiniMax M3 slashed keys on bad and undeclared calls

A parser-level test for the slash-keeping tag names: an invoke to an undeclared tool whose body uses a slashed key is still dropped with an `unknown tool` error (the #3690 reporting path), and a `<x/>` tag or an unclosed slashed key absorbs only the rest of its own invoke body, so the enclosing `</invoke>` is still found and the following invokes parse intact.

Refs #3738

---------

Co-authored-by: Jeongkyu Shin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Report undecodable tool calls as tool_call_parse_error

2 participants