Skip to content

RavenDB-24609 Add GetConversationMessages operation for AI agent conversations#302

Open
redknightlois wants to merge 1 commit into
ravendb:v7.2from
redknightlois:RavenDB-24609-get-conversation-messages
Open

RavenDB-24609 Add GetConversationMessages operation for AI agent conversations#302
redknightlois wants to merge 1 commit into
ravendb:v7.2from
redknightlois:RavenDB-24609-get-conversation-messages

Conversation

@redknightlois

@redknightlois redknightlois commented Jul 1, 2026

Copy link
Copy Markdown
Member

Issue

https://issues.hibernatingrhinos.com/issue/RavenDB-24609

Source (C# client): ravendb/ravendb#22619

What changed

Brings the GetConversationMessages read operation to the Python client, mirroring the C# client
(ravendb/ravendb#22619). It fetches an AI agent
conversation's message history from
GET /databases/{db}/ai/agent/conversation/messages, with:

  • Timestamp pagingbefore and after cursors (mutually exclusive), serialized in Raven's
    default UTC format (yyyy-MM-ddTHH:mm:ss.fffffffZ), UTC-coerced before formatting so a naive or
    non-UTC datetime yields a correct cursor.
  • Page size — max messages to return (default: unbounded).
  • Detail levelSimple (default), Detailed, Full; passed to the server for filtering.

New module ravendb/documents/operations/ai/agents/get_conversation_messages_operation.py:

  • GetConversationMessagesOperation / GetConversationMessagesCommand — a MaintenanceOperation
    with an inner read RavenCommand.
  • GetConversationMessagesOptions — parameter object with eager client-side validation (rejects an
    empty/whitespace conversation_id, before and after together, and page_size <= 0).
  • DTOs AiConversationMessagesResult, AiConversationMessage, AiToolCallResult — snake_case Python
    attributes with from_json/to_json mapping to/from the server's PascalCase keys.
  • Enums AiMessageRole (System, User, Assistant, Summary, Internal) and
    AiConversationDetailLevel (Simple, Detailed, Full).
  • AiUsage is reused from run_conversation_operation — not duplicated.

A convenience AiOperations.get_conversation_messages() accepts either a conversation-id string or a
GetConversationMessagesOptions.

Response-timestamp parsing normalizes the fractional-seconds precision so it is compatible with the
package's declared Python floor (~=3.9): datetime.fromisoformat before 3.11 accepts only 3 or 6
fractional digits and rejects a Z suffix, whereas Raven emits 7-digit (100 ns tick) ...Z
timestamps — both are normalized before parsing.

Tests: 43 unit tests (no mocks, no live server), covering URL/query construction, validation,
PascalCase↔snake_case round-trips through the real parser with representative server JSON (nested
tool calls, usage, sub-conversation ids), null-response handling, and datetime formatting/parsing.

Files (5): the new operation module and its test file; re-exports in
ravendb/documents/operations/ai/agents/__init__.py and ravendb/__init__.py; the convenience
method in ravendb/documents/ai/ai_operations.py.

Checklist

  • Tests added or existing tests cover the change
  • Breaking change (explain above if checked)

Known risks / not verified here

  • Python 3.9 floor: the datetime-precision fix is verified by construction (the normalized
    string falls within the fractional-digit/offset grammar that pre-3.11 fromisoformat accepts) and
    by the suite passing on 3.13/3.14, but was not executed under a <3.11 interpreter — none is
    installed here. Worth a CI run on 3.9 to confirm.

Implemented by hugin-bot, created on behalf of @redknightlois.

Python port of the RavenDB C# client's GetConversationMessages feature
(ravendb/ravendb#22619). Adds AiOperations.get_conversation_messages() with
timestamp-based paging (before/after cursors) and detail-level filtering
(Simple/Detailed/Full), presenting a unified message timeline across
conversation history documents.

New models: AiConversationMessage, AiToolCallResult,
AiConversationMessagesResult, GetConversationMessagesOptions,
AiConversationDetailLevel, AiMessageRole; split per-concern mirroring the
C# source layout.

See: https://issues.hibernatingrhinos.com/issue/RavenDB-24609
@redknightlois redknightlois force-pushed the RavenDB-24609-get-conversation-messages branch from 7b2800a to 5444d91 Compare July 1, 2026 22:21
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.

1 participant