Skip to content

Commit bae9808

Browse files
committed
feat: added args and result in tool_span
1 parent 9d866b0 commit bae9808

File tree

1 file changed

+6
-2
lines changed
  • datapizza-ai-core/datapizza/agents

1 file changed

+6
-2
lines changed

datapizza-ai-core/datapizza/agents/agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,13 +563,15 @@ async def _a_execute_planning_step(
563563
def _execute_tool(
564564
self, function_call: FunctionCallBlock
565565
) -> FunctionCallResultBlock:
566-
with tool_span(f"Tool {function_call.tool.name}"):
566+
with tool_span(f"Tool {function_call.tool.name}") as current_tool_span:
567+
current_tool_span.set_attribute("tool_arguments", function_call.arguments)
567568
result = function_call.tool(**function_call.arguments)
568569

569570
if inspect.iscoroutine(result):
570571
result = AsyncExecutor.get_instance().run(result)
571572

572573
if result:
574+
current_tool_span.set_attribute("tool_result", result)
573575
self._logger.log_panel(
574576
result,
575577
title=f"TOOL {function_call.tool.name.upper()} RESULT",
@@ -584,13 +586,15 @@ def _execute_tool(
584586
async def _a_execute_tool(
585587
self, function_call: FunctionCallBlock
586588
) -> FunctionCallResultBlock:
587-
with tool_span(f"Tool {function_call.tool.name}"):
589+
with tool_span(f"Tool {function_call.tool.name}") as current_tool_span:
590+
current_tool_span.set_attribute("tool_arguments", function_call.arguments)
588591
result = function_call.tool(**function_call.arguments)
589592

590593
if inspect.iscoroutine(result):
591594
result = await result
592595

593596
if result:
597+
current_tool_span.set_attribute("tool_result", result)
594598
self._logger.log_panel(
595599
result,
596600
title=f"TOOL {function_call.tool.name.upper()} RESULT",

0 commit comments

Comments
 (0)