mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* fix(bedrock): keep shared $defs in Claude tool schemas and bound inlining for other models * fix(bedrock): keep unpack_defs memory linear when a schema has many definitions unpack_defs copied the whole definitions dict for every node it visited, so a tool schema with N definitions and M nodes held N*M entries at once. Keep the scope as a tuple of the definitions layers instead, and add a layer only when a node or a resolved target declares its own $defs or definitions. * fix(bedrock): inline only legacy refs for Claude and follow root $ref aliases On Claude the legacy pass now resolves only definitions and components.schemas refs, so a definitions block beside $defs no longer expands the $defs tree. A root $ref is followed through alias chains so the root keeps its object schema. A non-map defs block or a non-string $ref is left as is instead of crashing * fix(bedrock): walk legacy refs inside a $defs ref and skip malformed definitions on Claude A $ref the legacy-only pass does not resolve is now walked like any other node, so a definitions ref inside a $defs entry is inlined instead of dangling. A definitions or components value that is not an object is dropped instead of failing the request * fix(bedrock): merge root ref siblings, drop unused $defs, and use the shared inlining budget A root $ref beside an empty properties block, the shape MCP tools get, now merges into its target instead of replacing the target's properties, so a strict Claude tool sends its real arguments again. Claude also stops getting $defs entries no $ref reaches, which kept unused definitions out of its input tokens before this branch. Inlining for other models and for legacy definitions now uses the same 10 MB budget the native Anthropic route uses, since 1 MB refused an 852 KB expansion that worked at the merge base, and the 400 now names the bytes of definitions copied * fix(bedrock): inline every Claude ref outside the root $defs and keep the shared legacy-defs helper as before Claude on Bedrock only gets the root $defs, so a root $ref into definitions, a $defs block nested in a property or in a root ref target, and a percent-encoded pointer now resolve before the schema is sent. Unused-entry pruning counts refs anywhere in the schema, non-Claude models never receive a root $defs, and unpack_legacy_defs keeps resolving every ref by name for the native Anthropic, Vertex, MCP and Fireworks routes * fix(bedrock): keep shadowed and unused Claude defs from changing meaning or spending budget, and inline boolean definitions * fix(bedrock): resolve a root ref target's own defs as before, fall back on oversized schemas, and accept non-string keys A Claude tool whose root $ref target declares a $defs name the root also declares with a different body now goes through the merge-base inlining, so refs inside the target keep resolving to the nearer definition Running past the 10 MB inlining budget now raises ContextWindowExceededError, so context_window_fallbacks fire as they did when Bedrock answered prompt is too long The tool schema walk accepts dict keys that are not strings, and only the budget overflow maps to the budget error, so an SDK tool with an int property key is no longer rejected with a false 10 MB message * fix(bedrock): raise a named AttributeError subclass for a $ref target that is not a schema * fix(bedrock): skip unused root definitions when inlining refs for non-Claude models Models that get every $ref inlined never receive the root definitions or components blocks, so walking them only spent the shared 10 MB inlining budget and could reject a small tool. * fix(bedrock): ignore unused legacy definitions when choosing which Claude $defs to keep A $defs entry reached only from a definitions or components block that the request drops no longer keeps its legacy refs inlined against the shared budget. Legacy entries the body reaches are still followed, so their $defs targets stay. * fix(bedrock): inline Claude tool refs written without a leading hash A $ref such as /$defs/Address is not a pointer into the document, so Claude on Bedrock now gets it inlined as at the merge base instead of kept. A root ref like that was dropped by the tool spec and left the tool with no arguments. * fix(bedrock): inline a Claude root $ref chain the hop limit leaves unresolved A root $ref chain longer than the hop limit left a root $ref that BedrockToolSpec drops, so Claude got no properties. The resolver now reports such a schema as unresolved, and the tool falls back to bounded full inlining like the base. * fix(bedrock): keep the Claude $defs reachability pass linear on long ref chains * test: track the long $defs chain cost with a CodSpeed benchmark instead of wall time * fix(bedrock): read the Claude $defs capability from the cost map first --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| test_a2a_benchmarks.py | ||
| test_benchmarks.py | ||
| test_count_tokens_benchmarks.py | ||
| test_extraction_guardrail_benchmarks.py | ||
| test_inference_benchmarks.py | ||
| test_json_fragment_accumulator_benchmarks.py | ||
| test_mcp_benchmarks.py | ||
| test_prompt_template_benchmarks.py | ||
| test_realtime_session_merge_benchmarks.py | ||
| test_responses_compaction_benchmarks.py | ||
| test_sse_lines_benchmarks.py | ||
| test_token_counter_pdf_benchmarks.py | ||