Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

feat: propagate details from AgentToolResult to ToolResultMessage

xf gong3aca38c4acd9
diff --git a/cubepi/agent/tools.py b/cubepi/agent/tools.py
index e28b797..94a2023 100644
--- a/cubepi/agent/tools.py
+++ b/cubepi/agent/tools.py
@@ -62,6 +62,7 @@ def _make_tool_result_message(finalized: _FinalizedOutcome) -> ToolResultMessage
tool_call_id=finalized.tool_call.id,
tool_name=finalized.tool_call.name,
content=finalized.result.content,
+ details=finalized.result.details,
is_error=finalized.is_error,
timestamp=time.time(),
)
diff --git a/cubepi/providers/base.py b/cubepi/providers/base.py
index c852427..4e3f82b 100644
--- a/cubepi/providers/base.py
+++ b/cubepi/providers/base.py
@@ -132,6 +132,7 @@ class ToolResultMessage(BaseModel):
tool_call_id: str
tool_name: str
content: list[Content]
+ details: Any = None
is_error: bool = False
timestamp: float | None = None
diff --git a/tests/agent/test_tools.py b/tests/agent/test_tools.py
index b2dade0..27f9e54 100644
--- a/tests/agent/test_tools.py
+++ b/tests/agent/test_tools.py
@@ -279,3 +279,27 @@ class TestToolEvents:
start_idx = types.index("tool_execution_start")
end_idx = types.index("tool_execution_end")
assert start_idx < end_idx
+
+
+class TestToolResultDetails:
+ async def test_details_propagated_to_tool_result_message(self):
+ async def execute_with_details(
+ tool_call_id, params, *, signal=None, on_update=None
+ ):
+ return AgentToolResult(
+ content=[TextContent(text="result")],
+ details={"execution_time": 42},
+ )
+
+ tool = make_echo_tool(execute_fn=execute_with_details)
+ ctx = make_context([tool])
+ msg = make_assistant_msg(
+ [ToolCall(id="t1", name="echo", arguments={"value": "hi"})]
+ )
+
+ batch = await execute_tool_calls(
+ ctx, msg, tool_execution="sequential", emit=lambda e: None
+ )
+
+ assert len(batch.messages) == 1
+ assert batch.messages[0].details == {"execution_time": 42}