You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Unavailable tool" error message lists every available tool, burning thousands of tokens on repeated occurrences #41047
Related upstream trigger: #33618 (Qwen via OpenRouter sporadically emits phantom/invalid tool calls). This issue is about the cost of the error response, which is independent of that bug.
When a model emits a malformed/invalid tool call (e.g. a phantom unknown tool call, which happens occasionally with some models during parallel tool batching), the harness responds with an error message that enumerates the complete list of available tools:
The arguments provided to the tool are invalid: Model tried to call unavailable
tool 'unknown'. Available tools: <full list of 100+ tool names…>
In a session with many MCP servers configured (~130 tools in my setup), each of these error messages injects several thousand tokens into the context. The underlying model behavior can repeat dozens of times in a single session (observed with openrouter/qwen/qwen3.8-max), so this adds up to a very large amount of wasted tokens and cost — far more than the invalid call itself.
A secondary effect: when the invalid call is part of a parallel batch, sibling tool calls in the same batch sometimes get aborted ("Tool execution aborted"), forcing the agent to re-issue them — more tokens and slower progress.
Expected behavior
The error should be minimal and actionable, e.g.:
Tool 'unknown' is not available. See the system prompt for the list of available tools.
The model already has the tool list in its system prompt; repeating it in every error message provides no additional value and is very expensive.
Suggested fix
Truncate/omit the Available tools: … enumeration from the error message (or cap it to a short prefix / first N names).
Optionally, deduplicate: if the same invalid-tool error already occurred in the session, return an even shorter message on repeats.
Activity
github-actions commentedon Oct 8, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.