fix: cross-version session compatibility and real message times in snapshot history - #1704
Conversation
- kap-server: accept opts.version in startServer, reported as server_version (/meta, OpenAPI, session exports, lock registry, default User-Agent); defaults to its own package version - kimi-code: pass the CLI product version when starting the server - add boot test covering /api/v1/meta, lock file, and User-Agent
- add wireRecord.seal() to write the metadata envelope at agent creation, so fresh logs satisfy v1 replay's first-record-must-be-metadata invariant - seal the wire log before any op dispatch in AgentLifecycleService.create; no-op when the log already has records (resume / forked copies) - seed empty agents/custom maps in session metadata so v1 Session.resume() can index agents['main'] on a v2-created state.json - add seal unit tests and lifecycle sealing tests
- read per-record times stamped on wire.jsonl via reduceContextTranscript and cache them alongside the transcript messages - prefer each record's real dispatch time for created_at; records without a stamp fall back to session.createdAt + index, clamped so the page stays strictly increasing (mirrors MessageLegacyService.list) - add tests for fallback, clamping, and the page-offset index mapping
…ession metadata - load() now heals pre-fix v2 state.json documents that never gained the agents/custom maps, persisting the backfill so one open on a new build leaves the session resumable by released v1 builds (Session.resume() indexes agents['main'] unconditionally) - updatedAt is deliberately untouched so the format heal does not reorder session listings
🦋 Changeset detectedLatest commit: 5541e8f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ded76570ac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| /** | ||
| * Ensure the on-disk wire log starts with the `metadata` envelope: append it | ||
| * when the log is still empty (fresh agent), no-op otherwise. Called at | ||
| * agent creation so the log always satisfies v1's replay invariant — v1's |
There was a problem hiding this comment.
Move seal documentation into the file header
packages/agent-core-v2/AGENTS.md says comments in this tree must live only in the top-of-file /** */ header and never beside functions or methods. This new method-level JSDoc violates that convention; move the v1-compatibility rationale into the file header or remove the inline documentation.
Useful? React with 👍 / 👎.
- add [subagent] config section with timeout_ms and KIMI_SUBAGENT_TIMEOUT_MS env override - resolve Agent and AgentSwarm per-run timeouts through resolveSubagentTimeoutMs - update tool descriptions and tests to reflect the 2-hour default
- add printBackgroundMode/printMaxTurns to the task config section with resolvePrintBackgroundMode (keepAliveOnExit fallback) - apply exit/drain/steer policy to kimi -p on the experimental engine, buffering turn.ended events and failing the run when a steered turn fails - register the subagent config section from the package entry
…e headers only - replace == null with === undefined in the session-metadata heal to satisfy eqeqeq (oxlint --type-aware in CI) - move the seal() rationale into the wireRecord contract header and the agents/custom invariant into the sessionMetadata header per the tree's header-only comment convention
Related Issue
No linked issue — the problems are explained below.
Problem
Three user-visible fixes, all around running mixed CLI builds against the same
KIMI_CODE_HOMEplus one web UI display fix:kimi serverreported the internal server package version (0.0.1) asserver_version, so the web UI settings dialog showed a meaningless version.Session.resume()indexesagents['main']unconditionally while pre-fix v2state.jsonomitted theagents/custommaps entirely.created_atfromsession.createdAt + indexeven though the real per-record times are persisted inwire.jsonl.What changed
1. Report the CLI version as
server_version/metaresponse instead of the private server package's own0.0.1; boot tests cover the User-Agent and version reporting.2. Make v2-created sessions resumable by v1 builds
wireRecord.seal()writes the metadata envelope at agent creation, called before any op dispatch inAgentLifecycleService.create; it is a no-op when the log already has records (resume / forked copies), andwireRecord.restore()still heals legacy envelope-less logs.agents/custommaps v1 reads unconditionally.SessionMetadata.load()heals existing pre-fix documents: missing maps are backfilled and persisted on first open, deliberately without touchingupdatedAtso session listings keep their order.3. Show real message send times in snapshot history
SnapshotReaderkeeps the per-recordtimesreturned byreduceContextTranscript(previously discarded) and passes them as thecreated_atoverride, falling back tosession.createdAt + indexfor records predating the time stamp and clamping so the page stays strictly increasing (mirroringMessageLegacyService.list).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.