fix: preserve capabilities when model/1 receives a populated LLMDB.Model struct#601
Closed
mhsdef wants to merge 1 commit intoagentjido:mainfrom
Closed
fix: preserve capabilities when model/1 receives a populated LLMDB.Model struct#601mhsdef wants to merge 1 commit intoagentjido:mainfrom
mhsdef wants to merge 1 commit intoagentjido:mainfrom
Conversation
…del struct Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d7ece78 to
c14d508
Compare
Contributor
Author
|
Nope. |
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.
Description
When
ReqLLM.model/1receives a fully-populated%LLMDB.Model{}struct (e.g. constructed viaLLMDB.Model.new!/1with explicit capabilities), it was tearing the struct apart, stripping nil fields, running it throughLLMDB.Enrich.enrich_model/1, and rebuilding viaLLMDB.Model.new(). This caused caller-provided fields likecapabilitiesto be overwritten by Zoi schema defaults (e.g.json.schema: false,tools.enabled: false).This matters because the recommended advanced usage path — constructing an explicit
LLMDB.Modelstruct for models not yet in the catalog or with incorrect catalog data — was silently losing the capabilities the caller set. This causeddetermine_output_mode/2to fall back to:tool_strictinstead of using native:json_schemastructured output, even when the caller explicitly declaredjson: %{schema: true}.Root cause:
LLMDB.Enrich.enrich_model/1only derivesfamilyandprovider_model_id— it doesn't do catalog lookups. After enrichment, the original non-nil values were being discarded. The fix merges enriched fields (family, provider_model_id) back under the caller's original values, so explicit capabilities are never overwritten.Type of Change
Breaking Changes
None. The existing behavior for bare structs (e.g.
LLMDB.Model.new!(%{id: "foo", provider: :openai})with no capabilities) is unchanged — enrichment still fills infamilyandprovider_model_id.Testing
mix test) — 2814 tests, 0 failuresmix quality)model/1round-trip for a fully-populated structChecklist
CHANGELOG.md(it is auto-generated by git_ops)Related Issues
Discovered while investigating why
determine_output_mode/2was returning:tool_strictfor models withjson.schema: truecapabilities — the capabilities were being silently dropped duringmodel/1normalization.