fix(addie): get_schema truncates large schemas at 6K chars#4398
Draft
bokelley wants to merge 3 commits into
Draft
fix(addie): get_schema truncates large schemas at 6K chars#4398bokelley wants to merge 3 commits into
bokelley wants to merge 3 commits into
Conversation
…ncation note The 6,000-char substring cut silently hid entire oneOf branches: creative/preview-render.json (~7.7K) and creative/preview-creative-response.json (~11K) were both truncated, with the third oneOf branch in preview-render and the variant branch in preview-creative-response completely hidden from Addie. Additionally, the old truncation note directed the AI to use the `property` parameter, which only works for schema.properties — not for union-type schemas (oneOf/allOf/anyOf). This pointed Addie toward a dead end, causing hallucination. Changes: - Raise SCHEMA_MAX_DISPLAY_CHARS from 6K to 20K - Extract formatSchemaJson() pure function for testability - Provide context-aware truncation note: property-hint for schemas with top-level properties, union-type hint for union-only schemas - Raise PRESERVE_TOOL_RESULTS threshold in token-limiter.ts from 20K to 25K to keep the two layers coherent (25K = 20K JSON + header overhead) - Bump CODE_VERSION to 2026.05.2 per playbook (mcp/*.ts change) - Add 6 unit tests for formatSchemaJson covering regression guard for #4397 Fixes #4397. https://claude.ai/code/session_01Qy5CniM5du4RLEDiTadFuJ
Regenerated by build; reflects the primary_brand_domain → Linked Domains UI description update committed in #4313 that was not yet reflected in dist. https://claude.ai/code/session_01Qy5CniM5du4RLEDiTadFuJ
…note Follow-up to initial fix — prompt-engineer review flagged two blockers: 1. 20K ceiling still truncates core/format.json (~29K) and core/product.json (~25K), the most commonly queried schemas. Raise SCHEMA_MAX_DISPLAY_CHARS to 50K, covering all current v3 schemas except the largest union enumerations (get-adcp-capabilities-response ~75K, brand.json ~74K — documented as known remaining limitation). Raise PRESERVE_TOOL_RESULTS in token-limiter to 55K to stay coherent. 2. Union-only truncation note suggested 'list_schemas' — a dead end for inline union schemas (brand.json, adagents.json) whose branches are not separate registry files. Replace with actionable 'validate_json' guidance. Also: fix propNames derivation when `property` is set — truncation hint now uses displaySchema.properties (the sub-property's own children) rather than root schema.properties, so the hint points to paths the agent can actually drill into next. Add 2 tests covering these regression cases. https://claude.ai/code/session_01Qy5CniM5du4RLEDiTadFuJ
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.
Closes #4397
Summary
The
get_schemaAddie tool truncated JSON schemas at a hardcoded 6,000-char limit using a rawsubstring()cut, producing syntactically broken output and hiding entireoneOfbranches.creative/preview-render.json(~7.7K) had its thirdoutput_format: "both"branch cut mid-sentence;creative/preview-creative-response.json(~11K) had thevariantbranch hidden entirely. The truncation note compounded the issue by directing the AI to thepropertyparameter — which only works forschema.properties, not for union-type schemas.Changes:
SCHEMA_MAX_DISPLAY_CHARSfrom 6K → 50K, covering all current v3 schemas except the largest union enumerations (get-adcp-capabilities-response~75K,brand.json~74K — documented as known remaining limitation; both reported schemas andcore/format.json~29K,core/product.json~25K now return in full)formatSchemaJson()as an exported pure function, making truncation logic unit-testable without HTTP mocksproperties;validate_jsonguidance foroneOf/allOf/anyOf-only schemas (replaces the previous dead-endlist_schemasredirect)propNamesderivation whenpropertyis set: truncation hint now usesdisplaySchema.propertiesso the note points to paths the agent can actually drill into, not siblings it has already passedPRESERVE_TOOL_RESULTSthreshold intoken-limiter.tsfrom 20K → 55K to stay coherent with new 50K JSON ceilingCODE_VERSIONto2026.05.2per playbook (mcp/*.ts tool implementation change)formatSchemaJsonincluding regression guards for get_schema tool truncates large schemas mid-content #4397Known remaining limitation: Schemas exceeding 50K chars (
get-adcp-capabilities-response.json~75K,brand.json~74K,adagents.json~50K borderline) will still trigger the truncation path. For these,validate_jsonguidance in the truncation note is the correct fallback.Non-breaking justification
Server-side Addie tool output change only. Existing callers that worked before still work; callers that were receiving truncated data now receive complete data. No protocol schemas, task definitions, or public API surfaces changed.
Pre-PR review
toLocaleString('en-US')locale safety, stale JSDoc. Noted truncated JSON-in-fence is pre-existing; no blockers.list_schemaswith actionablevalidate_jsonguidance.propNamesderivation fix added for sub-property truncation.Session: https://claude.ai/code/session_01Qy5CniM5du4RLEDiTadFuJ