Skip to main content

Engine-based Tool Routing

Benchmarked against: Anthropic — Programmatic Tool Calling Architecture: supervisor.py flat/nested dual-mode routing Key insight: Different engines support different tool-calling protocols

Not all engines handle tool calling the same way. SuperPortia's supervisor automatically routes tool calls through the correct mode based on the engine's capabilities.


The problem

LLM engines differ in how they handle tool calls:

EngineTool call formatMulti-agent supportIssue
ClaudeNative JSONFull (agent-as-tool)None
GeminiNative JSONFull (agent-as-tool)None
Groq (Llama 3.3)XML formatLimitedUses XML instead of JSON
DeepSeekJSON (partial)LimitedUnreliable with nested agents
MistralJSON (partial)LimitedUnreliable with nested agents
ZhipuJSON (partial)LimitedUnreliable with nested agents

If you send a nested agent-as-tool call to Groq, it fails because Groq uses XML tool calling instead of JSON.


Dual-mode routing

The supervisor automatically detects the engine and selects the appropriate mode:

Nested mode

  • Engines: Claude, Gemini
  • How: Supervisor delegates to worker agents, each with their own tool set
  • Advantage: Cleaner separation of concerns, workers can have specialized context
  • Use when: Complex multi-step tasks requiring different expertise

Flat mode

  • Engines: Groq, DeepSeek, Mistral, Zhipu
  • How: Supervisor directly calls tools without intermediate worker agents
  • Advantage: Compatible with engines that have limited tool-calling support
  • Use when: Simple tasks, cost-sensitive operations

Supervisor implementation

The supervisor (supervisor.py) implements automatic mode switching:

# Simplified logic
def select_mode(engine: str) -> str:
nested_capable = {"claude", "gemini"}
if engine in nested_capable:
return "nested"
return "flat"

Flat mode tool restrictions

Some tools are excluded from flat mode due to known issues:

ToolFlat modeReason
ingest_textExcludedGroq produces garbage token explosion (Unicode escape sequences)
Complex nested callsExcludedXML format cannot express nested structures

When a tool is excluded from flat mode, the orchestrator layer handles it instead.


Engine routing table

Task typeRecommended engineModeCost
Research / analysisGroqFlatFree
Intel with citationsGeminiNested~$0.014
Code editingClaudeNested$$$$
ClassificationGroq / DeepSeekFlatFree / cents
Chinese NLPZhipuFlatCents
Complex orchestrationClaude / GeminiNested$$-$$$$

Dispatch engine routing

The dispatch_work_order tool provides a simplified routing interface:

EngineTypeCostBest for
groqLLMFreeResearch, analysis, simple tasks
groq-searchLLM + WebFreeIntel gathering with web search
geminiLLMCheapGeneral tasks
gemini-searchLLM + WebCheapAuthoritative research with citations
deepseekLLMVery cheapReasoning, analysis
mistralLLMCheapEuropean model, alternative
zhipuLLMCheapChinese NLP, agent tool-calling
claudeLLMExpensiveCode editing, file operations only
ingestPipelineFreeBatch file ingestion

Known limitations

LimitationImpactWorkaround
Groq XML tool callsCannot use nested modeAuto-switches to flat
Groq token explosion on ingestGarbage outputExcluded from flat mode tools
DeepSeek nestingUnreliable worker agentsAuto-switches to flat
Free engines + important tasksPoor quality resultsUse Gemini/Claude for important work

Captain's principle: "Minimum cost that gets the job done RIGHT." Free engines are only for trivial tasks.


PageRelationship
Tool DiscoveryFinding available tools
Dispatch ModesEngine dispatch reference
Choosing an EngineEngine selection guide