Repository navigation
feat(mcp): Runtime runs agent tools for people's agents, as their person - #873
Conversation
|
Review: GPT-6.1-Sol (xhigh), round 1 on 04f3206. No blocking, should-fix or nit findings. Sol checked these areas and found them correct:
It ran 123 tests across 13 files. |
04f3206 to
3a49456
Compare
Acceptance: PASS with notesChecked Done means
Golden journeys
Additional risks and mirrored surfaces
Local evidence: 488 tests, 2 browser journeys, and rollback rehearsalFocused Runtime, execution Local/Engine, devExecution, guest, devLog, ConnectionsView and server migration suites: Independent real-workerd/Postgres acceptance probe: API, patch log API, portal, and independent mixed-release/connection-rendering checks: Browser journeys:
Rollback answers: match the diff. Nullable agent-name columns and the widened credential constraint remain; older readers tolerate the added rows. No Not run
Notes
|
c6020af to
b27f0c9
Compare
3a49456 to
a89e676
Compare
b27f0c9 to
f0f2048
Compare
Invocation.callAgent is how Patchy's own agent callers, the door and `patchy dev agent`, start a tool: on the version they read it from, as the person, with the agent's name in the binding, which no request can set. An agent's call starts only a marked agent tool; inside it, ctx.run reaches sibling handlers as usual. The tool's kind runs it through the same invocation as a page's call. The guest wire carries `agent` only on an agent's calls, nested ones included, so loaders and guests built before it keep serving pages, and handler code reads its absence as ctx.agent null. Every invocation row of an agent's call names the agent beside its person, and its callbacks' rows name the agent connection as their credential (migration 0021). dev's log says "<person> via <agent>". The caller's recheck runs before each company callback, as a page's session check does, so a failing one stops the call at its next callback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a89e676 to
fa5e9ea
Compare
… dev agent` (#875) Stacked on #873 (ticket #844); merges with the rest of #833's stack, not alone. ## What changed In the skill test, no builder agent could call its own agent tools before publishing, so each told its person the tools were untested. Now `patchy dev agent` lists a patch's tools as a worker agent sees them, and `patchy dev agent <tool> [<json>|-]` calls one the way Patchy MCP's door will, against the running `patchy dev` session, as the dev viewer or the colleague (`--colleague`). Open dev pages update live. Closes #844 ## Look at **1. One call path, the door's shapes** (`packages/patchy/src/devAgent.ts`, `packages/api/src/agentTools.ts`). Each dev mount answers a nonce-guarded `POST /~dev/agent` as its own person. The daemon reads the binding once, checks that the tool exists and that its arguments fit the schema on that version, and calls `Invocation.callAgent` (#843) with `ctx.agent` `{ name: "patchy dev" }`. A change gets a fresh key: a mutation's becomes its mutation key, which the daemon reuses on a retry of `unknown_outcome`. An action is never retried. Answers come from the shared module, which gains `unknownToolRefusal`, `invalidArgsRefusal`, `runtimeRefusal` and `callAnswer`, so the door (#854) shows agents the same words. The agent access switch is never read. **2. The CLI contract** (`devLifecycle.ts`, `CliError.ts`, ADR-0004). These follow the ticket's exit codes: - 0: a result. - 2: any refusal the door would give. ADR-0004's failure document gains `from`, `details` and `retryAfterSeconds`. - 1: a local problem: `not_running`, `no_agent_tools`, or arguments that aren't one JSON object. - 3: a started call got no usable answer. **3. Naming the binding** (`devServer.ts`, `devResources.ts`). Server builds are counted per session, and a call's `version` is its build. `dev.log` now says `Server build N ready`. When the latest rebuild failed, the answer says the last good build answered, in `warnings` under `--json`. A live run on this worktree's dev instance, with a starter tier 2 repo and two tools in `agent/notes.ts`: ``` $ pnpm patchy dev agent addNote '{"title":"Call Acme back"}' { "result": { "id": "01a16390-…", "by": "Patchy Dev", "via": "patchy dev" }, "version": 1 } Server build 1 answered as Patchy Dev via patchy dev. [exit 0] $ echo '{"title":"Send the deck"}' | pnpm patchy dev agent addNote - --colleague { "result": { "id": "01a16390-…", "by": "Dev Colleague", "via": "patchy dev" }, "version": 1 } Server build 1 answered as Dev Colleague via patchy dev. [exit 0] $ pnpm patchy dev agent listNotes --json {"result":["Send the deck","Call Acme back"],"version":1} [exit 0] $ pnpm patchy dev agent addNote '{"title":" "}' --json {"ok":false,"error":"agent-notes refused addNote (blank): give the note a title.","kind":"rejected","code":"blank","from":"patch","details":{"message":"give the note a title"}} [exit 2] $ pnpm patchy dev agent addNote '{}' --json {"ok":false,"error":"addNote's arguments don't fit its schema: Missing key at [\"title\"]. Fix them from its args in open_patch.","kind":"rejected","code":"invalid_args","from":"patchy"} [exit 2] # (since review round 1 this refusal also names the tools the patch has now and says to call open_patch) $ pnpm patchy dev agent create '{"title":"x"}' --json {"ok":false,"error":"agent-notes has no tool create. Its tools now: addNote, listNotes. Call open_patch to see what each does and takes.","kind":"rejected","code":"unknown_tool","from":"patchy"} [exit 2] $ pnpm patchy dev agent addNote '[1]' --json {"ok":false,"error":"A tool's arguments are one JSON object, such as '{\"name\":\"Acme\"}'.","kind":"local"} [exit 1] # listNotes' description deleted, so the rebuild fails: $ pnpm patchy dev agent listNotes { "result": [ … ], "version": 1 } Server build 1, the last good one, answered as Patchy Dev via patchy dev: the latest rebuild failed. Read `pnpm patchy dev logs`. # description restored: $ pnpm patchy dev agent listNotes { "result": [ … ], "version": 2 } Server build 2 answered as Patchy Dev via patchy dev. ``` The colleague's dev page was open throughout. Before and after `patchy dev agent addNote '{"title":"Book the venue for Friday"}'` ran as the primary viewer, with no reload in between:   ## How it was verified - `devAgent.test.ts` runs on supervised workerd and PGlite, through `DevResources` as `patchy dev` builds it. It checks: - `open_patch`'s answer; - a change as the viewer and as the colleague, each publishing the wake open pages re-run on; - a read that sees both, with `ctx.agent` and the person; - the dev settlement naming the agent; - the patch's refusal, `invalid_args` and `unknown_tool` (the page's own handler isn't a tool), and `handler_failed`; - `no_agent_tools` for tier 2 without tools and for tier 1. - `cliDevAgent.test.ts` runs the bundled CLI against a stub daemon. It checks the request, both outputs, `-` and `--colleague`, the stale build, and exits 0, 2 (with `from`, `details`, `retryAfterSeconds`), 1 (arguments, `no_agent_tools`, `not_running`) and 3 (a 500, an unreadable reply). - The live run above on `pnpm dev`, including the open page. - `agentTools.test.ts` covers the shared refusals and `callAnswer`. `devServer`, `devServerWatch`, `devExecution`, `devLifecycle`, `devLog` and all of `packages/api` pass. `pnpm typecheck:tests` and eslint pass, and `docs/API.md` is re-rendered. - `pnpm verify` on cdd420b passes all nine steps: format, lint, typecheck, synth, test (2,090 tests), postgres-concurrency, cli-smoke, tier2-smoke and browser. CI is green on cdd420b. `clerk-live` hit its 10-minute job cap twice on slow runners and passed on the third run. - `pnpm test:rollback-rehearsal --live dd3f41f` passes. dd3f41f is the `main` commit with #837 and #838; the run was dd3f41f → cdd420b → dd3f41f. This PR adds no migration. - Review: GPT-6.1-Sol (xhigh), two rounds. Round 1 had one blocking finding, round 2 none. Every finding is fixed or dismissed with a reason in the review comment. - Acceptance: [PASS with notes](#875 (comment)) on cdd420b. It also forced a lost reply after a committed mutation (the retry wrote once) and after an action (it ran once and warned it may have partly happened). ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required A new CLI subcommand and a new route on the local dev daemon. It adds no migration and no instance route. The one changed log line is `Server binding ready` → `Server build N ready` in `dev.log`, and nothing parses it. - **What does a revert leave behind?** Nothing. The command and daemon route go with the release, and no data changes shape. - **Does the release before it still work with that?** Yes. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).
## What changed This PR adds release 17's What's new entry, written from `5dd94f3`. It covers everything merged since release 16's `through` (`dd3f41f`), and it sets the `patchy` release to `0.17.0` in `packages/patchy/package.json` and `CURRENT_RELEASE`. With this release, people's agents can use their company's patches through Patchy MCP (#833). | Change | PRs | | --- | --- | | New: Your AI agent can use your company's tools | #873, #878, #880, #881, #882, #883, #884, #886, #887 | | New: Admins choose whether agents can use the company's tools | #871 | | Improved: Your machines shows your agents too (Revoke all machines is now Disconnect everything) | #885, #879 | | New: See what agents can do with a tool | #876 | | New: The log says when an agent made a change | #888 | | New: Your agent can make a tool ready for agents | #869, #870, #872, #875, #896 | | Behind the scenes: agents' calls have their own limits, and a server only an agent uses rests a minute after its last call | #889, #892 | | Behind the scenes: New and Improved changes are public, for patchyhq.com | #893 | | Behind the scenes: library updates | #899 | Five merged PRs get no line: - #874 is release 16's own entry. - #894 is dev tooling: worker agent launchers and scenario data. Its one CLI fix lets a `patchy` installed outside a tier 2 repo publish it. The skills have agents use the repo's pinned `pnpm patchy` instead, so that path is off the documented one. - #900 is CI. - #901 rewords an internal skill. ## Look at - **The entry**, at the top of `releases` in `packages/core/src/whatsNew.ts`. - It names only Claude Code and Codex. Both have connected through real consent against dev instances. Hosted clients (Claude.ai, ChatGPT) are checked in production only (`docs/product.md` › Patchy MCP › Acceptance). - Its labels are the pages' own: Agent access on Company, Your machines, What agents can do, Disconnect everything, and "Jordan Lee via Claude". - **Rollback safety, from the live commit `e4243ff` to `5dd94f3`.** - No PR in the range is labelled `one-way`, and every PR answers both Release impact questions with "Yes". - Migrations 0020–0025 are all additive: - three defaulted or nullable columns on `companies`; - `agent_name` on the runtime log, with a widened `credential_kind` check; - the agent connection tables, `agent_consents` and `change_keys`; - two columns on execution bindings. The new tables reference `users` without a cascade, but no release deletes users or companies. Release 16 reads the runtime log only for credential kinds it knows, so rows from agents can't break it. - `rollback-rehearsal` on #892 rehearsed the whole stack, since #892 adds the last migration and the rest of the stack sits below it: `Exercised rollback paths passed: e4243ff → c8bede4 → e4243ff → c8bede4, in 238s.` #896's run skipped, because it changes no migration or handler descriptor. - #883 turns on the load balancer's host header preservation, which the Deploy workflow's app stack deploy applies. A rollback leaves it on. That's harmless, because release 16's server never reads `Host`. - A rollback takes `/mcp` and `/whats-new.json` away. Connected agents get a 404 until this release returns, and then their connections work again, unless one ended in between. Agent tools published in between stay refused to pages, because #837 already shipped in release 16. ## How it was verified - `pnpm check` on `2d528b1`: format, lint, typecheck and synth passed. In the test step, 2,300 of 2,301 tests passed. The one failure was `packages/sdk/src/install.test.ts` › "says how to reach patchy when the prefix's bin is not on PATH", which timed out at 180 s while the shared machine was loaded. Rerun alone, that file passes all 7 tests in 62 s. The release's own tests pass too: `whatsNew.test.ts`, `schemas.test.ts` and `WhatsNewPages.test.ts`. - The live commit was pinned from `/healthz/deep`: `e4243ff`, release 16. The Deploy run updated last succeeded, and none is unfinished. - Each PR in the range was read with `gh pr view`, including its Release impact answers. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required This PR changes only the changelog text and the `patchy` version. As with every release, a CLI installed before this deploy is told to upgrade. - **What does a revert leave behind?** Nothing. People whose seen marker reached 17 would just see no new release. - **Does the release before it still work with that?** Yes. If this release misbehaves, roll back to `e4243ff54d2acbbc88b60eeb0cf9b82a26dc9d5d` (release 16). Prepared by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
Stacked on #872 (ticket #842); merges with the rest of #833's stack, not alone.
What changed
People's agents need a way to run a patch's agent tools as the person who connected them. The door (#854) and
patchy dev agent(#844) will both call through one entry point,Invocation.callAgent. It runs a tool on the version the caller read it from, as the person, with the agent's name in Patchy's own binding, which nothing in a request can set.An agent's call can start only a marked agent tool. Handler code sees the agent as
ctx.agent, nested calls included. Every log row of the call names the agent, and the caller's recheck runs before each company callback.Closes #843
Look at
1. Admission (
packages/runtime/src/Invocation.ts). #837 already refused a page's call to an agent tool, at any depth. This PR adds the other half: at the top level an agent starts only a marked tool, and inside itctx.runreaches ordinary siblings as usual.callAgentrefuses a person outside the version's company.Invocation.test.ts› "only an agent's call reaches a marked agent tool, nested calls included" covers both directions:agent.*handler is refused;agentrides on the top-level and every nestedInvoke, and is absent from a page's.With the new rule removed, the test goes red:
expected 'invalid_request' to equal 'access_denied'.2.
ctx.agentacross releases (packages/api/src/guest.ts,packages/execution/src/loader.ts,packages/patchy/src/guest.ts). TheInvokeand the guest request carryagentonly on an agent's calls. Older loaders and published guests decode strictly, so a page's call never sends the field and keeps working on them. A guest reads a missingagentasnull.In a mixed fleet, a new host's agent call to an execution task from an older release is refused by that task's strict decode and fails as
handler_failed. It never runs withctx.agentnull. Page calls are unaffected.3. The log (migration
0021_runtime_log_agents):runtime_invocations.agent_nameis set on every invocation of an agent's call tree.runtime_calls) get credential kindagentwithagent_name, under a check that ties the two together. That follows the Runtime glossary's Runtime log: the call names the agent connection, not a session.RuntimeLog.CallandInvocationLog.Invocationread it back asagent: { name } | null, so The log says which agent made each change: "Jordan Lee via Claude" #856 only has to render it.dev.logsaysusr_… via patchy dev agent.listDeals success 12ms(devLog.test.ts).4. One live test on supervised workerd and Postgres (
InvocationLocal.test.ts› "an agent's call runs its tool as the person…"). It builds a real bundle whoseagent/file re-exports a page query, then checks four things:ctx.agentis{ name: "Claude" }from the agent andnullfrom the page.ctx.runsibling sees the same agent.agentand the agent's name, and every top-level and nested invocation row namesClaudebesideusr_dev.members.get(2 rechecks, 1 read).With the loader's forwarding removed, this test goes red.
How it was verified
vitest: all ofpackages/runtime, plusdevExecution,guest,devLog,ConnectionsView,apps/servermigrations, and executionLocal/Engine. 31 files, 307 tests, all passing.pnpm typecheckon runtime, execution, patchy and integrations;pnpm typecheck:tests;eslinton the changed files.ctx.agentreaches nested calls;rollback-rehearsalagainst production's e4243ff: e4243ff → this head → e4243ff passed.pnpm verifyon 04f3206, whose code is identical:testhad ten timeouts in nine suites this PR doesn't touch (load average ~24 on a shared machine), and those nine pass alone (140 tests).pnpm test:rollback-rehearsal --live dd3f41f(main with Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837 and Deactivation and Disconnect everything end pending device logins and record when a person's credentials ended #838) passed on 04f3206.Release impact
Additive: two nullable columns and a widened credential check. The guest wire's new field is optional and only sent for agent calls, which nothing makes until the door ships in this stack.
agent_namecolumns and widenedcredential_kindcheck, plus any rows agents wrote in the meantime.agent, and its log reads filter credential kinds to the ones it knows, so agents' callback rows stay hidden instead of failing to decode. Agents' invocation rows read as the person's own, without the agent's name.Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).