From c100a486de7477aeac0e46643eca943ed14e46bb Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 1 Apr 2026 17:09:44 -0400 Subject: [PATCH] fix(acp): include tool results in step_callback for ACP tool_call_update events The step_callback previously only forwarded tool names as strings, so build_tool_complete received result=None and ACP tool_call_update events had empty content/rawOutput. Now prev_tools carries dicts with both name and result by pairing each tool_call with its matching tool-role message via tool_call_id. --- run_agent.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/run_agent.py b/run_agent.py index 92ab62fde9..92b150d228 100644 --- a/run_agent.py +++ b/run_agent.py @@ -6680,10 +6680,21 @@ class AIAgent: if self.step_callback is not None: try: prev_tools = [] - for _m in reversed(messages): + for _idx, _m in enumerate(reversed(messages)): if _m.get("role") == "assistant" and _m.get("tool_calls"): + _fwd_start = len(messages) - _idx + _results_by_id = {} + for _tm in messages[_fwd_start:]: + if _tm.get("role") != "tool": + break + _tcid = _tm.get("tool_call_id") + if _tcid: + _results_by_id[_tcid] = _tm.get("content", "") prev_tools = [ - tc["function"]["name"] + { + "name": tc["function"]["name"], + "result": _results_by_id.get(tc.get("id")), + } for tc in _m["tool_calls"] if isinstance(tc, dict) ]