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.
This commit is contained in:
15
run_agent.py
15
run_agent.py
@@ -6656,10 +6656,21 @@ class AIAgent:
|
|||||||
if self.step_callback is not None:
|
if self.step_callback is not None:
|
||||||
try:
|
try:
|
||||||
prev_tools = []
|
prev_tools = []
|
||||||
for _m in reversed(messages):
|
for _idx, _m in enumerate(reversed(messages)):
|
||||||
if _m.get("role") == "assistant" and _m.get("tool_calls"):
|
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 = [
|
prev_tools = [
|
||||||
tc["function"]["name"]
|
{
|
||||||
|
"name": tc["function"]["name"],
|
||||||
|
"result": _results_by_id.get(tc.get("id")),
|
||||||
|
}
|
||||||
for tc in _m["tool_calls"]
|
for tc in _m["tool_calls"]
|
||||||
if isinstance(tc, dict)
|
if isinstance(tc, dict)
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user