feat: Allow tool_call to be an object for granular capabilities#343
Open
neilberkman wants to merge 1 commit intoanomalyco:devfrom
Open
feat: Allow tool_call to be an object for granular capabilities#343neilberkman wants to merge 1 commit intoanomalyco:devfrom
neilberkman wants to merge 1 commit intoanomalyco:devfrom
Conversation
a5360d4 to
a9d9744
Compare
- Update schema to accept boolean OR object for tool_call - Add streaming, parallel, and coerces_types optional fields - Update meta.llama3-3-70b-instruct-v1:0 as example - Documents Bedrock streaming limitation and type coercion Default semantics (do the least harm): - streaming: undefined → true (matches current tool_call=true assumption) - parallel: undefined → false (safer, not universally supported) - coerces_types: undefined → false (most models work correctly) Addresses provider-specific tool calling limitations: - Streaming incompatibility (AWS Bedrock non-Anthropic models) - Type coercion issues (Bedrock integer handling) - Parallel tool calling tracking (addresses anomalyco#202) Evidence: - AWS re:Post: streaming errors, integer coercion - langchain-aws anomalyco#140, anomalyco#354: streaming validation issues - pydantic-ai #1649: response format problems - req_llm: agentjido/req_llm#163 100% backward compatible at TOML level - existing tool_call = true/false still valid
a9d9744 to
0359798
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Allow tool_call to be an object for granular capabilities
This PR implements the proposal from Issue #342.
It changes
tool_callinschema.tsto be az.union([z.boolean(), z.object(...)])to capture provider-specific limitations for tool-calling.Problem Summary
Consumer libraries like
req_llmthat rely on models.dev encounter failures whentool_call = truedoesn't capture provider-specific quirks. For example:HTTP 400when streaming with tools (AWS re:Post)Additionally, Issue #202 requests tracking which models support parallel tool calling - a capability that's currently undocumented but critical for test planning and feature support detection.
Changes in this PR
1.
packages/core/src/schema.tsUpdated the
tool_calldefinition from:To:
2.
providers/amazon-bedrock/models/meta.llama3-3-70b-instruct-v1:0.tomlUpdated from:
To:
This serves as a real-world example of the new schema and documents the known Bedrock limitations. Note that
parallelis not specified because we have no evidence either way for this model.Benefits of this Approach
100% Backward-Compatible at TOML level: All existing TOML files with
tool_call = trueortool_call = falseare still valid. No data migration needed.Solves the "Quirks" Problem: We can now document provider-specific TOML files that correctly describe real-world limitations. This allows consumers of the API to skip or modify tests accordingly, rather than maintaining their own local override lists.
Enables Parallel Tool Tracking: Addresses Request: New column for parallel tool calling #202 by providing a place to document which models support parallel tool calling.
Opt-in Complexity: The new fields are optional, so they only need to be specified for models with known exceptions.
How Consumers Should Handle Defaults
For API consumers (like
req_llm):tool_callisfalse: All tool sub-capabilities are falsetool_callistrue(boolean): All sub-capabilities work correctly (maintains current assumptions)streaming = true(default - most models support this)parallel = false(default - not universally supported, safer to assume no)coerces_types = false(default - most models don't have this bug)tool_callis an object:supportedflag as the base truthstreamingis undefined → default totrue(matches currenttool_call = trueassumption)parallelis undefined → default tofalse(safer, not universal)coerces_typesis undefined → default tofalse(most models work correctly)Rationale for defaults:
streaming = true: Currenttool_call = truealready implies streaming works. This is the norm.parallel = false: Parallel tool calling is NOT universal. Safer to assume not supported unless proven.coerces_types = false: Most models handle types correctly. This documents the exception.This makes the new granular flags "opt-out" for exceptions. You only specify fields when they differ from the defaults.
Breaking Change Note
This is a breaking change for consumers who expect
tool_callto always be a boolean.However, models.dev has precedent for breaking schema changes:
input_modalities/output_modalities→modalities: {input: [], output: []}inputCached/outputCached→cache_read/cache_writeConsumers will need to update their parsing logic to handle
tool_callas either a boolean or an object. This is a one-time update that provides long-term value.Migration Guide for Consumers
Before (req_llm example):
After:
Future Extensibility
If additional quirks are discovered, they can be added as optional fields without breaking existing consumers.
Testing
The schema change has been validated to accept:
true,false)supportedfieldstreaming,parallel, andcoerces_typesfields.strict()enforcement)Related Issues: