agent: Return ToolResult
from run
inside Tool
(#28763)
This is just a refactor which adds no functionality. We now return a `ToolResult` from `Tool > run(...)`. For now this just wraps the output task in a struct. We'll use this to implement custom rendering of tools, see #28621. Release Notes: - N/A
This commit is contained in:
parent
32829d9f12
commit
5e094553fa
25 changed files with 155 additions and 116 deletions
|
@ -1407,8 +1407,8 @@ impl Thread {
|
|||
) -> Task<()> {
|
||||
let tool_name: Arc<str> = tool.name().into();
|
||||
|
||||
let run_tool = if self.tools.read(cx).is_disabled(&tool.source(), &tool_name) {
|
||||
Task::ready(Err(anyhow!("tool is disabled: {tool_name}")))
|
||||
let tool_result = if self.tools.read(cx).is_disabled(&tool.source(), &tool_name) {
|
||||
Task::ready(Err(anyhow!("tool is disabled: {tool_name}"))).into()
|
||||
} else {
|
||||
tool.run(
|
||||
input,
|
||||
|
@ -1421,7 +1421,7 @@ impl Thread {
|
|||
|
||||
cx.spawn({
|
||||
async move |thread: WeakEntity<Thread>, cx| {
|
||||
let output = run_tool.await;
|
||||
let output = tool_result.output.await;
|
||||
|
||||
thread
|
||||
.update(cx, |thread, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue