test: cover multi-block system preservation across the Messages gateway loop - #154
Conversation
…ay loop The gateway tool loop rebuilds the upstream request body each round (append_round_to_history appends the assistant turn + tool_result to messages). A multi-block Anthropic `system` — the attribution block + instructions shape Claude Code sends — must ride through untouched, but the loop path had no coverage of it (only the transparent-proxy path did). Adds a two-round loop test asserting both upstream request bodies carry the identical system blocks, so a future refactor that rebuilds the body from a curated field subset can't silently drop system. Closes the Stage 3 (vllm-project#116) system-attribution parity item. Signed-off-by: Ashwin Giridharan <girida@amazon.com>
franciscojavierarceo
left a comment
There was a problem hiding this comment.
The new regression guard covers only the non-streaming run_messages_loop path. Claude Code sends stream: true, and /v1/messages routes those requests through the independent run_messages_stream implementation and its own round-history mutation. Without a matching request-body assertion in messages_stream_test.rs, a streaming-only refactor could still drop or reshape the multi-block system field while this test remains green.
I’m pushing the corresponding streaming request-capture regression test to this branch before merge.
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
franciscojavierarceo
left a comment
There was a problem hiding this comment.
Verified the non-streaming and streaming multi-block system regression coverage, including a mutation check against the streaming path. Local cargo test, formatting, and Clippy all pass.
Summary
Adds a regression guard that a multi-block Anthropic
systemfield survives the/v1/messagesgateway tool loop unchanged across rounds.The loop rebuilds the upstream request body every round —
append_round_to_historyappends the assistant turn +tool_resulttomessages. It only touchesmessages, sosystemshould ride through untouched, but the loop path had no coverage of that (only the transparent-proxy path assertedsystemforwarding). Claude Code sendssystemas an attribution block + instructions, so this is the shape that matters.The test drives a two-round gateway loop with a multi-block
systemand asserts both upstream request bodies carry the identical blocks — so a future refactor that rebuilds the upstream body from a curated field subset can't silently dropsystem.Completes the Stage 3 (#116) system-attribution parity item. Part of #113.
Test Plan
cargo test -p agentic-server-core --test messages_loop_test --test messages_stream_test(15 tests, including non-streaming and streaming multi-blocksystempreservation)cargo fmt -- --checkcargo clippy --all-targets -- -D warnings