Conversation
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.
Problem
Post-edit currently serializes its own commands but does not coordinate them with the following Agent run. A foreground formatter started by
agent_settledcan still be writing while the next parent turn reads or edits the same file.The native lifecycle matters here: Pi marks the run idle before settlement handlers finish, and a custom message with
triggerTurn: trueenters the parent through a different path from ordinary prompt preflight. Merely awaitingagent_settledor fencingbefore_agent_startis not sufficient.Value
Keep the existing opt-in, thin post-edit extension useful for foreground formatters without adding an editing-tool replacement, automatic repair loop, or second orchestration layer. Users can cancel a waiting Agent without losing track of the still-running command.
Approach
pi.execactually completes. Requesting abort does not release it early.agent_start, covering ordinary prompts and custom-message parent wakeups with the current Agent cancellation signal installed.tool_callbackstop for native Write/Edit/Bash. A canceled or session-invalidated call is blocked rather than admitted after the wait.killed: trueas interruption even if Pi reports exit code zero. Keep notices bounded, sanitized, and suppressed for stale sessions.The command must be finite and foreground-owned. This is not an acceptance gate or a workspace-wide lock: other sessions, concurrent subagents, user shell commands, external editors, and detached descendants remain outside its guarantee. Native Pi cancellation does not promise process-tree termination. A hung command can keep the next turn waiting; cancellation releases the Agent's wait, not the command's ownership. No timeout silently declares completion.
Validation
Environment: Windows, Node 22.22.0, Bun 1.3.14, locked Pi 0.85.1. Git's shell directory was on the test process PATH. Development configuration was isolated from daily Pi settings;
pi listresolved one local OpenPI checkout.The integration tests use real Pi sessions, native tools, real
pi.exec, and a real foreground formatter. A localhost TCP release controls completion deterministically; file contents and model/tool entry points establish ordering. The provider is synthetic and local-only, so no credentials or remote model calls are required. Dedicated tool-backstop tests omit only the start-hook registration to isolate that backstop; ordinary prompt, custom-message, and cancellation tests retain it.Full-suite limitations, not hidden as green:
bun run teston this host first hit five unrelated timing failures; those files passed in a serial rerun. A broader diagnostic using repository discovery with bounded file concurrency passed the parallel Node group (1,563 passed, 10 skipped) and all Vitest tests (220 passed). The Windows serial group had 87 passed, 7 failed, 4 skipped, with failures in unchanged background-terminal process-tree teardown tests. A representative kill-status failure reproduced independently; that test's dependency chain does not import post-edit. No background-terminal fixes or test suppressions are included here. Final post-edit checks above were rerun after the lifecycle fixes.No live-provider or manual visual TUI test is claimed. The native integration runs use TUI-mode extension contexts programmatically.
Impact
/openpi-setupentry point and command limit are unchanged.