diff --git a/src/pipecat/processors/aggregators/llm_response_universal.py b/src/pipecat/processors/aggregators/llm_response_universal.py index 51dfcb94d..841ac1727 100644 --- a/src/pipecat/processors/aggregators/llm_response_universal.py +++ b/src/pipecat/processors/aggregators/llm_response_universal.py @@ -1061,7 +1061,14 @@ class LLMAssistantAggregator(LLMContextAggregator): self._context.add_message( { "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, } ) @@ -1104,7 +1111,7 @@ class LLMAssistantAggregator(LLMContextAggregator): "role": "developer", "content": json.dumps( { - "type": "tool", + "type": "async_tool", "tool_call_id": frame.tool_call_id, "status": "finished", "result": result, diff --git a/src/pipecat/utils/context/llm_context_summarization.py b/src/pipecat/utils/context/llm_context_summarization.py index 53a353992..afb0ecd1f 100644 --- a/src/pipecat/utils/context/llm_context_summarization.py +++ b/src/pipecat/utils/context/llm_context_summarization.py @@ -388,7 +388,7 @@ class LLMContextSummarizationUtil: A tool message is considered pending (unresolved) when its content is 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. Args: @@ -403,7 +403,7 @@ class LLMContextSummarizationUtil: parsed = json.loads(content) if ( isinstance(parsed, dict) - and parsed.get("type") == "tool" + and parsed.get("type") == "async_tool" and parsed.get("status") == "started" ): return True @@ -474,14 +474,14 @@ class LLMContextSummarizationUtil: pending_tool_calls.pop(tool_call_id) # 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. if role == "developer": try: parsed = json.loads(msg.get("content", "")) if ( isinstance(parsed, dict) - and parsed.get("type") == "tool" + and parsed.get("type") == "async_tool" and parsed.get("status") == "finished" ): tool_call_id = parsed.get("tool_call_id")