Skip to content

Commit 6191aa5

Browse files
authored
chore: AsyncAgent should use ToolResponse instead of ToolResponseMessage (#197)
Summary: Test Plan: test with script in: https://github.com/meta-llama/llama-stack-apps/blob/async_agent/examples/agents/async_agent.py
1 parent ab3f844 commit 6191aa5

File tree

1 file changed

+6
-8
lines changed
  • src/llama_stack_client/lib/agents

1 file changed

+6
-8
lines changed

src/llama_stack_client/lib/agents/agent.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ async def create_turn(
439439
raise Exception("Turn did not complete")
440440
return chunks[-1].event.payload.turn
441441

442-
async def _run_tool(self, tool_calls: List[ToolCall]) -> ToolResponseMessage:
442+
async def _run_tool(self, tool_calls: List[ToolCall]) -> ToolResponseParam:
443443
assert len(tool_calls) == 1, "Only one tool call is supported"
444444
tool_call = tool_calls[0]
445445

@@ -464,20 +464,18 @@ async def _run_tool(self, tool_calls: List[ToolCall]) -> ToolResponseMessage:
464464
tool_name=tool_call.tool_name,
465465
kwargs=tool_call.arguments,
466466
)
467-
tool_response_message = ToolResponseMessage(
467+
tool_response = ToolResponseParam(
468468
call_id=tool_call.call_id,
469469
tool_name=tool_call.tool_name,
470470
content=tool_result.content,
471-
role="tool",
472471
)
473-
return tool_response_message
472+
return tool_response
474473

475474
# cannot find tools
476-
return ToolResponseMessage(
475+
return ToolResponseParam(
477476
call_id=tool_call.call_id,
478477
tool_name=tool_call.tool_name,
479478
content=f"Unknown tool `{tool_call.tool_name}` was called.",
480-
role="tool",
481479
)
482480

483481
async def _create_turn_streaming(
@@ -524,14 +522,14 @@ async def _create_turn_streaming(
524522
yield chunk
525523

526524
# run the tools
527-
tool_response_message = await self._run_tool(tool_calls)
525+
tool_response = await self._run_tool(tool_calls)
528526

529527
# pass it to next iteration
530528
turn_response = await self.client.agents.turn.resume(
531529
agent_id=self.agent_id,
532530
session_id=session_id or self.session_id[-1],
533531
turn_id=turn_id,
534-
tool_responses=[tool_response_message],
532+
tool_responses=[tool_response],
535533
stream=True,
536534
)
537535
n_iter += 1

0 commit comments

Comments
 (0)