Repository navigation
spark-server: send GLM native calls to undeclared tools to the client - #322
Merged
Merged
Conversation
A GLM call opened by the native <tool_call> token whose name the request did not declare was treated as prose. Streaming returned the raw envelope as content (finish "stop"); blocking cut it and returned empty content. A ZCode agent saw `<tool_call>mcp__accord__accord_sent<arg_key>id…` as the assistant's reply after calling a tool it had read about in source but was never offered, and its turn ended there. The literal-XML rule exists for markup the model writes as text. The native opener outside a quote or code span is a call, so its envelope now reaches the client as a tool call under the name the model wrote. It is never repaired onto a declared tool: blocking routes it around the fuzzy validator, and the tool guard still inspects its arguments. The client answers with its own unknown-tool result (ZCode: "Tool not found"), so the agent's turn continues, as with a reference server. Markup spelled without the native token, or inside a quote or code span, stays prose. The blocking path's literal check moves into a shared native_opener_opens_call helper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stream's finish reason counted calls the detector parsed, so a call that validation rejected (unparseable arguments, a write path carrying shell metacharacters) ended with finish_reason "tool_calls" and no tool call in the response. An agent treats that as a tool turn with nothing to run. Count the calls actually sent instead (`tool_calls_emitted_count`, bumped wherever a ToolCallStart goes out); salvaged calls keep their existing rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 tasks done
The fixture path '/tmp/a b' was rejected only because it holds a space. Atlas-Inf#323 accepts spaces in write paths, so with both changes the call reaches the client and the finish-reason test fails. '/tmp/a; b' carries a command separator, which the check rejects before and after Atlas-Inf#323. Co-Authored-By: Claude Opus 5.5 <[email protected]>
data-angel
added a commit
to Enntity/atlas
that referenced
this pull request
Nov 3, 2026
Contributor
|
Gated this head (
Merging on green CI. |
Contributor
|
Correction to which head each result came from:
I stopped the redundant BFCL rerun on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GLM calls to tools the request did not declare were lost. When GLM-5.3-Flash opened a call with its native
<tool_call>token and named a tool missing fromtools, Atlas treated the envelope as prose:finish_reason: "stop".A ZCode agent hit this live. It called
mcp__accord__accord_sent, a tool it had read about in source but was never offered, and the user saw<tool_call>mcp__accord__accord_sent<arg_key>id</arg_key>…as the reply. The agent's turn ended there.This PR has two commits:
c2f5fed97). A native opener outside a quote or code span is a call, so its envelope now reaches the client as a tool call under the name the model wrote. The client answers with its own unknown-tool result (ZCode:Tool not found), and the agent's turn continues, as with a reference server.tool_callsonly when a call was sent (4ca502214). The stream's finish reason counted calls the detector parsed, so a call that validation rejected ended withfinish_reason: "tool_calls"and no tool call in the response. It now counts the calls actually sent (tool_calls_emitted_count).Test plan
cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --locked -p spark-server --tests(pinned 1.93.1 toolchain): cleancargo test -p spark-server: 3,044 passed. 3 fail identically without a git checkout (bench_selfstartserve pin, twotui::bench_variants): they callrepo_root().glm_native_call_to_undeclared_tool_reaches_the_client: stream and blocking deliverunknown_toolunchanged withfinish_reason: tool_calls; the same envelope spelled without the native token stays prose.a_call_that_validation_rejects_finishes_stop: a declared write that validation rejects finishesstop.glm_native_tool_boundary_keeps_request_model_and_name_guardsand the explicit-close case inglm_boundary_case_testsnow assert the undeclared name is kept, not repaired ontoget_weather.accord_sentdescribed in the system prompt but not declared) now returns a tool call on both paths; declared calls are unchanged.Notes for reviewers
glm_native_tool_boundary_keeps_request_model_and_name_guardsencoded "a native boundary does not authorize an unregistered name". Authority still doesn't widen: Atlas executes nothing and the name is never mapped onto a declared tool. Only delivery changes, so the client can answer.note_native_opener); the detector marks the next envelope it opens. A text-spelled opener processed in the same chunk before a pending native one could take its mark. I found no way to produce that ordering, and the cost would be one envelope delivered instead of kept as prose.native_opener_opens_callhelper.🤖 Generated with Claude Code