generated from nhcarrigan/template
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: #114
This commit is contained in:
@@ -901,7 +901,8 @@ fn process_json_line(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit agent-start event for Task tool invocations
|
// 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
|
let description = input
|
||||||
.get("description")
|
.get("description")
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str())
|
||||||
@@ -1496,7 +1497,7 @@ fn get_tool_state(tool_name: &str) -> CharacterState {
|
|||||||
CharacterState::Coding
|
CharacterState::Coding
|
||||||
} else if tool_name.starts_with("mcp__") {
|
} else if tool_name.starts_with("mcp__") {
|
||||||
CharacterState::Mcp
|
CharacterState::Mcp
|
||||||
} else if tool_name == "Task" {
|
} else if tool_name == "Task" || tool_name.starts_with("Task(") {
|
||||||
CharacterState::Thinking
|
CharacterState::Thinking
|
||||||
} else {
|
} else {
|
||||||
CharacterState::Typing
|
CharacterState::Typing
|
||||||
@@ -1623,6 +1624,19 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_get_tool_state_task() {
|
fn test_get_tool_state_task() {
|
||||||
assert!(matches!(get_tool_state("Task"), CharacterState::Thinking));
|
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]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user