From e40ae989f77c34c0e282a317fbe95db56ce98f17 Mon Sep 17 00:00:00 2001 From: Hikari Date: Sat, 7 Feb 2026 10:55:17 -0800 Subject: [PATCH] fix: support Task(agent_type) tool name syntax from CLI v2.1.33+ Claude Code CLI v2.1.33 introduced support for restricting sub-agents via Task(agent_type) syntax in agent tools frontmatter. This commit updates our Task tool detection to handle both the legacy "Task" syntax and the new "Task(agent_type)" syntax. Changes: - Updated agent-start event detection to match "Task" or "Task(" - Updated character state detection to recognize Task(agent_type) - Added comprehensive test cases for new syntax variants: - Task(Explore) - Task(Plan) - Task(general-purpose) The fix is backwards compatible and all 350+ tests pass. Fixes: https://git.nhcarrigan.com/nhcarrigan/hikari-desktop/issues/114 --- src-tauri/src/wsl_bridge.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/wsl_bridge.rs b/src-tauri/src/wsl_bridge.rs index 18c8d78..8f877c7 100644 --- a/src-tauri/src/wsl_bridge.rs +++ b/src-tauri/src/wsl_bridge.rs @@ -901,7 +901,8 @@ fn process_json_line( } // Emit agent-start event for Task tool invocations - if name == "Task" { + // Support both "Task" and "Task(agent_type)" syntax (CLI v2.1.33+) + if name == "Task" || name.starts_with("Task(") { let description = input .get("description") .and_then(|v| v.as_str()) @@ -1496,7 +1497,7 @@ fn get_tool_state(tool_name: &str) -> CharacterState { CharacterState::Coding } else if tool_name.starts_with("mcp__") { CharacterState::Mcp - } else if tool_name == "Task" { + } else if tool_name == "Task" || tool_name.starts_with("Task(") { CharacterState::Thinking } else { CharacterState::Typing @@ -1623,6 +1624,19 @@ mod tests { #[test] fn test_get_tool_state_task() { assert!(matches!(get_tool_state("Task"), CharacterState::Thinking)); + // Test CLI v2.1.33+ Task(agent_type) syntax + assert!(matches!( + get_tool_state("Task(Explore)"), + CharacterState::Thinking + )); + assert!(matches!( + get_tool_state("Task(Plan)"), + CharacterState::Thinking + )); + assert!(matches!( + get_tool_state("Task(general-purpose)"), + CharacterState::Thinking + )); } #[test]