Skip to content

feat(examples/pi): adapt OpenViking extension to pi 0.81 (agent_settled commits + entry rendering) - #2996

Closed
ZaynJarvis wants to merge 1 commit into
mainfrom
worktree-pibot
Closed

feat(examples/pi): adapt OpenViking extension to pi 0.81 (agent_settled commits + entry rendering)#2996
ZaynJarvis wants to merge 1 commit into
mainfrom
worktree-pibot

Conversation

@ZaynJarvis

@ZaynJarvis ZaynJarvis commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

What

main already carries the full OV context-takeover extension (#3081, #3079, #3099, #3233). This PR does not re-do takeover — it adapts it to pi 0.81's new extension primitives, without regressing any existing behavior. Rebuilt on current main; single commit.

  • Threshold commits no longer stall the agent run. The takeover commit (flush + commit + overview poll, worst case pollMax×pollMs ≈ 30s) previously ran inline in turn_end, blocking the in-flight run. turn_end now only accumulates token pressure (noteSynced); the commit runs from agent_settled (pi ≥ 0.81, run fully settled), with a fire-and-forget before_agent_start fallback for older pi. onTurnSynced split into noteSynced() + commitIfDue().
  • ov-takeover state rendered in the TUI via registerEntryRenderer (pi ≥ 0.81): a dim one-line archive-boundary status, expandable to preview the overview; never enters LLM context. Optional, zero logic risk.
  • README comparison table aligned with code (startup memory index was dropped for latency in favor of on-demand recall).

Dropped after necessity review

  • mirrorMemoryWrites — mirroring .memory/MEMORY.md duplicates OV's own turn-based memory extraction (and re-mirrors unchanged content every shutdown). Removed.
  • commitOnShutdown — near-dead switch (only affects non-takeover mode; takeover is on by default). Removed.

Test

  • cd examples/pi-coding-agent-extension && node --test tests/*.test.mjs — 44 pass.
  • End-to-end on pi 0.81.1 against a local OpenViking server: agent_settled advances the boundary 121ms after the run; pi -c restores boundary/watermark; cross-boundary facts recalled from the overview.

Note (out of scope)

DESIGN.md (pre-existing on main) still documents mirrorMemoryWrites/commitOnShutdown as implemented — a doc/code mismatch predating this PR, left for a separate cleanup.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MRy5Epi4rQ7vCzSk3BLQcA

@ZaynJarvis

Copy link
Copy Markdown
Collaborator Author

closed for future PI feat migration.

@ZaynJarvis ZaynJarvis changed the title feat(examples): add OpenViking integration for Pi coding agent feat(examples/pi): pi 0.81 adaptation + remaining pibot ports for OpenViking extension Jul 21, 2026
@ZaynJarvis
ZaynJarvis requested a review from t0saki July 22, 2026 06:28
…ntry rendering

main already carries the full OV context-takeover extension; this adapts it to
pi 0.81's new extension primitives without regressing any existing behavior.

- Threshold takeover commits (flush + commit + overview poll, worst case
  pollMax x pollMs) previously ran inline in turn_end, stalling the in-flight
  agent run. turn_end now only accumulates token pressure (noteSynced); the
  commit runs from agent_settled (pi >= 0.81, run fully settled), with a
  fire-and-forget before_agent_start fallback for older pi. onTurnSynced is
  split into noteSynced() + commitIfDue().
- Render the persisted ov-takeover state entries in the TUI via
  registerEntryRenderer (pi >= 0.81): a dim one-line archive-boundary status,
  expandable to preview the overview, never entering LLM context.
- Align the README comparison table with the code: the startup memory index
  was dropped for latency in favor of on-demand recall.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MRy5Epi4rQ7vCzSk3BLQcA
@ZaynJarvis ZaynJarvis changed the title feat(examples/pi): pi 0.81 adaptation + remaining pibot ports for OpenViking extension feat(examples/pi): adapt OpenViking extension to pi 0.81 (agent_settled commits + entry rendering) Jul 22, 2026

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for one correctness race in the legacy fallback path. The focused suite passes (44/44), but a deterministic in-memory reproduction shows the boundary can advance past the data that was committed when a new prompt arrives during the overview await.


// Fallback commit point for pi < 0.81 where agent_settled never fires.
// Fire-and-forget: never delay the prompt; commitAndAdvance self-serializes.
if (config.takeoverEnabled) void takeover.commitIfDue();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Avoid advancing the boundary from mutable in-flight context state

This fire-and-forget call can overlap the following context hook. commitAndAdvance() awaits flush/commit/overview and only then reads mutable lastSeenUserTurns; meanwhile context can include the just-submitted user message, which has not yet been synced to OpenViking. The boundary can therefore advance past committed data and a later context transform may drop that unsynced turn. I reproduced this by starting a commit with 3 user turns and keepRecent=1, adding a fourth turn during the overview await, and observing coveredUserTurns=3 instead of the safe value 2. Please gate this fallback to runtimes without agent_settled and snapshot/derive the covered-turn count from committed state at commit start, with a regression test for the overlap.

@ZaynJarvis ZaynJarvis closed this Aug 4, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants