From f66b3fe76b740fd25529555b6d50d619e114749d 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 85d9302c3e..4ee4de51b2 100644 --- a/run_agent.py +++ b/run_agent.py @@ -6656,10 +6656,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) ]