Skip to content

Commit aab4bf3

Browse files
Alex Holmbergclaude
authored andcommitted
fix(agent): restore write/shell tools on follow-up confirmation turns
is_generation_query() only checked the current user input, so short follow-up messages like "sure go ahead fix all then" didn't match any keyword and caused the agent to be built without WriteFileTool, WriteFilesTool, and ShellTool. The model then tried to call those tools (they were in conversation history) and got ToolNotFoundError. Two fixes: 1. Add commonly missing generation verbs to is_generation_query: fix, update, add, change, modify, edit, configure, setup, patch, install - these clearly imply file modification intent. 2. Track last_was_generation in ChatSession. For short inputs (< 60 chars) that aren't planning mode, inherit generation mode from the previous turn so confirmations like "sure", "yes", "go ahead" keep write/shell tools active. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 749f7a2 commit aab4bf3

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/agent/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,13 @@ pub async fn run_interactive(
690690
Some(&current_input),
691691
session.plan_mode,
692692
);
693-
let is_generation = prompts::is_generation_query(&current_input);
694693
let is_planning = session.plan_mode.is_planning();
694+
// Inherit generation mode for short follow-up messages ("sure", "yes", "go ahead",
695+
// etc.) so the write/shell tool set is not lost between turns.
696+
let is_generation = prompts::is_generation_query(&current_input)
697+
|| (!is_planning
698+
&& session.last_was_generation
699+
&& current_input.trim().len() < 60);
695700

696701
// Note: using raw_chat_history directly which preserves Reasoning blocks
697702
// This is needed for extended thinking to work with multi-turn conversations
@@ -1138,6 +1143,10 @@ pub async fn run_interactive(
11381143
// Add to conversation history with tool call records
11391144
conversation_history.add_turn(input.clone(), text.clone(), tool_calls.clone());
11401145

1146+
// Remember whether this turn had generation tools active so short follow-up
1147+
// messages ("sure", "go ahead", etc.) don't lose write/shell access.
1148+
session.last_was_generation = is_generation;
1149+
11411150
// Check if this heavy turn requires immediate compaction
11421151
// This helps prevent context overflow in subsequent requests
11431152
if conversation_history.needs_compaction() {

src/agent/prompts/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,18 @@ pub fn is_generation_query(query: &str) -> bool {
705705
"new feature",
706706
"develop",
707707
"code",
708+
// Common modification verbs (previously missing)
709+
"fix",
710+
"update",
711+
"add",
712+
"change",
713+
"modify",
714+
"edit",
715+
"configure",
716+
"setup",
717+
"set up",
718+
"patch",
719+
"install",
708720
// Plan execution keywords - needed for plan continuation
709721
"plan",
710722
"continue",

src/agent/session/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ pub struct ChatSession {
3434
pub token_usage: TokenUsage,
3535
/// Current planning mode state
3636
pub plan_mode: PlanMode,
37+
/// Whether the previous turn used generation mode (write/shell tools active).
38+
/// Used so short follow-up messages ("sure", "go ahead", "yes") inherit the
39+
/// tool set from the previous turn instead of losing write/shell access.
40+
pub last_was_generation: bool,
3741
/// Session loaded via /resume command, to be processed by main loop
3842
pub pending_resume: Option<crate::agent::persistence::ConversationRecord>,
3943
/// Platform session state (selected project/org context)
@@ -58,6 +62,7 @@ impl ChatSession {
5862
history: Vec::new(),
5963
token_usage: TokenUsage::new(),
6064
plan_mode: PlanMode::default(),
65+
last_was_generation: false,
6166
pending_resume: None,
6267
platform_session,
6368
}

0 commit comments

Comments
 (0)