Heuristic:ANative Lab EvoAgentX Tool Calling Mode Selection
| Knowledge Sources | |
|---|---|
| Domains | LLM, Tool_Use, Agent_Design |
| Last Updated | 2026-10-21 00:00 GMT |
Overview
Selects between native API tool calling and prompt-based text tool calling based on whether the LLM provider supports the native function-calling protocol.
Description
EvoAgentX supports two tool-calling modes:
- Native mode: The provider API accepts a `tools` schema parameter, returns structured `tool_calls` in the response, and accepts `role: "tool"` result messages. This is the OpenAI reference protocol. Tool schemas are passed directly to the model, and tool results are exchanged as structured messages.
- Default (text) mode: Tools are described in the prompt text, and the model is asked to emit a textual tool-call block. The agent parses the block, executes the tools, and feeds results back as user messages.
The mode is decided per-LLM by calling `supports_native_tool_calling()`. Cloud providers (OpenAI, OpenRouter, LiteLLM with cloud models) return `True`. Local models (LiteLLM with `is_local=True`) return `False` because local model tool support is unreliable.
Usage
Use this heuristic when configuring agents with tools. You do not need to set the mode manually — it is auto-detected. However, be aware that local models always fall back to text mode, which may produce less reliable tool-calling behavior.
The Insight (Rule of Thumb)
- Action: Let `ContextManager` auto-detect the mode via `llm.supports_native_tool_calling()`.
- Value: `"native"` for verified cloud providers; `"default"` for local models and unknown providers.
- Trade-off: Native mode is more reliable and efficient but requires provider support. Text mode works everywhere but is more error-prone (parsing textual tool calls).
- Compatibility: OpenAI, OpenRouter, and LiteLLM (cloud) support native. LiteLLM (local) does not.
Reasoning
Native tool calling is the OpenAI reference protocol: the model receives structured tool schemas, decides which tool to call, and returns structured `tool_calls` that the agent can parse deterministically. This eliminates the ambiguity of parsing free-text tool-call blocks. However, many local model runtimes (Ollama, LM Studio) have incomplete or unreliable function-calling support. Forcing native mode on such models leads to silent failures or malformed responses. By defaulting to text mode for local models, EvoAgentX ensures the agent can still describe tools in the prompt and parse textual responses.
The `supports_native_tool_calling()` method defaults to `False` in `BaseLLM` so that unknown/unverified subclasses fall back to the safe text-based path.
Code Evidence
Mode auto-detection from `evoagentx/memory/context_manager.py:22-27`:
# "native": pass tools to the model and exchange structured tool_calls /
# role:tool messages. "default": describe tools in the prompt and parse a
# textual tool_call block from the response. Decided per-LLM by whether the
# provider supports the native function-calling protocol.
if llm.supports_native_tool_calling():
self.mode = "native"
else:
self.mode = "default"
BaseLLM default from `evoagentx/models/base_model.py:756-769`:
def supports_native_tool_calling(self) -> bool:
"""Whether this LLM supports the native (OpenAI-style) function-calling protocol.
Defaults to False so that unknown/unverified subclasses fall back to the
prompt-based tool-calling guide."""
return False
LiteLLM local model fallback from `evoagentx/models/litellm_model.py:91-98`:
def supports_native_tool_calling(self) -> bool:
return not bool(self.config.is_local)
Tool schema passing in native mode from `evoagentx/actions/customize_action.py:369-371`:
llm_response = await llm.async_generate(
messages=context_manager.context,
tools=self.tool_schemas if context_manager.mode == "native" else None,
)