Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions src/brain/agent/service/tool_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3742,7 +3742,7 @@ impl AgentService {
tracing::warn!("🛑 Tool '{}' cancelled mid-execution", tool_name);
break;
}
r = self.tool_registry.execute(&tool_name, tool_input, &approved_tool_context) => r,
r = self.tool_registry.execute(&tool_name, tool_input.clone(), &approved_tool_context) => r,
};
match exec_result {
Ok(result) => {
Expand Down Expand Up @@ -3790,11 +3790,26 @@ impl AgentService {
}

// Auto-record to feedback ledger (fire-and-forget)
let feedback_snippet = if !success && tool_name == "bash" {
let cmd_prefix = tool_input
.get("command")
.and_then(|v| v.as_str())
.map(|cmd| {
let truncated: String = cmd.chars().take(300).collect();
format!("[command: {}] ", truncated)
})
.unwrap_or_default();
Some(format!("{}{}", cmd_prefix, content))
} else if !success {
Some(content.clone())
} else {
None
};
self.record_tool_feedback(
session_id,
&tool_name,
success,
if success { None } else { Some(&content) },
feedback_snippet.as_deref(),
);

// Record tool execution for usage dashboard
Expand Down Expand Up @@ -3954,7 +3969,7 @@ impl AgentService {
tracing::warn!("🛑 Tool '{}' cancelled mid-execution", tool_name);
break;
}
r = self.tool_registry.execute(&tool_name, tool_input, &approved_context) => r,
r = self.tool_registry.execute(&tool_name, tool_input.clone(), &approved_context) => r,
};
match exec_result {
Ok(result) => {
Expand Down Expand Up @@ -3995,11 +4010,26 @@ impl AgentService {
}

// Auto-record to feedback ledger (fire-and-forget)
let feedback_snippet = if !success && tool_name == "bash" {
let cmd_prefix = tool_input
.get("command")
.and_then(|v| v.as_str())
.map(|cmd| {
let truncated: String = cmd.chars().take(300).collect();
format!("[command: {}] ", truncated)
})
.unwrap_or_default();
Some(format!("{}{}", cmd_prefix, content))
} else if !success {
Some(content.clone())
} else {
None
};
self.record_tool_feedback(
session_id,
&tool_name,
success,
if success { None } else { Some(&content) },
feedback_snippet.as_deref(),
);

// Record tool execution for usage dashboard
Expand Down
Loading