Skip to content

fix: preserve bounded inline images during tool artifact sizing - #603

Closed
ldavis9000aws wants to merge 1 commit into
LibreChat-AI:mainfrom
ldavis9000aws:codex/mcp-image-counting
Closed

ldavis9000aws wants to merge 1 commit into
LibreChat-AI:mainfrom
ldavis9000aws:codex/mcp-image-counting

Conversation

@ldavis9000aws

@ldavis9000aws ldavis9000aws commented Oct 8, 2026 •

Copy link
Copy Markdown

Withdrawn by the submitter; not merged. This concerns a separately reproduced same-turn inline-image sizing defect, not the documented omission of tool-image pixels on later user turns. The technical reproduction and proposed bounded sizing correction remain valid. Local deployed patches, source branches and tests are retained; withdrawal does not undo them.


Large MCP image artifacts can disappear from the next model request even when maxToolResultChars is sufficient. A 2.48 MB PNG expands to approximately 3.3M base64 characters and exhausts the fixed 1M structured character traversal allowance during jsonStringLength; the resulting conservative size estimate makes artifact accumulation omit it.

Count bounded escape-free inline image data URIs directly. Keep configured tool-result limits, the existing 5M inline-image ceiling, context budgeting, and traversal protection for arbitrary/malformed content. Both provider projections use this shared size calculation.

Graph.projectServingArtifacts
  -> provider artifact projection
    -> bounded artifact accumulation
      -> compactToolContent / getToolContentCharLength
        -> jsonStringLength

Validation: focused toolContent Jest suite (60 passed), npx tsc --noEmit, scoped ESLint, diff check. Installed 4.0.1 patch integration (11 passed, both provider projections and ESM); actual LibreChat + Desktop Commander + LiteLLM requests contain PNG pixels and Claude accurately reads labels, compares two boards, repeats reads, and continues with a text tool. Synthetic unit payloads verify sizing, not visual interpretation. Runtime deployment remains on 4.0.1; no package upgrade is required for the reproduced fix.

Fixes #602. Related to ldavis9000aws/cf-fleetrebuild#55 and ldavis9000aws/CreatorFlow#47.

@ldavis9000aws

Copy link
Copy Markdown
Author

Withdrawing and closing this PR without merging at the submitter's request. To avoid conflating findings: this PR concerns same-turn artifact sizing, where the structured traversal allowance can omit an otherwise permitted inline image. LibreChat's documented cross-turn image policy does not explain or invalidate that defect. The reproduction and focused tests remain valid, but we are withdrawing this upstream contribution. No claim of upstream resolution is made; local source and existing patches are retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large MCP image artifacts omitted despite sufficient maxToolResultChars

1 participant