Repository navigation
Closed
Description
Summary
Groq and Cerebras declare supportsTools = true at the provider level, but only some models support tools. When a caller provides tools for a non-tool-capable model, both providers silently omit tools and tool_choice from the upstream request instead of failing fast or falling back to a tool-capable model.
Cloudflare handles the same class of problem more explicitly by throwing ConfigurationError when tools are used with a model whose capabilities do not support tools.
Fractal Decomposition
Macro: Unified provider contract
- The package promises "tool/function calling ... with unified response format".
- Consumers should not need provider-specific knowledge to know whether a requested tool call will be honored.
Meso: Provider-level vs model-level capabilities
- The public
LLMProviderinterface exposes a coarsesupportsToolsboolean. - Model capability tables contain per-model tool support.
- The factory does not use model capabilities to route tool requests, so adapters are the last boundary where unsupported tool use can be caught.
Micro: Concrete code paths
src/providers/groq.ts:72-81: provider advertisessupportsTools = true.src/providers/groq.ts:337-350: tools are included only ifTOOL_CAPABLE_MODELS.has(model); otherwise they are dropped silently.src/providers/cerebras.ts:71-81: provider advertisessupportsTools = true.src/providers/cerebras.ts:341-354: tools are included only ifTOOL_CAPABLE_MODELS.has(model); otherwise they are dropped silently.src/providers/cloudflare.ts:314-327: Cloudflare detects unsupported tool use and throws.
Impact
- A caller can request tools and receive a plain text response from a model that never saw the tool schema.
- This can mask production bugs in agent/tool workflows because the request appears successful.
- Factory-level routing cannot distinguish "provider supports tools generally" from "this selected model supports tools for this request".
Suggested Fix
- Make behavior consistent across providers:
- Fail fast with
ConfigurationErrorwhen tools are requested on a non-tool-capable model, or - Have the factory route tool requests only to configured providers/models that support tools.
- Fail fast with
- Consider adding a provider method such as
getModelCapabilities(model)or a factory-visible capability resolver. - Add tests for Groq/Cerebras unsupported-tool requests that assert either explicit rejection or documented fallback behavior.
Verification
npm run typecheckpasses.npm testpasses: 169 tests.
Metadata
Metadata
Assignees
Labels
No labels
Activity