fix: preload deferred tools by default in yolo mode

This commit is contained in:
Hunter Bown
2026-02-24 10:37:17 -06:00
parent 8d904129b5
commit 7a6be37e2d
3 changed files with 28 additions and 4 deletions
+1
View File
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Model selection and config validation now accept any valid `deepseek-*` model ID (including future releases), while still normalizing common aliases like `deepseek-v3.2` and `deepseek-r1`.
- Tool-call recovery now auto-loads deferred tools when the model requests them directly, instead of failing with manual `tool_search_*` instructions.
- YOLO mode now preloads tools by default (including deferred MCP tools), so model tool calls can run immediately without discovery indirection.
- Unknown tool-call failures now include discovery guidance and nearest tool-name suggestions instead of generic availability errors.
- Slash-command errors now suggest the closest known command (for example `/modle` -> `/model`) instead of only returning a generic unknown-command message.
+12 -4
View File
@@ -533,7 +533,11 @@ fn is_tool_search_tool(name: &str) -> bool {
matches!(name, TOOL_SEARCH_REGEX_NAME | TOOL_SEARCH_BM25_NAME)
}
fn should_default_defer_tool(name: &str) -> bool {
fn should_default_defer_tool(name: &str, mode: AppMode) -> bool {
if mode == AppMode::Yolo {
return false;
}
!matches!(
name,
"read_file"
@@ -1504,13 +1508,17 @@ impl Engine {
let tools = tool_registry.as_ref().map(|registry| {
let mut tools = registry.to_api_tools();
for tool in &mut tools {
tool.defer_loading = Some(should_default_defer_tool(&tool.name));
tool.defer_loading = Some(should_default_defer_tool(&tool.name, mode));
}
let mut mcp_tools = mcp_tools;
for tool in &mut mcp_tools {
let name = tool.name.as_str();
if mode == AppMode::Yolo {
tool.defer_loading = Some(false);
continue;
}
let keep_loaded = matches!(
name,
tool.name.as_str(),
"list_mcp_resources"
| "list_mcp_resource_templates"
| "mcp_read_resource"
+15
View File
@@ -100,6 +100,21 @@ fn tool_exec_outcome_tracks_duration() {
assert!(outcome.started_at.elapsed().as_nanos() > 0);
}
#[test]
fn yolo_mode_keeps_tools_preloaded() {
assert!(!should_default_defer_tool("exec_shell", AppMode::Yolo));
assert!(!should_default_defer_tool(
"mcp_read_resource",
AppMode::Yolo
));
}
#[test]
fn non_yolo_mode_retains_default_defer_policy() {
assert!(should_default_defer_tool("exec_shell", AppMode::Agent));
assert!(!should_default_defer_tool("read_file", AppMode::Agent));
}
#[test]
fn detects_context_length_errors_from_provider_payloads() {
let msg = r#"SSE stream request failed: HTTP 400 Bad Request: {"error":{"message":"This model's maximum context length is 131072 tokens. However, you requested 153056 tokens (148960 in the messages, 4096 in the completion).","type":"invalid_request_error"}}"#;