Skip to content

fix: preserve and verify image input through Responses - #263

Merged
franciscojavierarceo merged 5 commits into
vllm-project:mainfrom
Zheng-Lu:feat/253-verify-codex-images
Sep 17, 2026
Merged

franciscojavierarceo merged 5 commits into
vllm-project:mainfrom
Zheng-Lu:feat/253-verify-codex-images

Conversation

@Zheng-Lu

@Zheng-Lu Zheng-Lu commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #253 by preserving and verifying image input through the Responses API. This establishes the gateway baseline before #261 enables image input in the Codex catalog and launchers.

  • Preserve modeled message content and extension fields through typed input, persistence, continuation, and upstream forwarding. Support refusal history; reject unsupported message part types and empty content arrays on typed paths while retaining eligible raw proxy behavior.
  • Cover single-image, multiple-image, image continuation, and client-executed tool image-output scenarios using recorded OpenAI (gpt-4o) and gateway→vLLM (Qwen/Qwen2.5-VL-3B-Instruct) cassettes. Replay assertions compare protocol structure and image bytes rather than identical model wording.
  • Cover HTTP, WebSocket, function/custom/namespace tool outputs, conversation history, and compaction. Image generation and Codex launcher enablement are outside this PR.
  • Separate typed content definitions and compaction context predicates into focused modules to satisfy production file-size checks, preserving public import paths and tightening existing baselines.

Test Plan

Validation after the review patch:

  • Core library: 690 passed, 3 PostgreSQL-gated tests ignored.
  • Image cassette replay: 3 passed; cassette validation: 157 cassettes, 336 turns passed.
  • Compaction integration: 7 passed; HTTP Responses integration: 40 passed; WebSocket Responses integration: 56 passed.
  • cargo clippy -p agentic-server-core --all-targets --all-features -- -D warnings passed.
  • pre-commit run --all-files passed, including formatting and production file-size checks.

Existing recordings were inspected and replayed; the review did not regenerate them or repeat live provider/model calls. The recorder workflow and pinned image fixtures are documented in crates/agentic-server-core/tests/cassettes/README.md.

@LOGO127

LOGO127 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking up #253. I had an unpublished local image/replay candidate and am pausing its publication to avoid duplicating this PR.

There is one integration seam with my #258 (fab52ff): a no-commit merge into your 5318fb5 has conflicts in three core files: types/io/input.rs, types/io/output.rs, and executor/compaction.rs.

The local resolution keeps one shared InputContent::InputFile variant and your unknown-part filtering; it preserves #258's typed-path rejection before inference/compaction, without changing eligible raw-proxy traffic or structured tool-output files. The nested-content regression retains both your file/audio cases and #258's future-content case, so neither assertion is discarded.

rustfmt and the 17 replay-server Python tests pass for that combination. Full Rust verification is still pending: compilation completed, but the run was interrupted by filesystem I/O failures in my local WSL environment. This is not a passing Rust-suite, upstream-CI, or live vision-model result. Neither published branch has changed, and no mixed commit/PR has been created.

I'll keep #258's validation contract and this PR's image-preservation tests together when checking the eventual integration. The original test/replay implementation here remains yours; I am withdrawing the overlapping publication plan, not requesting ownership of #253.

@Zheng-Lu

Zheng-Lu commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for picking up #253. I had an unpublished local image/replay candidate and am pausing its publication to avoid duplicating this PR.

There is one integration seam with my #258 (fab52ff): a no-commit merge into your 5318fb5 has conflicts in three core files: types/io/input.rs, types/io/output.rs, and executor/compaction.rs.

The local resolution keeps one shared InputContent::InputFile variant and your unknown-part filtering; it preserves #258's typed-path rejection before inference/compaction, without changing eligible raw-proxy traffic or structured tool-output files. The nested-content regression retains both your file/audio cases and #258's future-content case, so neither assertion is discarded.

rustfmt and the 17 replay-server Python tests pass for that combination. Full Rust verification is still pending: compilation completed, but the run was interrupted by filesystem I/O failures in my local WSL environment. This is not a passing Rust-suite, upstream-CI, or live vision-model result. Neither published branch has changed, and no mixed commit/PR has been created.

I'll keep #258's validation contract and this PR's image-preservation tests together when checking the eventual integration. The original test/replay implementation here remains yours; I am withdrawing the overlapping publication plan, not requesting ownership of #253.

Thanks for reaching out.

The resolution strategy you tested locally sounds great: keeping InputContent::InputFile along with the unknown-part filtering, while incorporating #258's typed-path validation and combining the regression test cases, is a very clean and complete solution.

Whenever #258 (or #252) lands, I'm happy to rebase and align with that resolution, or vice versa if this PR merges first. Thanks again for the thoughtful heads-up and collaborative spirit!

@LOGO127

LOGO127 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

AI-assisted follow-up from LOGO127: I found a separate replay-fixture concurrency issue while adding complementary coverage against your exact head 5318fb5ee3692f2a8053301c0e3ed4f1a0b173ab.

On Windows / Python 3.13.6, the unchanged append_capture implementation loses JSONL records when multiple handler threads append concurrently. A new file-level regression starts 8 writers, each appending 32 records with a 16 KiB payload. All 10 baseline repetitions failed: 208-227 records survived instead of 256. This is a Windows reproduction, not evidence that your Linux Actions job has failed.

A local two-file candidate serializes each record's open/write/flush/close with a process-local lock and adds that regression plus a six-request HTTP check (one recorded turn consumed, one 200 and five 409 responses, all 12 capture records retained). After the fix:

  • All 19 replay tests pass on Windows Python 3.12 and 3.13: your existing 17 tests plus these two additions.
  • The two new cases pass 50 file-level and 20 HTTP repetitions on Python 3.13; these are repeats, not 70 distinct cases.
  • All applicable hooks for the two changed files pass.

No Rust, cassette, model-catalog, or image-validation behavior changes are involved. I have not verified this on Linux, with a live vision model, or across multiple writer processes. The separate #258 integration still needs its full Rust verification.

Would you prefer this fixture fix as a separate follow-up, or folded into #263? I have kept the candidate local pending personal review and scope agreement; no competing #253 PR or signed/public patch has been created.

@LOGO127

LOGO127 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

AI-assisted scope proposal from LOGO127, following the separate capture-concurrency note above:

I prepared a complementary fixture-only extension against unchanged 5318fb5, without modifying your Rust/image implementation: optional assert-capture --expect-tool-image CALL_ID SHA256 checks structured function/custom tool outputs by call ID and exact ordered PNG digests. It rejects stringified arrays, wrong/duplicate calls, and missing/extra/reordered images. Message attachments cannot satisfy tool-output assertions, and the existing attachment assertion is unchanged.

All 28 replay tests pass on native Windows Python 3.12 and 3.13 (your 17 plus 11 new methods); coverage includes real loopback HTTP capture and Python CLI subprocesses. Applicable three-file hooks pass. This remains a single outgoing-request capture assertion, not a new multi-round runner or evidence of real Codex tool execution, Rust/WebSocket correctness, or live-model understanding. No cassette changed. The earlier two-file concurrency candidate remains separate.

Would maintaining capture assertions and fixture concurrency be a useful complementary slice for me to take on, as a follow-up to your #263? The new extension is still local, pending scope agreement and personal review/sign-off; I have not opened a competing #253 implementation.

@LOGO127

LOGO127 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

A follow-up closing the local Rust-validation gap in my earlier integration report: the unchanged combination of your 5318fb5 head and #258 fab52ff now passes the full workspace/all-features tests on WSL Linux with Rust 1.98.0: 979 passed, 0 failed, 9 ignored (excluding two duplicate nested subprocess summaries). Strict workspace/all-targets/all-features Clippy with -D warnings also passes.

I verified all 448 source files and executable flags against the original integration archive (tree 5a1628c224a104bc3a056e267c5e51caa06f089b) before running. The three-conflict resolution is unchanged: one shared InputFile variant, your unknown-part filtering, #258's typed-path rejection, and the combined nested-content regressions. The previous I/O failure no longer prevents these checks; no source or cassette changes were needed.

Commands: cargo +1.98.0 test --workspace --all-features --locked --offline --no-fail-fast --quiet and cargo +1.98.0 clippy --workspace --all-targets --all-features --locked --offline -- -D warnings.

This is evidence for that exact local combination, not current-main/upstream CI or live vision-model validation. The ignored tests remain ignored; PostgreSQL acceptance is not claimed. The separate capture-concurrency/assertion proposals are not included. Neither published branch has been changed, and I have not signed or published the mixed integration tree. AI-assisted verification; thanks again for coordinating the resolution.

@Zheng-Lu
Zheng-Lu force-pushed the feat/253-verify-codex-images branch from 5318fb5 to 553ea1e Compare September 14, 2026 15:39
@Zheng-Lu
Zheng-Lu marked this pull request as ready for review September 14, 2026 18:18
@Zheng-Lu
Zheng-Lu force-pushed the feat/253-verify-codex-images branch 2 times, most recently from e52cbf4 to fbdd150 Compare September 14, 2026 19:07
@maralbahari

Copy link
Copy Markdown
Collaborator

@Zheng-Lu could you please update the PR title and resolve merge conflict thanks

@Zheng-Lu
Zheng-Lu force-pushed the feat/253-verify-codex-images branch from fbdd150 to 6a3ba20 Compare September 17, 2026 14:56
…llm-project#253)

Message content parts the typed Responses executor cannot convey are now
rejected with a 400 naming the part (`input[i].content[j]` and its type)
instead of being forwarded as a synthetic {"type": "unknown"} part that no
client sent. This extends the existing input_file rejection to unmodeled
part types and to empty part arrays, so one validator owns the rule that a
typed message is never mutated in transit, never means something different
on the typed path than on the raw store=false path, and is never persisted
with content the client did not send.

InputContent gains a hand-written deserializer so an unmodeled part keeps
its type name for the error, and its Unknown variant can no longer
serialize, which makes "never forwarded, never stored" a compile-time
property rather than a convention. `refusal` is modeled as an assistant
history part so OpenAI-style history replays through the typed executor.

Add deterministic gateway coverage for image preservation over HTTP and
WebSocket: mixed text/image ordering, multiple images per message,
client-executed view_image tool output, previous_response_id continuation,
conversation rehydration, stateless store=false proxying, compaction of
retained image-bearing user messages, and rejection of unmodeled or empty
message content before inference and before persistence.

Claude-Session: https://claude.ai/code/session_01EsbCF1Smauv41qnpnqYvfz
Signed-off-by: Zheng Lu <[email protected]>
- Accept --input-file for the first of several turns, so a conversation
  that opens with an item array (for example an input_image part) can be
  continued by previous_response_id in the same recording.
- Send a tool handler's list of typed content parts as the structured
  function_call_output `output` array instead of a JSON string, which is
  how a cassette records a client-executed tool returning an image.

Claude-Session: https://claude.ai/code/session_01EsbCF1Smauv41qnpnqYvfz
Signed-off-by: Zheng Lu <[email protected]>
…llm-project#253)

Record paired cassettes for the two paths the gateway must keep equivalent:
client -> OpenAI Responses API (gpt-4o, the reference) and client -> Agentic
API -> vLLM 0.29.0 serving Qwen/Qwen2.5-VL-3B-Instruct. Both paths receive
the same image bytes, prompts, and tool definitions; only the model differs.

Scenarios, each streaming and non-streaming per provider (16 cassettes):
a text-and-image message; text interleaved with two different images in
order; a previous_response_id follow-up that rehydrates the earlier image;
and a client-executed view_image tool whose function_call_output is a
content array carrying the image, which the model answers from.

The replay test compares protocol structure only: request bodies equal
across providers modulo model and call ids and byte-equal to the committed
fixtures, completed-response shape, contiguous sequence numbers and an
identical normalized streaming lifecycle for both message and
function_call rounds, and the history the gateway forwards on continuation
with every image part and the structured tool output intact.

Qwen2.5-VL's stock chat template has no tools block, so with tool_choice
auto the model never sees declared functions; the committed
qwen2.5-vl-hermes-tools.jinja adds the Hermes tools prompt while keeping
multimodal rendering, including images inside tool responses. The README
documents the full vLLM launch and recording procedure.

Claude-Session: https://claude.ai/code/session_01EsbCF1Smauv41qnpnqYvfz
Signed-off-by: Zheng Lu <[email protected]>
@Zheng-Lu
Zheng-Lu force-pushed the feat/253-verify-codex-images branch from 6a3ba20 to ba364a6 Compare September 17, 2026 15:40
@franciscojavierarceo franciscojavierarceo changed the title test: verify Codex image attachments and image tool outputs through Responses (#253) fix: preserve and verify image input through Responses Sep 17, 2026

@franciscojavierarceo franciscojavierarceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split the content types and compaction helpers without changing their behavior. the image replay, HTTP, WebSocket, compaction, core tests, Clippy, and pre-commit checks pass locally.

@franciscojavierarceo
franciscojavierarceo merged commit 068feb2 into vllm-project:main Sep 17, 2026
19 checks passed
@Zheng-Lu
Zheng-Lu deleted the feat/253-verify-codex-images branch October 9, 2026 13:17
maralbahari pushed a commit that referenced this pull request Oct 22, 2026
…471)

## Summary

Closes #469.

The typed Responses executor now accepts a user-message `input_file`
when its `file_data` carries an inline UTF-8 text
file, and sends it to the model as text. Until now every message
`input_file` got a 400 (#256/#258). That meant a
text-only model behind the gateway could not read a `.txt`, `.md`,
`.json` or `.yaml` attachment a client sent inline.

What is accepted:
- a base64 data URL with a text media type (`text/*`,
`application/json`, `application/xml`, `application/yaml`).
Parameters such as `charset` are ignored, and an explicit media type
takes precedence over the filename;
- raw base64, or `application/octet-stream` / an empty media type, with
a `filename` that has a common text extension.

How it works:
- **Validation** (`types/io/input/validation.rs`, new
`types/io/input/file_text.rs`). The existing validation runs on
new input, rehydrated `previous_response_id`/`conversation` history and
every upstream build (including the
compaction summary). It now decodes the file (`base64` crate, already a
dependency, then strict UTF-8). Each other
case gets a specific 400 reason: `file_id` (no Files API), `file_url`
(no fetching), missing `file_data`, non-text or
PDF data, a non-base64 data URL, invalid base64, non-UTF-8. The
`input[i].content[j]: ` prefix is kept, and no reason
  echoes the file data, URL or media type.
- **Model-facing copy only** (`normalized_model_input`). The file
becomes an `input_text` part in the same position,
prefixed with `File: <filename>\n` when a filename is set. This is the
same presentation proposed in vLLM #62676, so
  both paths would give the model the same prompt.
- **Storage is unchanged.** Stored history and compacted windows keep
the client's original `input_file`, and the text
is re-inlined on each continuation. This follows the #263 rule: never
persist content the client did not send.
- **Routing.** A `store: false` request with an inline text file goes to
the executor instead of the raw proxy, so
stateless and stored requests give the model the same input. `store:
false` requests with `file_id`, `file_url` or
PDF files are still raw-proxied byte for byte. The predicate
(`ResponsesInput::has_inline_text_file`) only classifies
the reference fields and the media type, without decoding. It is checked
in the HTTP routing decision next to the
tool-search state, not in `in_process_feature()`. `in_process_feature()`
also gates split execution in
`agentic-llm-d`, and split execution already builds its upstream body
through `to_upstream_request`, so it can serve
  these files.
- **Compaction** (`executor/compaction/context.rs`). An inline file
counts as meaningful context, so a compaction whose
  input is only a file no longer fails with "requires non-empty input".
- **Docs/CHANGELOG.** Rewrote "File inputs" in
`docs/guides/responses-compaction.md`. The section appeared twice, so
  this also removes the duplicate. Added an `[Unreleased]` entry.

Not in scope: `file_id` resolution (#356), fetching `file_url`, PDF/DOCX
extraction, Chat Completions `file` parts
(that route is a passthrough), and a separate decoded-size limit. Inline
files are bounded by the existing
`max_request_body_size_bytes`, and the body shrinks after decoding. No
new dependencies, no I/O. No changes to
`events/`, the ingestion state machine, the relay or `engine.rs`.

Open questions for reviewers:
1. Should `store: false` text-file requests go through the executor, as
here, or should the raw proxy stay
byte-transparent for them? Dropping the routing change is a two-line
revert in the HTTP handler.
2. Is the `File: <filename>` header the format you want?
3. Do you want an explicit decoded-size cap in `ResponsesConfig`? Adding
a field would break struct literals, so it is
   left out here.
4. Should the compaction token estimate count the decoded size (about
3/4 of the base64 length) instead of the base64
   length? It is unchanged here, which overestimates.

## Test Plan

Unit tests (`agentic-server-core`):
- `file_text.rs`: accepted media types (including `charset` parameters
and uppercase types), an
`application/octet-stream` or empty media type falling back to the
filename, raw base64 with `.yaml`/`.YML`, empty
and multi-byte UTF-8 files, a PDF rejected by media type (even with a
`.txt` filename) and by filename, `file_id`,
`file_url`, missing data, a non-base64 data URL, invalid base64,
non-UTF-8, and routing classification (text
files are detected without decoding; references, PDFs, images and
tool-output files are not).
- `validation.rs`: file errors keep their `input[i].content[j]` position
and never echo the URL. Inline text files pass
in new input and in restored history. The previous `input_file` case in
the position test now uses an unknown part
  type, and `file_url` is covered by its own test.
- `conversions.rs`: the model copy has `input_text` with the header in
the original order. Canonical items keep
  `input_file`. Input with no files stays `Cow::Borrowed`.

Integration tests (`crates/agentic-server/tests/input_file_repro.rs`,
mock upstream and in-memory SQLite). All 30
existing tests still pass unchanged. They use a `file_url` PDF, which is
still rejected before inference and before
persistence, and the raw-proxy byte-for-byte controls still hold. 9 new
tests:
- `store: true` with a data URL: 200. The upstream gets `input_text`
`"File: notes.txt\n..."` with no `file_data`, and
  the stored item is the original `input_file`;
- raw base64 with `filename: config.yaml` is inlined;
- streaming HTTP gives the same upstream body;
- a `previous_response_id` follow-up re-inlines the stored file, and
storage still holds the single original `input_file`;
- WebSocket `response.create` is accepted and inlined;
- `store: false` with a text file runs through the executor: inlined,
nothing persisted;
- `store: false` with invalid base64 gets a 400 from the gateway instead
of being proxied;
- `/v1/responses/compact` with a message containing only a file
succeeds. The summary request has the text, and the
  returned window keeps `input_file`;
- each rejection reason (`file_id`, `file_url`, missing data, PDF data
URL, PDF filename, non-base64 data URL, invalid
base64, non-UTF-8) gives a 400 with the specific message: no inference,
nothing persisted.

Commands, all run in WSL Ubuntu-22.04 with Rust 1.98.1:
- `cargo fmt --all --check`: pass
- `cargo clippy --all-targets -- -D warnings`: pass
- `cargo test -p agentic-server --test input_file_repro`: 39 passed, 0
failed
- `cargo test -p agentic-server`: 710 passed, 0 failed (42 test
binaries)
- `cargo test -p agentic-server-core`: 1776 passed, 1 failed, 17
ignored. The failure is

`tool_search_characterization_test::provider_parity_recorder_generated_matrix_has_one_semantic_flow`,
which asserts
that checked-in cassettes are not executable. It fails only because the
checkout is on a Windows drive mounted in WSL
(`/mnt/c`), where every file reports mode 0777. This change touches no
cassettes.
- `python scripts/check_rust_file_sizes.py` (the `rust-file-sizes`
hook): pass, 291 production files checked. The new
`file_text.rs` has 155 production lines. `types/io/input.rs` has 485
production lines, plus one `mod` line.
- `git diff --check`: clean

---------

Signed-off-by: MetehanAydemir <[email protected]>
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.

Verify Codex image attachments and image tool outputs through Responses

4 participants