Renaming to async_tool and providing description.

This commit is contained in:
filipi87
2026-04-06 09:56:48 -03:00
parent eace782752
commit 42335e2ef0
2 changed files with 13 additions and 6 deletions

View File

@@ -1061,7 +1061,14 @@ class LLMAssistantAggregator(LLMContextAggregator):
self._context.add_message( self._context.add_message(
{ {
"role": "tool", "role": "tool",
"content": json.dumps({"type": "tool", "status": "started"}), "content": json.dumps(
{
"type": "async_tool",
"status": "started",
"tool_call_id": frame.tool_call_id,
"description": "The tool associated with this tool_call_id is still in progress, and the result is not yet available. It will be provided in a subsequent message with the same tool_call_id.",
}
),
"tool_call_id": frame.tool_call_id, "tool_call_id": frame.tool_call_id,
} }
) )
@@ -1104,7 +1111,7 @@ class LLMAssistantAggregator(LLMContextAggregator):
"role": "developer", "role": "developer",
"content": json.dumps( "content": json.dumps(
{ {
"type": "tool", "type": "async_tool",
"tool_call_id": frame.tool_call_id, "tool_call_id": frame.tool_call_id,
"status": "finished", "status": "finished",
"result": result, "result": result,

View File

@@ -388,7 +388,7 @@ class LLMContextSummarizationUtil:
A tool message is considered pending (unresolved) when its content is A tool message is considered pending (unresolved) when its content is
the synchronous ``"IN_PROGRESS"`` sentinel or the async the synchronous ``"IN_PROGRESS"`` sentinel or the async
``{"type": "tool", "status": "started"}`` marker — both indicate ``{"type": "async_tool", "status": "started"}`` marker — both indicate
that the actual result has not yet been written back to the context. that the actual result has not yet been written back to the context.
Args: Args:
@@ -403,7 +403,7 @@ class LLMContextSummarizationUtil:
parsed = json.loads(content) parsed = json.loads(content)
if ( if (
isinstance(parsed, dict) isinstance(parsed, dict)
and parsed.get("type") == "tool" and parsed.get("type") == "async_tool"
and parsed.get("status") == "started" and parsed.get("status") == "started"
): ):
return True return True
@@ -474,14 +474,14 @@ class LLMContextSummarizationUtil:
pending_tool_calls.pop(tool_call_id) pending_tool_calls.pop(tool_call_id)
# Check for async tool completion — a developer message with # Check for async tool completion — a developer message with
# {"type": "tool", "status": "finished"} signals that the # {"type": "async_tool", "status": "finished"} signals that the
# async result has arrived and the call is now resolved. # async result has arrived and the call is now resolved.
if role == "developer": if role == "developer":
try: try:
parsed = json.loads(msg.get("content", "")) parsed = json.loads(msg.get("content", ""))
if ( if (
isinstance(parsed, dict) isinstance(parsed, dict)
and parsed.get("type") == "tool" and parsed.get("type") == "async_tool"
and parsed.get("status") == "finished" and parsed.get("status") == "finished"
): ):
tool_call_id = parsed.get("tool_call_id") tool_call_id = parsed.get("tool_call_id")