Skip to content

Commit e16e627

Browse files
committed
fixes permission for in memory default agent
1 parent 8b196df commit e16e627

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

crates/chat-cli/src/cli/agent.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ impl Agents {
429429

430430
local_agents.append(&mut global_agents);
431431

432+
// If we are told which agent to set as active, we will fall back to a default whose
433+
// lifetime matches that of the session
434+
if agent_name.is_none() {
435+
local_agents.push(Agent::default());
436+
}
437+
432438
let _ = output.flush();
433439

434440
Self {
@@ -443,8 +449,10 @@ impl Agents {
443449

444450
/// Returns a label to describe the permission status for a given tool.
445451
pub fn display_label(&self, tool_name: &str, origin: &ToolOrigin) -> String {
452+
error!("## perm: name: display_label called");
446453
let tool_trusted = self.get_active().is_some_and(|a| {
447454
a.allowed_tools.iter().any(|name| {
455+
error!("## perm: name: {name}, tool_name: {tool_name}");
448456
// Here the tool names can take the following forms:
449457
// - @{server_name}{delimiter}{tool_name}
450458
// - native_tool_name

crates/chat-cli/src/cli/chat/cli/tools.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl ToolsArgs {
110110
})
111111
.collect::<BTreeSet<_>>();
112112

113+
tracing::error!("## perm: command called");
113114
let to_display = sorted_tools.iter().fold(String::new(), |mut acc, tool_name| {
114115
let width = longest - tool_name.len() + 4;
115116
acc.push_str(
@@ -356,11 +357,22 @@ impl ToolsSubcommand {
356357
{
357358
active_agent.allowed_tools = orig_agent.allowed_tools;
358359
}
360+
} else if session
361+
.conversation
362+
.agents
363+
.get_active()
364+
.is_some_and(|a| a.name.as_str() == "default")
365+
{
366+
// We only want to reset the tool permission and nothing else
367+
if let Some(active_agent) = session.conversation.agents.get_active_mut() {
368+
active_agent.allowed_tools = Default::default();
369+
active_agent.tools_settings = Default::default();
370+
}
359371
}
360372
queue!(
361373
session.stderr,
362374
style::SetForegroundColor(Color::Green),
363-
style::Print("\nReset all tools to the permission levels as defined in persona."),
375+
style::Print("\nReset all tools to the permission levels as defined in agent."),
364376
style::SetForegroundColor(Color::Reset),
365377
)?;
366378
},

0 commit comments

Comments
 (0)