Repository navigation
Conversation
In the interactive app, a run its parent started now asks through that turn's prompter, as `fx ask` and ACP do: the request is registered, the parent gets one note, and the parent answers with `approve` or `deny`. The request still waits on the subagent's own worker, so its own screen shows it, but no instance's screen borrows it, and neither the footer nor the agent list says the subagent needs the person. A turn the person typed on a subagent's screen keeps the worker's prompter and stays with the person, lent to the instance's screen as before. When the person answers on the subagent's own screen, its registry binding goes, so the parent's later answer reads that nothing waits. The approval prompt now owns a copy of its file review instead of pointing into the tool call's stack frame, so a prompt that outlives its call can no longer read freed memory. Tests that held a main-started subagent's approval on main's screen now type the subagent's turn, so each keeps its assertions; new tests cover the parent's approve and deny, the person answering first, two subagents at once, the quiet footer and list, and an instance's subagent asking that instance's agent.
A stop or close of a subagent now first refuses the approval request it waits on, with a reason it can read: its parent stopped it, its parent closed it, or the person closed it. The call is refused and nothing runs. In fx ask and ACP a stop used to leave the request waiting until the turn ended; in the app it was declined without a reason. The refusal takes only the registry's mutex and releases it before it answers the worker, and it runs before the stop takes admission, so it cannot deadlock with the note path. ACP's session/cancel still leaves the request waiting. A turn the person typed keeps today's decline.
The fake approved writer first whenever any note was in the history. When helper's note reached main first, main approved writer before it waited, fx answered that nothing waited, and writer's later note found both approve calls already made, so writer was never approved. The fake now approves the agent the newest note names, approves again an agent whose approval came too early, and says both were answered only after both approvals were allowed.
tests/tla/subagent/TuiParentApproval.tla checks the designs for Part 2: the step-3b trial breaks NoStaleLent and design a breaks NoStalePrompt, while a2, b and c pass. Design c is the code in this change: the prompt owns a copy of its review, so NoStalePrompt holds by construction, and a request its parent answers is never lent. Three planted defects each break their rule, and two simulation runs cover ideal and non-ideal conditions.
…ubagent-approvals-to-parent
Both branches added the same import to approval_registry.zig, and the merge kept both lines, which does not compile.
The terminal build now carries the approval prompt's own copy of its file review, the routing of a subagent's request to its parent, and the refusal on stop and close. That code adds 6,798 bytes to fx-term.wasm: CI's SDK job measured 4,253,179 bytes on the base and 4,259,977 with this change, over the 4,254,000-byte budget.
The app copied the approval prompt's review from a pointer it read in the worker's snapshot, after the worker's lock was released. The review lives in the tool call's frame, and in this change an answer can come from another thread, the parent's approve or a stop's refusal, so the call could end and free the review before the copy was made. The worker now makes the copy itself under its lock while the request still waits, and the prompt adopts it once per request; the snapshot's pointer is only compared. Also: the main-started form of the agent-list test asserts the team row again, the instance tests wait on the pane instead of polling with a sleep, and a test that ignored closeChild's error now checks it.
"interactive child approval uses the normal parent prompt" and "subagent search recovers when its target disappears during approval" held a main-started subagent's request on main's screen, which now goes to main as a note. Each keeps its assertions with the subagent's turn typed by the person; a typed turn sends no report, so the wait for main's report turn is replaced by the child's own evidence. Each also gets a new test for the note path: main denies, and main's approve is refused once the target is gone.
…ubagent-approvals-to-parent
…ubagent-approvals-to-parent
…ubagent-approvals-to-parent
The restored command and search approval tests, and their note-path versions, sampled a variable every 25 ms to see what the fake recorded. They now await a promise the fake resolves when it records it, bounded by a deadline. Selecting an agent uses the list's search box and waits for its one-row header, instead of stepping the highlight and sampling.
The app copies a waiting request's file review through the worker; when that copy fails, the prompt shows no review for that pass and the next pass tries again. It now leaves a trace line with the request id and the error, so the dropped copy is visible.
The note shows a shell command's permission label cut to one activity line. On macOS the temp workspace path is long, so the cut falls before the marker's name, and the note test failed there. The test now checks that the note's action is the real label, or the label's own head ending in a cut marker, and checks the marker's name only when the label is whole.
fazxes
marked this pull request as ready for review
November 25, 2026 04:41
This branch has not been deployed
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.
Stacked on #2198. Merge after it.
Summary
fx askand ACP after Send a subagent's approval requests to its parent #2198. The run asks through the turn's prompter, so the request is registered, the parent gets one note, and it answers with thesubagenttool'sapproveordeny.approvereads that nothing waits.tool_admission.zig), so a prompt that outlived its call, such as a lent copy, could read freed memory. That is the crash the first attempt at this change hit. The worker makes the copy under its own lock while the request still waits (WorkerRuntime.copyPendingReview), because an answer can now come from another thread and end the call; the app adopts it once per request, and the snapshot's pointer is only compared.fx askand ACP a stop used to leave the request waiting until the turn ended; in the app it was declined with no reason. ACP'ssession/cancelstill leaves the request waiting. A typed turn's request keeps today's decline.Model
tests/tla/subagent/TuiParentApproval.tla, with 13 configs incheck.sh. The step-3b trial (lend a parent-routed request) breaksNoStaleLent, and design a (main's answer off the loop, the call frees its review) breaksNoStalePrompt; a2, b and c pass. Design c is this change:NoStalePromptholds for it because the prompt reads its own copy, taken under the worker's lock while the request waits; theOwnedReviewandcopyPendingReviewunit tests prove the copy is taken only then and outlives the call. Three planted defects each break their rule (NoPersonPromptForParentRouted,NoStalePrompt,TypedStaysWithPerson), and two simulation runs pass.ParentApproval.tla'sStopalready drops the request; its comment now says the stop refuses it first.Tests
OwnedReviewkeeps its rows after the source review is freed, in computed and fallback mode and at the fallback limit; the two approval-prompt tests that asserted the borrow now assert the copy and read it after the source is freed; a stop refuses the child's waiting request once with the reason; a close refuses it with the reason of who closed it; a stop or close with nothing waiting refuses nothing; a refused stop answer ends a child's permission wait with the reason.tui-host-switch.test.ts: the parent approves (the write lands) and denies (nothing written), and main's screen never shows "needs permission"; the person answers on the subagent's screen first and main is told nothing waits; a typed turn's approval is still lent; two subagents wait at once and main answers both; the status and agent-list tests each have a typed form with their old assertions and a main-started form (main reads "waiting for an approval", the footer stays quiet, the list says working); main's stop refuses a subagent's request and its command never runs.tui-host-instances.test.ts: the 17 grant tests (always and one-time answers, kept, sibling, nested, lead, instance scope, main's running turn,/permissions reset,fx mcp call, auto mode) keep every assertion with the subagent's turn typed by the person, since a main-started subagent no longer asks the person; a launched instance's subagent still asks on that instance's screen in a typed turn; new: a launched instance's subagent asks that instance's agent, not the person or main.sessions.test.ts: main's stop refuses a subagent's request infx ask, and nothing runs.tui-command-permissions.test.tsandgateway-stream-lifecycle.test.ts: "interactive child approval uses the normal parent prompt" and "subagent search recovers when its target disappears during approval" keep their assertions with the subagent's turn typed; new tests cover main denying through the note, and main's approve refused once the target is gone.worker_runtime.zig: the worker copies a pending review only while the request waits, and the copy outlives its source.Merges
The branch merges #2198's head four times: for its fix of the ACP reload tests (with a follow-up that removed a duplicate import that merge left), for its fix of a registry-owner lock cycle, for the single-check route pin that replaced that fix's give-back, and for a one-line
std.mem.printfix in a test. The SDK budget forfx-term.wasmrises from 4,254,000 to 4,270,000 bytes: this change adds 6,798 bytes (4,253,179 on the base, 4,259,977 at its first head), assdk/AGENTS.mdallows for a change that has to grow the package.Checks
bin/checkreportsremoved-assertfor the tests that pinnedsyncReviewor the prompt's own review pointer. Each one has a replacement:adoptReview(alloc, id, &review, owned copy)inapproval_screen.zig,approval_prompt.zigandapp_render_runtime.zig, and the twonullcases;review_source == &reviewand== &replacement_reviewinapp_worker_runtime.zig. The prompt's and the projection's pointer equality became pointer inequality plus content checks (currentReview() != &review, the row count, the viewport), because the prompt now holds its own copy. Intui-host-switch.test.ts, the status and row assertions now pin indexed status lines and the full row text. None was dropped (R7.4).agents_menu/andturn_clock/stay as they are (R7.2). The list's label comes from the worker's turn phase, and a parent-routed approval is still a turn in flight. The clock's wait condition and edges are unchanged; only who owns the review copy changed.switch_order,agents_menu_selection,queue_placementanddiff_rows, the four targets this change reaches directly, each ran one 60 s round with no reproducer.-OReleaseSafe -fsanitize-thread): 0 warnings in 40 tests, none in a changed file.Bun.sleeppolls (R7.3).Docs
The subagents page on fx.sh: vercel-labs/fx-web#365, stacked on vercel-labs/fx-web#357.
Rules: R3.8, every withdrawn or refused request leaves a trace line with counts and ids, never content; R3.9, the prompt owns its review and frees it; R4.1 and R4.2, the parent's answer never grants more than its own check; R7.1, each new test fails without its part of the change; R7.2, the model above; R7.4, no assertion was loosened.