Repository navigation
fix: let Messages answer after forced tool use - #296
franciscojavierarceo merged 5 commits into
Conversation
Signed-off-by: Chuyue Wang <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
A moderate test expectation issue remains unresolved and should be corrected before approval.
Pull request overview
Fixes repeated forced gateway-tool calls in Messages requests by relaxing fulfilled selectors to auto, allowing the model to answer from tool results.
Changes:
- Updates shared selector handling for blocking and streaming flows.
- Adds regression and integration coverage.
- Updates Messages and architecture documentation.
File summaries
| File | Summary |
|---|---|
docs/design/claude-code-integration.md |
Documents forced selector relaxation. |
crates/agentic-server/tests/messages_tool_choice_test.rs |
Adds selector coverage; moderate issue: restrict name removal to type == "tool" (1 vote). |
crates/agentic-server-core/src/executor/messages_loop.rs |
Clarifies shared loop behavior. |
crates/agentic-server-core/src/executor/messages_context.rs |
Implements selector fulfillment and mutation. |
ARCHITECTURE.md |
Documents selector behavior; nit: use “client-executed function tool” terminology (1 vote). |
Review details
Suppressed comments (2)
ARCHITECTURE.md:764
- Please use the repository's normative term
client-executed function toolhere instead of the newly introduced ambiguousClient-tool.TERMINOLOGY.md:16andTERMINOLOGY.md:27-29define the execution-location terminology and distinguish it from gateway-executed built-in tools.
tool. Parallel-use settings and extension fields remain intact. Client-tool and
mixed rounds return before this mutation, and Messages does not persist this state.
crates/agentic-server/tests/messages_tool_choice_test.rs:183
- The expected transition removes
nameforanyas well astool. That contradicts the contract described by this change (extension fields survive; only a fulfilled named selector losesname) and would make this helper reject a validanyrequest carrying an extranamefield. Restrict name removal totype == "tool"while still changing both forced types toauto.
if choice["type"] == "any" || choice["type"] == "tool" {
choice["type"] = json!("auto");
choice.as_object_mut().unwrap().remove("name");
}
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Chuyue Wang <[email protected]>
|
Thanks for the review, @maralbahari. Both points are addressed in 970bcb1: completed client tool calls now report |
Summary
Let a Messages request that forces a gateway tool finish with an answer from its result. Previously,
anyremained forced on every inference round, causing repeated searches and eventual round exhaustion. vLLM 0.29.0 also labels complete named callsend_turn, which could prevent gateway execution or make clients skip their own tool calls.anyor matchingtooltoautoafter appending the full assistant turn and paired tool results. Preserve parallel-use settings and extensions; removenameonly for a named selector.end_turninternally for a matching, explicitly selected gateway call. Surface completed client-executed function calls withstop_reason: tool_usein JSON and the terminal SSEmessage_delta. Hide gateway calls in mixed rounds. Streaming normalization requiresmessage_stop; token limits, other stop reasons and unfinished streams keep their terminal semantics.tool_choiceas a tagged enum with variant-specific fields, the existing non-empty tool-name type and flattened extensions. Use exhaustive matches for fulfillment and transition, while keeping raw JSON for lossless forwarding. Invalid gateway-tool requests return HTTP 400 withinvalid_request_errorbefore inference instead of escaping through the proxy fallback. Requests without gateway tools retain transparent proxying and upstream validation.Anthropic clients distinguish completed turns from requests for client tool execution. The provider compatibility case is visible in vLLM's named-call finish reason and Messages conversion.
Test Plan
Qwen/Qwen3-4B: four gateway recordings coverany/named selection × JSON/SSE. Each completes with one local search and two provider requests; retaining the forced selector causes another call in all four live controls.tool_use, submits the client output with the returned call ID, and receives the complete verification string. Both raw provider recordings containend_turn. Replay checks the complete requests, response metadata and streaming lifecycle, repeats conversations on one gateway, and verifies no gateway search or Messages persistence. All six captures are unmodified recorder output.1e422c3: both new recorded client conversations and the client-stop/invalid-selector regressions fail as intended; all four gateway recordings still pass. The corrected commit passes all six. Earlier unchanged-main validation established failure of all four gateway scenarios before the original fix.