feat(pi-ext-run-log): @agentic-kit/pi-ext-run-log — mirror pi session entries into the run log - #1724
Merged
Conversation
…ith pi entries stored verbatim
A pi extension that drains pi's append-only session into an @agentic-kit/run-log store — verbatim, in order, same code locally and in the cloud (only runId and the store differ). Draining is index-based because the session is append-only; the read position is keyed to the session header id so a switch/fork re-mirrors and the store's idempotency absorbs the duplicates. A drain advances only after a successful append, and store failures are rethrown into pi's dispatch by default rather than silently dropping entries.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This was referenced Aug 14, 2026
Merged
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.
Summary
Package 2 of the agentic-kit series (issue #1657): the write side of the run log for a pi session.
@agentic-kit/run-log(#1723) defines the record + store contract; this package is the pi extension that fills it. Same code in both placements — local Desktop session and a long-running cloud job — onlyrunIdand the store differ, which is what makes a run observable from anywhere without a second transcript format.Stacked on
feat/agentic-run-log, so until #1723 merges this diff also showsagentic/run-log.Why draining, not an event
pi owns its session (an append-only entry tree, persisted as JSONL) and exposes no "entry appended" event. So
SessionMirrordrains: after each event that could have appended, it takes the entries past its read index and appends them verbatim.Index-based reading is sound precisely because the session is append-only — entries are never rewritten or removed, only branched from.
The load-bearing invariants (each has a test):
consumed/headerMirroredmove only oncestore.appendresolves, so a failed drain is retried whole and leaves no hole.this.tail, so concurrent events cannot interleave batches and break run-log ordering.id, so a switch/fork/new-session re-mirrors from the start and the store's idempotency (pi entry ids) discards the carried-over entries. The same property makes resume free: a restarted host re-appends its history and writes nothing new.expect(record.entry).toEqual(exotic)).Failure policy
A store failure is rethrown into pi's event dispatch by default — a run log that silently stops recording is worse than a loud one, so losing entries is never the default.
onErrorlets a host trade that for survival.SessionMirrordeliberately knows nothing about pi's extension API (it takes{ getHeader, getEntries }), so mirroring is tested against a fake session and the extension test drives the registered handlers with a fakeExtensionAPI— no agent process in the unit tests.Verification
pnpm testin the package: 15 tests, 2 suites green (header-once/ordering, verbatim, unbound no-op, concurrent drains, retry-after-failure, session switch, idempotent resume, malformed entry, version passthrough, event registration, onError, flush)pnpm build(makage, CJS+ESM) andpnpm lintcleanpnpm install --frozen-lockfilepasses with the hand-added importer (no lockfile churn)agenticbatch in.github/workflows/run-tests.yamlLink to Devin session: https://app.devin.ai/sessions/450ce6d6659c47759c184ae6ec19a2a8
Requested by: @pyramation