Skip to content

feat(channels): claim-bound write abilities for external chat runtimes - #586

Merged
chubes4 merged 1 commit into
mainfrom
fix/issue-585-external-runtime-writes
Oct 17, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/issue-585-external-runtime-writes

Conversation

@chubes4

@chubes4 chubes4 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Closes #585.

Lets a runtime outside the process holding a chat run claim write that run and its transcript, using the same stores the in-process loop uses.

New REST-visible abilities, all gated by agents_chat_run_write_claim_permission (the run's claim_token is the only credential; client principals and caps are never consulted):

  • agents/append-chat-run-messages
  • agents/update-chat-run-message: edit in place, for streamed text
  • agents/append-chat-run-events
  • agents/set-chat-run-status: running → completed/failed/cancelled or suspended; the response carries cancellation visibility
  • agents/claim-chat-run-input: queued user answers, e.g. to input_required

Accepted-pending: a wp_agent_chat_handler may return status: pending (new WP_Agent_Run_Outcome::STATUS_PENDING → run-control running). agents_chat_run_claimed() then leaves the run open instead of terminalizing it.

Review focus: the claim token acts as a bearer credential over REST. That's intentional (the runtime is a separate process with no WP user), but check its lifetime and comparison in verify_run_claim().

Verification

  • php tests/chat-run-write-smoke.php: 59 assertions. Covers foreign-claim rejection, append/update, events + status transitions, the input_required round trip, and cancellation (owner cancel → runtime heartbeat sees it; committed cancel beats a success claim).
  • composer smoke: full suite, exit 0.

Finalized outside Homeboy: the cook produced this patch, but its gate (homeboy review test <component> --changed-since origin/main) could not run on the lab runner (merge base unreachable / no test extension for this component), and continuation is closed. I re-applied the cook's patch to a fresh worktree off origin/main and ran the verification below by hand.

AI disclosure: written by a Pi coding agent via Homeboy cook, verified and opened by Extra Chill Bot, authorized by @chubes4.

@chubes4
chubes4 merged commit eb5715d into main Oct 17, 2026
4 checks passed
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.

External runtimes: canonical write path for chat runs and transcripts

1 participant