Repository navigation
feat(botiverse): rebuild a past request from the wire, and record a messages hash - #9
Merged
stamp-build[bot] merged 1 commit intoNov 6, 2026
Conversation
stamp-build
Bot
force-pushed
the
otter/2.3.1-context-rebuild
branch
from
November 6, 2026 01:02
ba9327e to
7c3b0db
Compare
…essages hash llm.request records the system prompt and tool hashes and a message count, but nothing that proves what messages a request sent. The Raft daemon's View Context needs to show the input behind a message an agent sent, and reimplementing the projection there would drift from the code that built the real request. - rebuildLastLlmRequest (exported from the node SDK) replays wire records along the same restorable chain a resume uses, with the contextMemory and profile folds, runs the same projection, and returns the last loop request's system prompt, tools, messages and response. Pass the records only up to the point of interest. Every check that fails is a refusal with a reason, never a best guess. - llm.request gains an optional messagesHash over the messages actually sent, so new sessions verify exactly (verification: verified), and an image the media budget replaced with text refuses. Older sessions rebuild as count_matched. The hash ignores media payloads, which the wire stores dehydrated, and key order. A hash that cannot be computed is left out rather than failing the request. - A request retried with media removed is refused: its strip snapshot and display paths are not recorded. - With tool select on, the live request also drops schemas of tools no longer active, which the wire cannot tell. The rebuild keeps them; the hash and count checks still apply. - Test snapshots mask messagesHash: it covers tool output, whose wall time differs per run. Signed-off-by: Otter <raft+otter@agents.stamp.build>
stamp-build
Bot
force-pushed
the
otter/2.3.1-context-rebuild
branch
from
November 6, 2026 01:21
7c3b0db to
8bbb355
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on
patch-2.3.1-botiverse, the source of2.3.1-botiverse.0that Raft ships today. Target release:2.3.1-botiverse.1.Why: Raft's View Context shows the input behind a message an agent sent.
llm.requestrecords the system prompt and tool hashes and a message count, but nothing that proves which messages were sent. Reimplementing the projection in the daemon would drift from the code that built the real request.What:
rebuildLastLlmRequest(records), exported from the node SDK, replays one agent's wire records the way a resume does:contextMemoryalong the restorable chain, so undo behaves as it does live, andprofileover the whole journal. It runs the same projection and returns the last loop request's system prompt, tools, messages and response. Callers pass the records only up to the point of interest.llm.requestgains an optionalmessagesHashover the messages actually sent. New sessions reportverified; sessions written earlier reportcount_matched. The hash ignores media payloads (the wire stores them dehydrated) and key order. If the hash can't be computed it's left out, so it can't fail a real request.message_count_mismatch,messages_hash_mismatch,system_prompt_mismatch,tools_unavailable,tools_mismatch,media_projection,newer_wire_version,replay_failed,no_request.Known limits:
count_matched), a budget-replaced image still shows as the image, and with tool select on (off by default) schemas of tools no longer active still show. The count can't detect either. That's why this result must never be labelled verified.protocol_version, which the result returns.responsecan mix both attempts. The hash doesn't cover the response.CI:
test (2)is red and isn't from this change. Nine survey tests inapps/kimi-code/test/tui/kimi-tui-message-flow.test.tsfail the same way on the base commit when the whole file runs.Tests: round-trip tests run real turns in the harness (tool calls, undo with an unowned injection, compaction, clear, inline and blob-reference images, an over-budget image) and rebuild from JSON-round-tripped wire records. Each check has a refusal test. I mutated the helper's branches and the tests catch all but one: the rewrite-record stop in the response fold, which the length stop already covers in every case I could build.
agent-core-v2: 7,357 passed, 2 skipped.node-sdk: 183 passed. Typecheck passes. An earlier build of this change was repackaged and its export run on a dumped session; the release dry run will repeat that. No real Kimi session file has been tried yet.Existing inline snapshots changed only by the new field, which the harness masks because it covers tool output, whose wall time differs per run.
docs/wire-manifest.d.tsis regenerated.