Repository navigation
fix: reject unknown conversation id instead of implicit creation - #531
maralbahari merged 4 commits into
Conversation
A Responses request referencing a conversation id that does not exist no longer creates the conversation implicitly; it now returns the storage not-found (HTTP 404), matching the OpenAI Conversations contract (closes vllm-project#155) Signed-off-by: Jack Wei <[email protected]>
maralbahari
left a comment
There was a problem hiding this comment.
Thanks for picking up #155. The direction is right: OpenAI rejects a Responses request whose conversation names an unknown id, for both store: true and store: false and for the {"id": ...} form, instead of creating it. A few things are needed before this can go in.
The error envelope. OpenAI answers 404 with type: invalid_request_error and the message Conversation with id '<id>' not found.. This PR returns type: not_found with storage error: not found: Conversation with id '<id>'. Missing responses already follow OpenAI through typed StorageError::ResponseNotFound / PreviousResponseNotFound variants that carry OpenAI's message and map to invalid_request_error in ExecutorError::error_type; a missing conversation should do the same. ConversationStore::rehydrate already detects it (StorageError::not_found("Conversation", ...) in storage/conversation.rs), so returning a typed conversation-not-found error from there is enough; no separate lookup is needed.
Finish the removal. With implicit creation gone, ConversationStore::get_or_create and models::conversation::get_or_create (an INSERT ... ON CONFLICT ... RETURNING * upsert) have no production caller left; they would only run in test_conversation_get_or_create_same_id and postgres_get_or_create_creates_then_returns_the_existing_conversation. Since rehydrate already reports the missing conversation, please remove them with those tests (explicit creation stays separate, in ConversationStore::create behind POST /v1/conversations), and update ARCHITECTURE.md, which still says a missing conversation "is created for a stored turn" and lists get_or_create among the store and handler methods.
Verification: before vs afterI ran two gateway binaries on an isolated port (
The implicitly-created row from the old binary had an empty Valid path still works (verified on the fixed binary, step by step):
So only "reference an unknown id → create implicitly" is removed (now a fast 404); the normal "create first, then reference" stateful multi-turn flow is unchanged. Note for anyone reproducing: rebuild the |
Thanks for verifying this. Please add the case as a cassette recording so it's gated in the repo: append turns to the |
Add typed StorageError::ConversationNotFound returned by ConversationStore::rehydrate, mapping to HTTP 404 with type invalid_request_error, param conversation and message Conversation with id '<id>' not found. Remove the now-unused get_or_create store/upsert and their tests; update ARCHITECTURE.md. Addresses review on vllm-project#155. Signed-off-by: Jack Wei <[email protected]>
|
Thanks for the detailed review. Points 1–3 are addressed in the new push (
Point 4 (cassette): I don't have access to an OpenAI API key, so I can't produce the recorded cassette via
Verification run locally (Rust 1.98.1): core lib 1419 passed; |
|
@justrightnow I will help to add those cassettes in. |
Bring in model capability validation (vllm-project#512), unknown conversation id rejection (vllm-project#531), persisted-turn documentation (vllm-project#533), and the shared input-item test helper (vllm-project#545). Signed-off-by: LeaderOnePro <[email protected]>
Summary
Closes #155.
A Responses request that references a
conversationid no longer creates that conversation implicitly when the id does not exist. Previously, withstore: true, a missing conversation fell throughfrom_conversationtoConversationHandler::get_or_create, so an unknown client-supplied id silently created a new conversation.The OpenAI Conversations contract requires creating a conversation through
POST /v1/conversationsfirst; referencing an unknown id must fail rather than be created. This change lets the storage not-found error surface, so the request returns404(type: not_found) for both stored and unstored turns.Changes:
storeimplicit-creation branch infrom_conversationand propagate the conversation not-found.ConversationHandler::get_or_createand its unit tests (the lower-levelConversationStore::get_or_createremains for storage tests).storefalse/true.Test Plan
cargo test -p agentic-server-core --test stateful_responses_integration— 27 passed (includes the newunknown_conversation_id_is_not_created_implicitly).cargo test -p agentic-server-core --test stateful_conversation_integration— 8 passed.cargo test -p agentic-server-core --lib conversation— related cases pass.cargo clippy -p agentic-server-core --all-targets -- -D warnings— no warnings.cargo fmt -- --check— formatted.