44 lines
2.8 KiB
Markdown
44 lines
2.8 KiB
Markdown
# Large chat history
|
|
|
|
The chat broker reads OpenCode V2 history in cursor pages and represents an
|
|
oversized tool result as an explicitly labelled omission rather than failing the
|
|
transcript. The native bare-array HTTP history path uses the same projector;
|
|
its existing OutputFormat read-only export fallback is unchanged and retains its
|
|
separate evidence limit. A retained hub tail is never authoritative history.
|
|
|
|
History-specific HTTP reads retain shared auth, directory scoping, validation and
|
|
request cancellation. They do not use the generic Call 1 MiB safeguard (which is
|
|
unchanged). A fixed 32 KiB reader validates JSON incrementally, including discarded
|
|
strings/escapes. Each complete tool state (input, output, metadata, file data and
|
|
many small fields together) has a 64 KiB encoded budget. Oversized states become
|
|
valid omission cards, not raw JSON prefixes. Projection happens before ordinary
|
|
JSON decoding, one message at a time, never by buffering the raw page or string.
|
|
Memory is O(returned conversation + largest projected message), with fixed reader,
|
|
64 KiB state and depth-bounded scanner workspace (128 levels). User/final-answer
|
|
text is not capped. This is not a lazy full-detail API: omitted tool details are
|
|
not currently retrievable in the chat UI.
|
|
|
|
Android's retained cursor/load-older controls merge pages by message id. A
|
|
request-start snapshot distinguishes stale cached messages (replace on reconnect)
|
|
from live updates received during the read (preserve). Cached older pages survive
|
|
newest-page refreshes.
|
|
|
|
2026-10-18 verification is fixture evidence, not a live model or production
|
|
deployment claim. `go test ./internal/opencode -run 'History|ChatMessages' -v`
|
|
measured approximately 175 KiB allocated for both generated 2 MiB and 32 MiB
|
|
single-tool strings, with maximum source reads of 32 KiB. Tests cover malformed
|
|
discarded detail, UTF-16 escapes, cancellation during huge strings and HTTP reads,
|
|
auth refusal, legacy arrays, uncapped answer text, and the generic Call safeguard.
|
|
`TestChatHistoryLargeFixtureWebsocketTraversalAndReconnect` exercises a scratch
|
|
HTTP fixture through the real broker and /connect websocket, including a >1 MiB
|
|
page of many tools, one >1 MiB output, opaque cursors, equal-timestamp ordering,
|
|
full traversal and reconnect between pages. No production history was seeded.
|
|
|
|
`internal/author/skill/references/` has no history-pagination guidance; any chat
|
|
reference added there should document that older history remains reachable through
|
|
the opaque continuation and that a truncated tool preview is not full output.
|
|
`docs/cli.md` is stale for `chat_query.cursor`, `chat_history` (messages,
|
|
next_cursor, has_more), and tool-state `truncated`; fold those wire fields there
|
|
with the compatibility `chat_messages` list through the docs-fold writer only.
|
|
No deployment, installation, device interaction or production mutation was done.
|