Repository navigation
fix(remote-workspace): observe Pi prompt failures before acknowledgement #7669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lidge-jun
merged 10 commits into
lidge-jun:dev
from
luvs01:fix/pi-prompt-rejection-lifetime
Oct 25, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9e5a917
fix(test): promote Bun 1.4.4 with independent runner role verification
luvs01 1deb67d
docs: align Docker Bun comments with unified role defaults
luvs01 41f08ff
test: use a draining TLS origin for early upload replies
luvs01 a9c3d12
test: confine draining origin to buffered HTTP/1 upload
luvs01 1d56a1d
fix(remote-workspace): observe Pi prompt failures before acknowledgement
luvs01 f011a94
merge: align test-runner role branch with dev 2.93.0 dependency baseline
luvs01 13acca5
Merge commit '1d56a1df7fee7a793466b7dd0d9cb17607ba75ed' into codex/fo…
luvs01 26d7d61
Merge branch 'dev' into fix/pi-prompt-rejection-lifetime
lidge-jun 7ee21b1
Merge commit 'f011a94be1b468b7b785cb54976d4cb4a9b6a563' into codex/pr…
luvs01 3083613
Merge origin/dev (#7627 landed as 0929e6efc6) into fix/pi-prompt-reje…
lidge-jun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // A real RPC child and an isolated parent let tests observe unhandled rejections | ||
| // without changing the test runner's process-wide rejection policy. | ||
| export {}; | ||
|
|
||
| const mode = process.argv[3]!; | ||
| if (process.argv[2] === "child") { | ||
| const send = (value: object) => process.stdout.write(`${JSON.stringify(value)}\n`); | ||
| let input = ""; | ||
| const decoder = new TextDecoder(); | ||
| for await (const chunk of Bun.stdin.stream()) { | ||
| input += decoder.decode(chunk, { stream: true }); | ||
| let end: number; | ||
| while ((end = input.indexOf("\n")) >= 0) { | ||
| const message = JSON.parse(input.slice(0, end)); | ||
| input = input.slice(end + 1); | ||
| if (message.type !== "prompt") { | ||
| send({ type: "response", id: message.id, success: true }); | ||
| continue; | ||
| } | ||
| if (mode === "exit-before-ack") process.exit(7); | ||
| if (mode === "malformed-before-ack") { | ||
| process.stdout.write("{invalid JSON}\n"); | ||
| continue; | ||
| } | ||
| if (mode === "extension-before-ack") { | ||
| send({ type: "extension_error", error: "synthetic extension failure" }); | ||
| await Bun.sleep(25); | ||
| } | ||
| if (mode === "settle-before-ack") send({ type: "agent_settled" }); | ||
| send({ type: "response", id: message.id, success: mode !== "rejected", error: "synthetic rejection" }); | ||
| if (mode === "success") send({ type: "agent_settled" }); | ||
| if (mode === "extension-after-ack") send({ type: "extension_error", error: "synthetic extension failure" }); | ||
| } | ||
| } | ||
| } else { | ||
| const { PiRemoteWorkspaceRuntimeFactory } = await import(process.argv[2]!); | ||
| const unhandled: string[] = []; | ||
| const errorText = (error: unknown) => error instanceof Error ? error.message : String(error); | ||
| process.on("unhandledRejection", error => { unhandled.push(errorText(error)); }); | ||
| const factory = new PiRemoteWorkspaceRuntimeFactory({ command: [process.execPath, import.meta.path, "child", mode] }); | ||
| const handle = await factory.start({ | ||
| sessionId: "fixture", deviceId: "fixture-device", deviceName: "Fixture", rootId: "fixture-root", rootLabel: "Fixture", | ||
| capabilities: ["workspace.read"], tools: ["read_file"], emit: () => {}, | ||
| coordinator: { async invokeTool() { throw new Error("No remote tool should run"); } }, | ||
| }); | ||
| let error: string | null = null; | ||
| try { | ||
| try { await handle.prompt("synthetic prompt"); } catch (caught) { error = errorText(caught); } | ||
| } finally { | ||
| await handle.stop(); | ||
| } | ||
| await new Promise<void>(resolve => setImmediate(resolve)); | ||
| console.log(JSON.stringify({ error, unhandled })); | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔎 Supported by static analysis
Script executed:
Repository: lidge-jun/opencodex
Length of output: 41772
Script executed:
Repository: lidge-jun/opencodex
Length of output: 33653
Script executed:
Repository: lidge-jun/opencodex
Length of output: 15545
Web query:
official Pi coding agent RPC protocol agent_settled extension_error event orderingResult:
Invalidate a failed Pi handle before admitting another prompt.
extension_errorclears the active settlement while the prompt command can remain pending. The session keeps the same handle and allows another prompt after the failure. Becauseagent_settledhas no turn identifier, a later settlement from the failed run can resolve the next prompt. Its RPC response can then makePromise.allcomplete before the next run settles.Stop and discard the failed RPC child before allowing another prompt, or correlate settlement events with their turns. Add a regression that sends a second prompt before the first response and gives both prompts distinct settlement events.