Skip to content

[PR] fix(guardrails): preserve multimodal tool output order - #6581

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_tool-content-order
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_tool-content-order

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #6580

Problem

The shared pi/omp tool-result guardrail moves every image/resource ahead of all text whenever the default 50,000-byte text cap is exceeded. A result containing caption/image/caption/image becomes image/image/one text block, changing which description precedes each image and discarding text-part metadata.

Change

Map the existing UTF-8-safe combined text prefix back onto the original text parts, retaining non-text blocks in place and copying metadata for retained text. Append one truncation notice to the final retained text part (or the first text position when the byte budget cannot fit one character).

The shared text budget, complete-line preference, full-output path notice, default settings and disabled/pass-through behavior stay the same. This affects host tool results in pi/omp; proxy-mode message rewriting and the kernel are outside the changed path.

Verification

  • Six new regressions, including invocation through the actual registered tool_result callback with the default cap.
  • Unchanged master e1f31ad: 5 failures and 1 passing control.
  • Fixed branch: 49/49 new and existing guardrail tests pass.
  • UTF-8 boundary, shared byte budget, complete-line truncation, opaque resource order, text metadata, no input mutation and pass-through controls are covered.
  • Typecheck, full build, unused-export check, test-import-graph check and git diff --check pass.
  • Remote Git tree SHA matches the locally tested tree exactly. Full CI remains the pushed-head verdict.

Duplicate screening is recorded in the issue. No new configuration or persistence format.

@ranxianglei ranxianglei changed the title fix(guardrails): preserve multimodal tool output order [PR] fix(guardrails): preserve multimodal tool output order Nov 13, 2026
@ranxianglei
ranxianglei merged commit ac4dc60 into ranxianglei:master Nov 14, 2026
35 of 50 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit ac4dc60404f (Merge Afloat16/2026-11-13_tool-content-order (PR #6581)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6580 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

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.

Tool output cap moves image blocks ahead of their captions

2 participants