Help: Llama4 Maverick failure in Langgraph Swarm Handoff Tools

It worked with single tool call with langchain, however when using Swarm, it failed. Is it a problem of handoff tool support script?

Using swarm pattern as documented in: https://langchain-ai.github.io/langgraph/agents/multi-agent/
Parser implementations:
jinja: tool_chat_template_llama4_pythonic.jinja
parser: llama4_pythonic_tool_parser.py

[1] [SwarmStream] Message accumulator entries: 1
[1] [SwarmStream] Message 1/2:
[1] - Type: human
[1] - Content length: 110 chars
[1] - Preview: “can you search info for me?
[1] [SwarmStream] Message 2/2:
[1] - Type: ai
[1] - Content length: 26 chars
[1] - Preview: “transfer_to_tavily_agent()”
[1]

Then, it stopped execution. Please help.

Swarm-style multi-agent handoff (e.g., transfer_to_tavily_agent()) is not natively supported by vLLM’s tool calling out of the box. vLLM’s tool calling is designed for OpenAI-compatible function calls, not for agent handoff commands as described in the LangGraph Swarm pattern. This limitation is not due to your Jinja template or parser, but rather to the lack of explicit support for agent handoff tools in vLLM’s OpenAI-compatible API and tool parser implementations. See the discussion and examples in LangGraph Swarm documentation and related vLLM issues for more context.

If you need Swarm-style agent handoff, you may need to implement custom logic outside of vLLM, or adapt your tool parser/plugin to recognize and process handoff commands. There is no direct, built-in support for this in vLLM as of now, and no official documentation or examples for Swarm handoff in vLLM’s tool calling features. Would you like more detail on possible workarounds or custom parser approaches?

Sources:

Hint: Mention @RunLLM in the post for followups.

@RunLLM any walkarounds?

There is no official workaround in vLLM for Swarm-style agent handoff tools, as vLLM’s tool calling is focused on OpenAI-compatible function calls, not agent routing or handoff. However, you could implement a custom tool parser plugin that recognizes handoff tool names (e.g., transfer_to_tavily_agent) and triggers the appropriate logic in your application layer after parsing the tool call, rather than expecting vLLM to handle the agent switch internally. This approach requires you to manage agent routing outside of vLLM, using the tool call output as a signal.

No built-in vLLM parser or template currently supports Swarm handoff natively, and there are no documented examples of this pattern in the vLLM docs or issues. Would you like a step-by-step outline for building a custom parser or integrating this logic in your application?

Sources:

Hint: Mention @RunLLM in the post for followups.