agent: Return an error to the model when trying to use a tool that is disabled (#27928)
This PR makes it so we return an error to the model if it tries to use a tool that is not currently enabled: <img width="628" alt="Screenshot 2025-04-02 at 11 10 55 AM" src="https://github.com/user-attachments/assets/e4bdf01c-f0ea-4c9c-805a-11868bd9c771" /> This allows the model to adapt based on that: <img width="637" alt="Screenshot 2025-04-02 at 11 08 38 AM" src="https://github.com/user-attachments/assets/41016b47-933c-4dcb-b791-847be0548c8a" /> Release Notes: - N/A
This commit is contained in:
parent
2eed94ff23
commit
961bfadad9
1 changed files with 13 additions and 8 deletions
|
@ -3,7 +3,7 @@ use std::io::Write;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result, anyhow};
|
||||||
use assistant_settings::AssistantSettings;
|
use assistant_settings::AssistantSettings;
|
||||||
use assistant_tool::{ActionLog, Tool, ToolWorkingSet};
|
use assistant_tool::{ActionLog, Tool, ToolWorkingSet};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -1403,13 +1403,18 @@ impl Thread {
|
||||||
cx: &mut Context<Thread>,
|
cx: &mut Context<Thread>,
|
||||||
) -> Task<()> {
|
) -> Task<()> {
|
||||||
let tool_name: Arc<str> = tool.name().into();
|
let tool_name: Arc<str> = tool.name().into();
|
||||||
let run_tool = tool.run(
|
|
||||||
input,
|
let run_tool = if self.tools.is_disabled(&tool.source(), &tool_name) {
|
||||||
messages,
|
Task::ready(Err(anyhow!("tool is disabled: {tool_name}")))
|
||||||
self.project.clone(),
|
} else {
|
||||||
self.action_log.clone(),
|
tool.run(
|
||||||
cx,
|
input,
|
||||||
);
|
messages,
|
||||||
|
self.project.clone(),
|
||||||
|
self.action_log.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
cx.spawn({
|
cx.spawn({
|
||||||
async move |thread: WeakEntity<Thread>, cx| {
|
async move |thread: WeakEntity<Thread>, cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue