[Bug]: supports_tool_calling ignores the model, so every model reports capable (ollama list deleted in 6fc646d; provider lists unreachable)
What happened?
supports_tool_calling does not look at the model. Whatever a caller asks, every client answers from model_config.supports_tool_calling, which trae_agent/utils/config.py:43 defaults to True — so an unknown Ollama tag and a GPT-4-class model get the same answer, and the per-provider lists the repository maintains to tell them apart are unreachable.
There are two distinct losses behind that one symptom, both measured on main @ e839e55:
(1) Ollama's model list was deleted in a move. trae_agent/utils/ollama_client.py used to carry a 21-entry tool_support_model list — deepseek-r1, qwen3, llama3.1, llama3.2, mistral, qwen2.5, qwen2.5-coder, mistral-nemo, llama3.3, qwq, mistral-small, mixtral, smollm2, llama4, command-r, hermes3, phi4-mini, granite3.3, devstral, mistral-small3.1, qwen3:4b. — and #212 was merged on 2025-07-23 specifically to extend it with "qwen3:4b.". The refactor 6fc646d ("New Configuration System backed by YAML", #234, 2025-08-02) moved the client to trae_agent/utils/llm_clients/ollama_client.py and dropped the method on the way:
git show 6fc646d^:trae_agent/utils/ollama_client.py | grep -c "def supports_tool_calling" -> 1
git show 6fc646d :trae_agent/utils/llm_clients/ollama_client.py | grep -c "def supports_tool_calling" -> 0
grep -rn "granite3.3\|mistral-small3.1\|qwen3:4b\|tool_support_model" trae_agent/ -> no matchesSo #212's merged change ("Support Qwen:4b model") has no effect on main today, and none of those 21 names appears anywhere in the package.
(2) The providers that still keep a list cannot be asked. ProviderConfig declares supports_tool_calling(self, model_name: str) as an @abstractmethod (openai_compatible_base.py:59-62) and all three implementations answer it — OpenRouterProvider with a conservative pattern list (openrouter_client.py:48-62), AzureProvider and DoubaoProvider with True (azure_client.py:43, doubao_client.py:36). grep -rn "\.supports_tool_calling(" trae_agent/ finds exactly one call site, llm_client.py:84, and it passes the ModelConfig to the client, which resolves to BaseLLMClient.supports_tool_calling (base_client.py:42-44) and returns the config field. The provider methods are dead code. Same model name, two answers:
OpenRouterClient(mc).supports_tool_calling(mc) -> True # mc.model == "no such model"
OpenRouterProvider().supports_tool_calling("no such model") -> False
OpenRouterProvider().supports_tool_calling("gpt-4o") -> TrueThe repository's own tests already assert (1) and (2) and are red because of them. test_ollama_client_utils.py:120-122 builds a qwen3:4b config, expects True for it and False after model_config.model = "no such model"; test_openrouter_client_utils.py:116-118 does the same for mistralai/mistral-small-3.2-24b-instruct:free. On main, both fail at exactly that second assertion:
FAILED tests/utils/test_ollama_client_utils.py::TestOllamaClient::test_supports_tool_calling
AssertionError: True != False
FAILED tests/utils/test_openrouter_client_utils.py::TestOpenRouterClient::test_supports_tool_calling
AssertionError: True != FalseThey are not flaky and not credential-gated — those two tests construct a client and read a flag, no request — but CI runs make uv-test (Makefile:42), which sets SKIP_OLLAMA_TEST=true SKIP_OPENROUTER_TEST=true, and both files are decorated with a module-level skipIf, so they never execute on a run and the defect stays invisible. (The third, test_google_client.py:311, dies two lines earlier on TypeError: ModelConfig.__init__() got an unexpected keyword argument 'base_url'; it is a stale-test problem, not this one, and #480 does not touch that file either.)
What did you expect to happen?
supports_tool_calling should answer for the model that was configured, which is what its own parameter (model_config.model) and the provider lists are for: True for a tag or model the provider can send tools to, False for one it cannot. Concretely, the two repository tests above should pass without editing them, and the lists providers maintain should be the lists that get consulted.
Traceback
No exception — the failure is a wrong True. The two assertion failures quoted above are the observable form.
What is your system, Python, dependency version?
- OS: Windows 11 (
Windows-11-10.0.26200-SP0); host-independent — this is a name lookup on a string, no filesystem, locale or line-ending involvement - Python: 3.12.13 (repo venv from
uv sync --all-extras);openai==1.86.0,anthropic==0.54.0,google-genai==1.24.0 - Commit:
e839e55(main); the deletion is6fc646d
Additional information that you believe is relevant to this bug
What I am not claiming, because it is not true. Nothing in trae_agent/ currently consumes this answer: _create_response (openai_compatible_base.py:94-107) and _create_ollama_response (ollama_client.py:65-69) send tools= whenever the agent has tools, regardless of supports_tool_calling. So this is not the cause of a live request failure, and I am not filing it as one — an agent does not get "tool calling is not supported" today, it just sends tools to a model that may refuse. I checked that before writing this: grep -rn "\.supports_tool_calling(" trae_agent/ returns the one call site above, and nothing in the package calls it.
So the defect is: an API that exists, is abstract-forced, is maintained by hand (see #212), and is documented by three tests — answers True for everything. Wiring the answer into the request path is a real behavioural change (a model the list does not know would stop receiving tools) and that decision is the maintainers'; I am not making it in this issue. It is also why #211 ("Tool calling in Ollama not working", filed without a traceback) cannot be closed by this: since nothing consults the answer before sending tools, a truthful answer cannot by itself change what a request looks like. I am not claiming this issue is #211's cause, and #427 is working on the multi-turn history axis that thread is about.
Plan, if the reading is right: restore the Ollama check with the list it had (OllamaClient.TOOL_CALLING_MODELS, the 20 entries that can actually match — I am deliberately not re-adding "qwen3:4b." from #212, which carries a trailing dot that no Ollama tag has and so could never match anything; "qwen3" already covers that tag), and in OpenAICompatibleClient forward model_config.model to self.provider_config.supports_tool_calling, ANDed with the existing config field so supports_tool_calling: false remains an off switch. Two small methods, no new abstraction, no model-name guessing beyond what the repository already wrote down. A test file that is not behind any skipIf, so CI actually runs it.
Expected effect on the red list: the two test_supports_tool_calling tests above turn green without being edited. I measured it: bare pytest tests on main is 13 failed, 66 passed, on the fix branch 11 failed, 74 passed, and comm over the two sorted failure lists shows zero branch-only failures — the only difference is those two, fixed.
Source: bytedance/trae-agent