Skip to content

Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.

fix: verify tool calls without forced tool selection (#26)

澄潭87b7b1c55b99
diff --git a/crates/integrations/src/model_connections/inference.rs b/crates/integrations/src/model_connections/inference.rs
index fdc243b3..d5fcbf19 100644
--- a/crates/integrations/src/model_connections/inference.rs
+++ b/crates/integrations/src/model_connections/inference.rs
@@ -22,21 +22,21 @@ pub(super) fn send(
let messages =
serde_json::json!([{"role":"user","content":"Call hiroute_probe with value ok."}]);
let parameters = serde_json::json!({"type":"object","properties":{"value":{"type":"string","enum":["ok"]}},"required":["value"],"additionalProperties":false});
+ // Let the user instruction elicit the call. Forced tool_choice is rejected by some
+ // providers in their default thinking mode; leave that mode unchanged and allow
+ // enough output for a short reasoning prelude before the tool call.
let body = match target.candidate_target.upstream_protocol {
UpstreamProtocol::Responses => {
- serde_json::json!({"model":model,"input":messages,"max_output_tokens":256,"stream":false,
- "tools":[{"type":"function","name":"hiroute_probe","parameters":parameters}],
- "tool_choice":{"type":"function","name":"hiroute_probe"}})
+ serde_json::json!({"model":model,"input":messages,"max_output_tokens":4096,"stream":false,
+ "tools":[{"type":"function","name":"hiroute_probe","parameters":parameters}]})
}
UpstreamProtocol::ChatCompletions => {
- serde_json::json!({"model":model,"messages":messages,"max_tokens":256,"stream":false,
- "tools":[{"type":"function","function":{"name":"hiroute_probe","parameters":parameters}}],
- "tool_choice":{"type":"function","function":{"name":"hiroute_probe"}}})
+ serde_json::json!({"model":model,"messages":messages,"max_tokens":4096,"stream":false,
+ "tools":[{"type":"function","function":{"name":"hiroute_probe","parameters":parameters}}]})
}
UpstreamProtocol::Messages => {
- serde_json::json!({"model":model,"messages":messages,"max_tokens":256,"stream":false,
- "tools":[{"name":"hiroute_probe","input_schema":parameters}],
- "tool_choice":{"type":"tool","name":"hiroute_probe"}})
+ serde_json::json!({"model":model,"messages":messages,"max_tokens":4096,"stream":false,
+ "tools":[{"name":"hiroute_probe","input_schema":parameters}]})
}
};
let mut request = client
diff --git a/crates/integrations/tests/model_connections/onboarding.rs b/crates/integrations/tests/model_connections/onboarding.rs
index 66c3307f..2240b0d7 100644
--- a/crates/integrations/tests/model_connections/onboarding.rs
+++ b/crates/integrations/tests/model_connections/onboarding.rs
@@ -107,7 +107,24 @@ fn explicit_inference_verifies_tool_call_for_one_model_without_directory_probe()
serde_json::from_str(requests[0].split("\r\n\r\n").nth(1).unwrap()).unwrap();
assert_eq!(body["model"], "manual-model");
assert_eq!(body["tools"].as_array().unwrap().len(), 1);
- assert!(body.get("tool_choice").is_some());
+ assert!(
+ body.get("tool_choice").is_none(),
+ "thinking providers reject forced tool selection"
+ );
+ let messages = if protocol == UpstreamProtocol::Responses {
+ &body["input"]
+ } else {
+ &body["messages"]
+ };
+ assert_eq!(messages.as_array().unwrap().len(), 1);
+ assert_eq!(messages[0]["role"], "user");
+ assert!(
+ messages[0]["content"]
+ .as_str()
+ .unwrap()
+ .contains("hiroute_probe")
+ );
+ assert!(body.get("enable_thinking").is_none());
}
}