Skip to content

fix: address Conversations API review comments and add cassette tests - #370

Merged
maralbahari merged 14 commits into
vllm-project:mainfrom
avinashsingh77:fix-conversations-review-comments
Sep 25, 2026
Merged

maralbahari merged 14 commits into
vllm-project:mainfrom
avinashsingh77:fix-conversations-review-comments

Conversation

@avinashsingh77

@avinashsingh77 avinashsingh77 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  1. Fixed architectural layering and pagination issues from review comments from feat: add OpenAI-compatible Conversations API #351
  2. Added cassette testing infrastructure (shell script, Python recorder, Rust replay tests)
  3. Documented cassette recording requirements.

Note: Actual cassette recording requires OpenAI API access or a running gateway instance, which were not available to me at the time of development.
The infrastructure is complete and ready for recording

Fixes #155

avinashsingh77 and others added 4 commits September 23, 2026 17:04
   Fixes three issues identified in PR review:

   1. **Architectural layering violation** (conversation.rs:24-26)
      - Make ConversationHandler.store() private to enforce typed operations
      - Add create_items(), list_items(), retrieve_item(), delete_item()
   methods
      - Update HTTP handlers to use typed operations instead of direct storage
      - Add fallible convert_item() helper that propagates errors

   2. **Pagination issues** (item.rs, conversation_items.rs)
      - Rewrite list_for_conversation() to use keyset pagination with (seq, id)
      - Resolve cursor to (seq, id) tuple within conversation and tenant
      - Use compound predicates matching ordering to prevent skip/repeat
      - Handle NULL seq values for items added via Items API
      - Add 'order' query parameter (defaults to 'desc' per OpenAI spec)
      - Add 'include' parameter with explicit rejection of unsupported values
      - Replace silent filter_map with fallible conversion that propagates
   errors

   3. **API compatibility testing**
      - Types already match OpenAI (items array, flattened response)
      - Cassette infrastructure exists (record_cassette.py)
      - Need to add Conversations mode to recorder (see cassettes/README.md)

   Changes:
   - crates/agentic-server-core/src/executor/modes/conversation.rs
     * Private store() accessor
     * New typed operations with ExecutorResult returns
     * Fallible item conversion helper

   - crates/agentic-server/src/handler/http/conversation_items.rs
     * Remove storage model imports
     * Add order/include query params with validation
     * Use ConversationHandler operations

   - crates/agentic-server-core/src/storage/models/item/conversation.rs
     * Rewrite list_for_conversation with keyset pagination
     * Resolve cursor to (seq, id), use compound predicates
     * Handle NULL seq edge cases

   - crates/agentic-server-core/src/storage/conversation/api.rs
     * Pass cursor ID directly (not pre-resolved sequence)

   - crates/agentic-server-core/src/types/conversations.rs
     * Add DeletedResponse::item() method

   C-authored-by: Claude Sonnet 4.5 <[email protected]>

Signed-off-by: Avinash Singh <[email protected]>
Explain the recording infrastructure and requirements for capturing
HTTP cassettes against OpenAI and gateway endpoints. Note that actual
recording requires either OpenAI API access or a running gateway
instance with LLM backend.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Signed-off-by: Avinash Singh <[email protected]>
@avinashsingh77
avinashsingh77 marked this pull request as draft September 23, 2026 16:17
@avinashsingh77
avinashsingh77 marked this pull request as ready for review September 23, 2026 16:32
@avinashsingh77
avinashsingh77 marked this pull request as draft September 23, 2026 16:57
Signed-off-by: Avinash Singh <[email protected]>
@avinashsingh77
avinashsingh77 marked this pull request as ready for review September 23, 2026 17:19
@maralbahari

maralbahari commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

@avinashsingh77 Thanks for the test support. I'll help to record the cassettes and push in your branch.

avinashsingh77 and others added 2 commits September 24, 2026 15:29
Consolidate storage, fix branching and pagination, and add OpenAI/gateway
cassettes. Correct test fixtures that reused item IDs.

Signed-off-by: maral <[email protected]>
@maralbahari

maralbahari commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

@avinashsingh77
The new recordings exposed gaps that our Responses-only tests could not see. I recorded conversation-item continuation, deletion, branching, and pagination against both OpenAI and the gateway, with streaming and non-streaming Responses calls.

  • Item identity: In OpenAI’s recording, an item ID in a Response’s output reappears unchanged in the conversation items list. Gateway storage previously generated a separate item_… row ID, hiding that relationship. It also allowed test fixtures to reuse one public ID for different messages or tool calls. Preserving public IDs made the database correctly reject those fixtures, which are now fixed.

  • History and branching: An item added through the Items API affects the next conversation-ID response. A branch from an earlier previous_response_id retains the earlier history and does not append its output to the original conversation. Response checkpoints now capture the conversation’s ordered items at the time of the turn, including items later removed from the live conversation.

  • Pagination: The recordings cover ascending and descending order, cursors, page metadata, and include. Pagination now uses a deterministic (sequence, ID) cursor. Gateway reasoning items can shift raw page boundaries, so each provider’s pages are checked against its own full ordered list.

The #351 PR also introduced extra api.rs storage layers for work already belonging to the conversation store and item models. I consolidated those operations into the existing layers. HTTP routes still go through app state and the execution mode handler to reach storage; they do not access the database directly.

The shared record_cassette.py generated the cassettes, and Rust integration assertions and storage regressions check the recorded behavior.

avinashsingh77 and others added 4 commits September 25, 2026 13:54
  - Add StorageError::Validation for client-side validation failures
  - Validate no duplicate IDs in serialize_new_items using HashSet
  - Reject explicit empty ID strings ("" vs missing field)
  - Return 400 BAD_REQUEST instead of 500 database constraint errors
  - Add unit and integration tests for both validation cases

Signed-off-by: Avinash Singh <[email protected]>
@maralbahari

Copy link
Copy Markdown
Collaborator

The fresh OpenAI and gateway recordings now match across all 19 edge-case steps. The recordings clarified several behaviors:

  • Cross-conversation reuse: an existing generated item ID can be added to another conversation. OpenAI preserves its original content and ignores replacement content submitted with that ID.
  • Duplicates within one request: submitting that existing ID twice to a fresh conversation succeeds with 200. Listing afterward returns two occurrences with the same public ID.
  • Already-present items: adding an ID already present before the request fails with 400, code: item_already_in_conversation, param: items, and message Item already in conversation.
  • Storage implications: uniqueness on (conversation_id, public_item_id) would reject an accepted OpenAI case. Gateway now separates each history occurrence’s internal database identity from the reused public item ID, fixing the previous database constraint failures.
  • Deleted pagination cursor: both providers now return 404, type: invalid_request_error, param: after, null code, and No item found with id '<id>'.
  • Invalid-prefix probes: the recorded message and function-call cases return 400 invalid_value, with matching parameters and messages.

The tests now compare every edge-case status and complete response body, normalizing dynamic IDs and timestamps. They also replay the OpenAI sequence against gateway storage and retain history, branching, pagination, and streaming checks.

These recordings establish parity for the captured cases; duplicate invented IDs and pagination/deletion among repeated occurrences remain unrecorded.

@maralbahari
maralbahari merged commit 0d5d9e4 into vllm-project:main Sep 25, 2026
19 checks passed
haoshan98 added a commit that referenced this pull request Sep 30, 2026
## Summary

Several user-facing docs had fallen behind `main` or contradicted each
other and the code. This PR brings them in line with what has shipped.
It changes documentation only.


**Corrected claims**
- README listed the Messages API as "🚧 Planned" while another README
section documents `/v1/messages`. It is now listed as shipped; only
stateful Messages stays planned.
- README and `docs/index.md` advertised "Background execution" and
gateway-executed file search. Neither exists yet: background mode is
#357, and `file_search` declarations parse but are dropped before
inference (`tool/normalize.rs`). Both claims are removed.
- `docs/api/index.md` quoted fixed WebSocket and executor limits (256
KiB SSE lines, 1 MiB events and response budget). These now come from
the configurable `[responses]` settings, which default to 16 MiB and 8
MiB.
- `docs/api/index.md` listed only some of the conditions that route a
Responses request through the executor. The list now also includes
non-function tools, `multi_agent.enabled`, and tool-search state,
matching `handler/http/responses.rs`.
- CHANGELOG listed Tavily under 0.8.0, but it merged on Sep 28, after
the Sep 19 release. The two Tavily entries move to `[Unreleased]`.

**Newly documented features**
- README: a multi-agent Responses section with an example and the
gateway's limits (`store: true`, HTTP/SSE only, default of 3 concurrent
subagents, no `max_tool_calls` or reasoning summaries). Also new rows in
the API table for `/v1/responses/compact`, the full Conversations
routes, `/v1/messages` with `/v1/messages/count_tokens`, and
Swagger/OpenAPI (`ENABLE_OPENAPI_DOCS`). The features list, diagram, and
tool ownership table now include MCP, the code interpreter, Claude Code,
compaction, and OpenTelemetry.
- `docs/api/index.md`: new sections for `GET
/v1/responses/{response_id}`, multi-agent, Conversations, and Messages.
- CHANGELOG `[Unreleased]` was empty. It now has entries for #345, #347,
#349, #351/#370, #354, #368, #369, #372/#373, #380, and #387.

**Roadmap**
- ROADMAP.md marks multi-agent HTTP execution as shipped, with WebSocket
injection (#300) and stateless requests (#393) still open. It adds a
status note for Messages, a code interpreter entry, and a file search
item linking #34 and #356.
- README "Roadmap at a Glance" checks off Messages and Conversations and
adds unchecked items for multi-agent, file search, and stateful
Messages.

**Smaller fixes**
- The repository layout in README and AGENTS.md now lists
`agentic-llm-d`, `agentic-cli-docs`, and `python/agentic_api/`.
- ARCHITECTURE.md's list of multi-agent rejections now includes
`max_tool_calls`, matching `executor/rehydrate.rs`.
- `mkdocs.yaml` adds the existing but unlinked `design/shell-tool.md` to
the nav.

**Not changed:** the README's "Rust 1.85+" badge is wrong (1.85 cannot
build the lockfile, see #377), but #379 already updates it to 1.88 along
with `rust-version` and a CI check, so this PR leaves it alone to avoid
a conflict.

Signed-off-by: haoshan98 <[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.

Conversations API: match OpenAI for unknown conversation ids (currently created implicitly)

2 participants