Repository navigation
Conversation
Signed-off-by: xianlubird <xianlubird@gmail.com>
|
/ok to test 7acb9cd |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Reject missing tool names lib/llm/src/protocols/anthropic/types.rs |
Tool-choice conversion now returns an error when a tool choice has no name. Anthropic request conversion propagates that error. Other tool-choice mappings remain unchanged. |
Verify HTTP validation and dispatch lib/llm/tests/frontend_protocol_validation_http.rs |
Tests verify that unnamed tool choices fail validation before backend dispatch in unary and streaming modes. Tests also verify that a named list_directory choice succeeds and is forwarded as a function choice. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Severity of issue fixed: Low
Merge Risk: 
Minimal · up to 7acb9
-
The change is ready to merge after normal checks; no actionable risk remains from this review.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "fix(anthropic): reject named tool choices without a name" matches the main change: the Anthropic-to-Chat conversion now rejects tool_choice with type "tool" and no name, instead of silently mapping it to Required. It is concise, specific, and follows the conventional-commit style. The title does not mention the new tests, but that detail is not needed.
Full details: Description check
-
Explanation
The description follows the required template. It has a Summary section with the problem, the fix, and before/after behavior, plus a Validation section with test results. The required Related Issues section is present with "Closes
#17307". The template's Overview, Details, and Where should the reviewer start? headings are not used as written, so the structure differs from the template. The issue link satisfies the required reference, and the content covers the template's intent.
Full details: Linked Issues check
-
Explanation
Issue
#17307requires conversion to rejecttool_choice.type: "tool"withoutnamebefore backend dispatch. The changed Anthropic converter now propagates theconvert_anthropic_tool_choiceerror. The added HTTP regression covers unary and streaming requests, HTTP 400invalid_request_error, thetool_choice.namefield, and zero backend dispatch. The test also covers a valid named-tool control and verifies forwarding of the selected tool. The supplied validation reports 20 HTTP tests and 114 Anthropic protocol tests passed.
Full details: Out of Scope Changes check
-
Explanation
The reviewed changes are limited to Anthropic tool-choice error propagation and its HTTP regression test. The test validates the linked issue behavior and preserves valid named-tool forwarding. No unrelated implementation or test changes are identified.
-
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
✅ Dynamo PR CI passed — run 40365559956 (attempt 1) on
|
Signed-off-by: Ryan McCormick <rmccormick@nvidia.com>
|
/ok to test c7d0c04 |
Summary
POST /v1/messagescurrently turns a malformed named-tool choice into a request to call any available tool. Reject the missing name during Anthropic-to-Chat conversion instead, before backend dispatch.Anthropic's
tool_choicecontract requiresnamewhentypeistool. The protocol type can deserialize a missing name as the simpleToolvariant, so validation must happen before that variant is silently converted to Chat Completionsrequired.Closes #17307.
Before and after
Consider an agent that advertises two tools but accidentally omits the name of the tool it wants to force:
{ "model": "my-model", "max_tokens": 64, "messages": [{"role": "user", "content": "List the current directory."}], "tools": [ { "name": "list_directory", "input_schema": { "type": "object", "properties": {"path": {"type": "string"}} } }, { "name": "get_weather", "input_schema": { "type": "object", "properties": {"city": {"type": "string"}} } } ], "tool_choice": {"type": "tool"} }tool_choice: "required"tool_choice.nameidentifiedinvalid_request_error, for both unary and streaming requestsThe rejected request now returns:
{ "type": "error", "error": { "type": "invalid_request_error", "message": "Failed to convert request: tool_choice.name: field required when tool_choice.type is \"tool\"" } }For
stream: true, rejection is still an HTTP 400 JSON error before any successful SSE response.To force the intended tool, the client supplies its name:
This valid control continues to return 200 in unary and streaming HTTP replay, and the captured backend request still selects exactly
list_directory. The patch does not change the existing auto/any/none conversions.Validation
Red/green HTTP regression: the new missing-name test failed against unchanged main with actual status 200, then passed after the fix.
cargo test --locked --no-default-features -p dynamo-llm --test frontend_protocol_validation_http: 20 passed. Covers missing-name rejection without backend dispatch and valid named-tool forwarding in both response modes.cargo test --locked --no-default-features -p dynamo-llm --lib protocols::anthropic: 114 passed.Crate/test clippy with
--no-deps -- -D warnings,cargo fmt --check -p dynamo-llm, file-scoped pre-commit, andgit diff --checkpassed. The initial clippy command including workspace dependencies was blocked by the existing macOS-only unusedjoin_reuseportparameter warning indynamo-runtime; the changed crate and HTTP test are checked with warnings denied.Validation uses the real HTTP handlers, pinned protocol types, and existing scripted-engine harness on CPU. No GPU/model inference was performed;
my-modelabove is an illustrative deployment name.Summary by CodeRabbit