Repository navigation
fix(llm): select container union defaults by item schema - #8240
Draft
Ramcharan49 wants to merge 1 commit into
Draft
Ramcharan49 wants to merge 1 commit into
Ramcharan49 wants to merge 1 commit into
Conversation
Inspect array items before resolving union defaults, preserving the prior shape-only fallback for Pydantic-coercible inputs. AI-assisted investigation, implementation, review and local validation by OpenAI Codex. New regression suite: 4 failures on main; related suites: 417 pass.
This branch has not been deployed
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.
When a tool accepts
requests: list[EmailRequest] | list[SMSRequest], the null-default resolver currently selects the first array schema without checking its elements. With defaults of 2 and 5 retries respectively,[{"kind":"sms","retries":null}]becomes an SMS request with 2 retries: Pydantic chooses the SMS model after the wrong default has already been inserted, so validation succeeds with silently changed behavior.Check
itemsand positionalprefixItemsrecursively when selecting a default-injection variant. This selects the SMS default of 5 and also handles nested lists and tuple arguments. If no variant matches the item schemas strictly, retain the previous shape-only fallback so existing Pydantic-coercible input can still receive defaults.This follows the null-sentinel contract from merged #6444.
Validation on base
18c07ba0482d90093b361cb566b573a27e389515(Python 3.12.14, Linux; dependencies installed fromuv.lock):ruff 0.15.22, 1,207 files).python -m mypy --follow-imports=silent --platform linux -m livekit.agents.llm.utilspasses (mypy 2.3.0). Python 3.10 syntax parsing andgit diff --checkpass.CI on exact head
20974007bd6866e4090c36b3b6c69b18e346215b: Ruff, the release gate, and blockguard on Ubuntu/macOS/Windows pass. Unit-test collection and Python 3.13 all-plugin type checking fail on the pre-existing Thunderphone_shorten_call_idimport after its upstream rename to_shorten_id; the Python 3.10 matrix job was cancelled. The relevant files are byte-identical to the tested base, and the import failure was reproduced in a clean worktree of that base. Existing upstream PR #8229 addresses it; this PR does not duplicate that fix.Limits: the existing matcher remains a shape/literal heuristic, not a complete JSON Schema or Pydantic union validator. Ambiguous variants and variants requiring coercion retain the existing fallback behavior. No live providers or paid APIs were called. Full all-plugin type checking and the whole unit/audio suite were not run.
AI assistance: OpenAI Codex investigated, implemented and reviewed the patch, and executed the validation above. No personal human review is asserted. This PR is intentionally a draft; no CLA agreement has been accepted by this automated task.