OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Feature] messages/batch hard-caps at 100 messages: server-side auto-chunking or configurable limit for large session import/recovery

Open wyl1988 opened this issue 1 month ago • 3 comments

Environment

  • OpenViking 0.4.23, self-hosted, Linux, api_key mode

Current behavior

POST /api/v1/sessions/{sid}/messages/batch rejects any payload with more than 100 messages:

400 Invalid request parameters:
body.messages: List should have at most 100 items after validation, not 120

Why this matters

For workflows that need to re-inject an archived session back into OpenViking (memory re-extraction after a VLM outage, migration, pack/restore of selective data, or importing conversations from an external system), large sessions are common. With the hard cap, every client is forced to implement its own chunking: split into <=100-message slices, create one temp session per slice, messages/batch + commit each slice separately, then merge.

We maintain exactly such a client-side pipeline (recovery of ~1,700 sessions after a VLM provider incident) and had to write and debug this logic ourselves — including failure modes the server could shield clients from:

  • slice boundaries cutting related turns apart (extraction quality depends on context continuity)
  • per-slice temp sessions polluting the session namespace unless carefully named and cleaned
  • partial failures mid-sequence leaving half-injected sessions

Related work

#5894 / #5905 add size-aware auto-chunking on the extraction side (resolve_extraction_batch_limits, ExtractLoop batching). That's great, but it's orthogonal: it chunks what happens after commit, while the injection endpoint still caps what clients may send before commit. Both sides need a story for large sessions.

Proposal (any one of)

  1. Server-side auto-chunking (preferred): accept larger batches and internally split into <=N-message appends, transparent to the caller. The server already knows its own limit and message boundaries.
  2. Configurable limit: e.g. server.max_batch_messages in ov.conf, so operators with local deployments can raise it.
  3. Minimum: include the actual limit and a one-line chunking hint in the 400 error message.

Workaround we use today (for reference)

CHUNK = 100
slices = [msgs[i:i+CHUNK] for i in range(0, len(msgs), CHUNK)]
for pi, chunk in enumerate(slices):
    temp_sid = f"reextract_{orig_sid}_p{pi+1:02d}_{ts}"
    create_session(temp_sid); add_messages(temp_sid, chunk); commit(temp_sid)

Happy to contribute a PR for option 1 or 2 if maintainers think it's in scope.

wyl1988 avatar Oct 21 '26 00:10 wyl1988

I opened #6401: https://github.com/volcengine/OpenViking/pull/6401

It adds server.max_batch_messages (default 100), removes the hard-coded request-model cap, and validates the configured limit before any append. A batch over the limit now returns a 400 that names the limit and explains how to split or raise it. The default is unchanged, so existing deployments keep their current behavior.

CodingYangDev avatar Oct 21 '26 05:10 CodingYangDev

Updated the PR: the default safety cap is now 10,000 instead of 100, so the reported 120-message case and multi-hundred-message imports work without client-side chunking. The batch is still appended atomically; server.max_batch_messages remains configurable for deployments that need a stricter bound. The issue's preferred "no client chunking" outcome is covered without introducing partial-write windows.

CodingYangDev avatar Oct 21 '26 05:10 CodingYangDev

Thanks for reporting this and describing the recovery workflow.

The 100-message limit applies to each messages/batch request, not to the total number of messages in a session. Importing a larger conversation does not require separate temporary sessions or a commit for each batch: appending 100 messages and then 20 more to the same session preserves all 120 in order.

For this workflow:

  1. Create the import session, then disable automatic commits with PATCH /api/v1/sessions/{sid}/config and {"auto_commit_policy": null} before adding messages.
  2. Sequentially send batches of at most 100 messages to POST /api/v1/sessions/{sid}/messages/batch, using the same sid throughout.
  3. Once every batch has succeeded, call POST /api/v1/sessions/{sid}/commit once.

This keeps the conversation together for commit without introducing per-batch sessions. Given that the existing API supports this import flow, we do not plan to add server-side chunking or a configurable batch limit for this request. Closing as not planned.

qin-ctx avatar Oct 21 '26 07:10 qin-ctx