Skip to content

[langgraph] ag-ui langgraph integration does not support concurrent tool callΒ #871

@happyxgang

Description

@happyxgang
async def _handle_single_event(self, event: Any, state: State) -> AsyncGenerator[str, None]:
    event_type = event.get("event")
    if event_type == LangGraphEventTypes.OnChatModelStream:
        should_emit_messages = event["metadata"].get("emit-messages", True)
        should_emit_tool_calls = event["metadata"].get("emit-tool-calls", True)

        if event["data"]["chunk"].response_metadata.get('finish_reason', None):
            return

        current_stream = self.get_message_in_progress(self.active_run["id"])
        has_current_stream = bool(current_stream and current_stream.get("id"))
        tool_call_data = event["data"]["chunk"].tool_call_chunks[0] if event["data"]["chunk"].tool_call_chunks else None


        is_tool_call_start_event = not has_current_stream and tool_call_data and tool_call_data.get("name")
        is_tool_call_args_event = has_current_stream and current_stream.get("tool_call_id") and tool_call_data and tool_call_data.get("args")
        is_tool_call_end_event = has_current_stream and current_stream.get("tool_call_id") and not tool_call_data

if a tool call is streaming, other tool call will not trigger a tool start event

is this by design or we can improve this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions