Skip to content

feat(session): let a person answer the runtime's approvals and questions - #26

Closed
xxchan wants to merge 4 commits into
mainfrom
feat/interactive-approvals
Closed

xxchan wants to merge 4 commits into
mainfrom
feat/interactive-approvals

Conversation

@xxchan

@xxchan xxchan commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Why

rowrow steers many agents from a phone and wants risky actions to wait for a person (and the agent's questions to reach them), possibly minutes later. Every oar session ran YOLO: adapters disabled the runtime's gate and nothing let a host take a decision. This settles chat-ui.md open question 2.

What

  • SessionOptions.approvals?: "never" | "ask": "never" (default) is today's YOLO, unchanged. "ask" turns the runtime's own permission gate on and routes it to the host; oar owns no approval policy. The gate is forced on, never assumed; where oar cannot guarantee it the runtime declares so.
  • SessionCapabilities.approvals: { kind: "supported" } | { kind: "unsupported"; code: "no_gate" | "not_enforceable"; reason }. An "ask" open on an unsupported runtime rejects with the reason.
  • Session.answer(requestId, decision): Promise<ControlOutcome> with AppDecision = allow (once | session) | deny (message?) | answer (questions) | native. Recorded like every control: an answer request, the toApp request's answered response (reply as sent, verbatim), then accepted. Typed rejections: unknown_request, already_answered (first answer stands: two devices racing get one accept), withdrawn, runtime_exited, disposed, unsupported, error.
  • AppAsk (what is asked, read from the native body): tool_approval (tool, callId, title, reason, input, command, cwd, paths, diff, choices, denyMessage) or question (questions with options). It rides on the toApp request body and the app_request event; native stays verbatim beside it.
  • Never pending forever: new app_request_withdrawn event (claude control_cancel_request, codex serverRequest/resolved for an unanswered request); ACP's protocol-required cancelled answer on abort is recorded; the exit voids the rest. status() gains awaiting (and stallOf stays quiet while a person owes an answer); SessionView.pendingRequests carry ask and settle on all three.
  • scriptedRuntime scripts can approve() / ask(), so hosts can test approval UIs without binaries.

Per runtime (evidence in docs/runtimes/*, experiments/approval-channels*.ts)

Runtime approvals Gate under "ask" Evidence
claude 2.1.284 supported --permission-mode default --permission-prompt-tool stdio aimock probe: can_use_tool waits (allow 300 s later ran the tool), deny message reaches the model, session grant = claude's addRules+addDirectories at session destination, AskUserQuestion answers, interrupt → control_cancel_request; CI (windows-latest): a safety-check write (8.3 temp path) carries suppress_always_allow_rule, so no allow_session is offered and a session grant is refused unsupported
codex 0.155.1 supported approvalPolicy: "untrusted", approvalsReviewer: "user" (reply checked) aimock probe: command approvals, accept / acceptForSession / decline / cancel, serverRequest/resolved, resume keeps the policy; on-request asked nothing under danger-full-access
kimi 2.0.0 supported mode default live: session/request_permission waited, reject held; "Approve for this session" = allow for the session
grok 1.0.44 not_enforceable none live: under permission_mode = "always-approve" config, --permission-mode default, yoloMode: false and GROK_DEFAULT_PERMISSION_MODE all ran the command unasked; no mode read-back
pi no_gate none pi has no permission gate

Usage

const session = await runtime.session(installation, { cwd, approvals: "ask" });
session.events(async (event) => {
  if (event.kind === "app_request" && event.ask?.kind === "tool_approval") {
    const ok = await askThePerson(event.ask.tool, event.ask.command ?? event.ask.input);
    const answer = await session.answer(event.requestId, ok ? { kind: "allow" } : { kind: "deny", message: "not now" });
    if (answer.kind === "rejected") console.log(answer.code); // withdrawn, already_answered, runtime_exited, …
  }
});

Tests

  • pnpm run check: green (typecheck, lint, 397 unit tests, mock sea-trial 22/22).
  • pnpm tsx sea-trial/all.ts: mock, claude-aimock, codex-aimock, pi-aimock all 22/22; OAR_TEST=scripted pnpm sea-trial 22/22. New cases: sea-trial/cases/session-approvals.ts.
  • OAR_TEST=claude-aimock|codex-aimock pnpm vitest run sea-trial/vendor/approvals.vendor.test.ts: green locally and in CI on ubuntu, macos and windows (it asserts on the runtimes' own reports in a scratch cwd, so it holds across shells). (Two pre-existing claude vendor tests fail on this host only: account usage under a subscription login, and the system-prompt capture picking up the Claude Desktop entrypoint.)

Notes for review

  • SPI break for custom runtimes: AdapterSession.answer and SessionCapabilities.approvals are required (kernel.answer makes the former a one-liner). Needs a minor bump at release.
  • claude: a runtime control_request is now one record (the toApp request), no longer also a frame.
  • Open: sub-agent can_use_tool (carries agent_id, recorded at the root); codex file-change approvals and requestUserInput are schema-backed only (not reachable in this aimock setup / Default mode); kimi's session grant not exercised live; grok could become supported given a switch that outranks the config or a mode read-back.

🤖 Generated with Claude Code

xxchan and others added 4 commits September 29, 2026 14:55
rowrow steers many agents from a phone and wants risky actions to wait
for a person, and the agent's questions to reach them, possibly minutes
later. Every session ran YOLO: adapters disabled the runtime's gate and
nothing let a host take a decision.

SessionOptions.approvals ("never" by default, so no host changes) opts a
session into the runtime's own permission gate, routed to the host.
Each approval or question is a toApp request that holds its turn until
Session.answer(requestId, decision) settles it. oar owns no approval
policy: what asks is the runtime's rules. The gate is forced on, never
assumed, and a runtime where oar cannot guarantee it declares so
(SessionCapabilities.approvals: supported, or unsupported with a code).

- An answer is recorded like every control: an `answer` request with the
  host's decision, then the toApp request's `answered` response with the
  reply exactly as sent, then `accepted`. Refusals carry one code:
  unknown_request, already_answered (the first answer stands, so two
  devices racing get one accept), withdrawn, runtime_exited, disposed,
  unsupported. The kernel keeps the bookkeeping, read off the stream, for
  every adapter; an adapter only turns a decision into its native reply.
- What is asked (AppAsk: a tool approval with tool, callId, command,
  paths, diff, reason; or questions with options) rides on the toApp
  request body beside `native`, as a frame carries `events`, and on the
  `app_request` event. `ask.choices` lists the typed decisions (allow,
  allow for the session, deny, answer) the runtime is shown to honor; a
  `native` decision sends the runtime's own payload for everything else.
- A request never looks pending forever: the runtime withdrawing it is a
  new `app_request_withdrawn` event (claude control_cancel_request, codex
  serverRequest/resolved for one oar did not answer); ACP's required
  `cancelled` answer after session/cancel is recorded like any automatic
  one; the exit voids the rest. status() says whom the turn is
  `awaiting` beside the phase, stallOf reports no stall meanwhile, and
  SessionView's pendingRequests carry the ask and settle on all three.

Per runtime, probed 2026-09-29 (experiments/approval-channels.ts
token-free on aimock; approval-channels-acp.ts on the real login):

- claude 2.1.284: `--permission-mode default --permission-prompt-tool
  stdio` instead of --dangerously-skip-permissions. can_use_tool control
  requests (AskUserQuestion included) wait: an allow 300 s later ran the
  tool. deny's message reaches the model; a deny without one reads as an
  invalid result, so oar sends a default. Allow for the session sends
  claude's own addRules and addDirectories suggestions at destination
  session (the rule alone still asked for a path outside the working
  directory), never its setMode. A control_request is now one record,
  the toApp request, no longer also a frame.
- codex 0.155.1: approvalPolicy untrusted with approvalsReviewer user on
  thread/start and thread/resume, the reply checked (on-request under
  oar's danger-full-access sandbox asked for nothing). Command approvals
  take accept / acceptForSession / decline though availableDecisions
  lists fewer; the answer carries codex's numeric JSON-RPC id back.
  requestUserInput and file-change approvals follow the schema
  (questions are refused in Default mode).
- kimi 2.0.0: mode `default`; session/request_permission waits, reject
  holds; "Approve for this session" is allow for the session.
- grok 1.0.44: not_enforceable. Under a user config permission_mode =
  "always-approve", the top-level --permission-mode default, yoloMode
  false and GROK_DEFAULT_PERMISSION_MODE all left a command running
  unasked, and grok reports no mode in effect.
- pi: no_gate.

scriptedRuntime scripts can approve() and ask(), so hosts test their
approval handling without a binary; the mock runtime asks on the probe
prompt. contracts/records.ts moves the graph and cursor types to
graph.ts (re-exported) to stay under the file-size limit.

Docs: design/approvals.md (the position, decision gates, refusals),
decisions.md, spec/approvals.md (shapes, per-runtime mapping, the
pending lifecycle), record-stream.md, chat-ui.md open question 2
settled, every runtime page with its evidence.

Tests: kernel, fold and view units (tests/approvals.test.ts); adapter
tests against scripted claude, codex and ACP processes; sea-trial
cases/session-approvals.ts (declared-or-refused, typed answer
rejections, a held turn, withdrawal on abort, void on dispose) green on
mock, scripted, claude-aimock, codex-aimock and pi-aimock;
approvals.vendor.test.ts on claude-aimock and codex-aimock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The vendor approvals test checked the filesystem after `touch <absolute
path>`, which Windows breaks two ways: Git Bash mangles the backslashes, and
codex's PowerShell has no `touch`. It now runs in a scratch cwd with relative
paths and asserts on what the runtime itself reports: claude's tool results
(the deny's message is the denied call's output), codex's commandExecution
item status (declined, or not). The sea-trial subject takes a `cwd` override
for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A refused answer leaves the turn held, so the vendor test waited out its
timeout instead of saying why (Windows, claude). It now aborts the turn and
reports the rejection code, opens the vendor trace like the other vendor
tests so a red run ships its trajectory, and retries the scratch-dir cleanup
Windows briefly holds after the process exits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uiet

CI on windows-latest showed why the session grant was refused there: the
runner's temp dir is an 8.3 short path (RUNNER~1), and claude's safety check
flags a write through it as "a suspicious Windows path pattern" with
suppress_always_allow_rule, so oar rightly offered no allow_session and the
grant came back `unsupported`. The scratch dir is now resolved to its long
name, the session probe writes outside the cwd again (`touch ../session`) so
the addDirectories half of the grant stays pinned, and every session the
test opens is disposed before the mock stops, by a watchdog too, so a failed
expectation reports itself instead of timing out. The claude runtime page
records the safety-check shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan marked this pull request as draft September 29, 2026 08:11
xxchan added a commit to xxchan/rowrow that referenced this pull request Sep 29, 2026
- README: `npx rowrow serve` to try it, `npm install -g rowrow` and the
  service to keep it. `rowrow service install` refuses to run from npx's
  cache (npm clears it, and the service would stop working) and says to
  install it first.
- D-022: agents run without permission prompts, in oar and rowrow alike;
  approvals (botiverse/oar#26) are parked. D-011 points to it; the roadmap
  and the roamgate comparison say so; rowrow 0.1.0 on npm moves to done.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan

xxchan commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

Holding this for now. oar keeps its default of running agents without permission prompts, and rowrow won't expose approvals either (rowrow D-022), so approvals: "ask" has no consumer yet. The PR stays as a draft, ready to pick up if that changes, for example for agents working on repositories you don't trust.

State when parked:

  • CI green on all 12 jobs.
  • "ask" works on Claude Code, Codex and Kimi; Grok is refused as not_enforceable and Pi as no_gate.

Before merging:

@xxchan

xxchan commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

Closing per xxchan (2026-10-13): approvals stay parked and OAR keeps running agents without permission prompts. The branch stays; when approvals come back they get a fresh design on current code.

@xxchan xxchan closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant