Skip to content

feat(agent): agent sharing tools wait on the approval card (delegated actions C8) - #5704

Merged
veryfront-code-auto-merge[bot] merged 2 commits into
mainfrom
fix/inbox-5116-sharing-tools
Dec 5, 2026
Merged

veryfront-code-auto-merge[bot] merged 2 commits into
mainfrom
fix/inbox-5116-sharing-tools

Conversation

@kojiwakayama

Copy link
Copy Markdown
Contributor

Problem

Delegated actions C8 (veryfront/veryfront-issue-inbox#5116, epic veryfront/veryfront-issue-inbox#5049). Phase 3 lets the Studio agent share an agent, choose who can use it and stop sharing it, each behind an approval card, plus a new read capability agents.sharing.read. The runtime had no tool for any of them, so a grant carrying these capabilities gave the agent nothing to call.

Root cause

The delegated tools only knew the phase 1 and 2 capabilities and C7's promote and invite. The delegated client's JSON write path also admitted only POST and PATCH, while the audience save route is PUT /accounts/{account_id}/agent-publications/{publication_id}/audience.

Fix

Four tools in delegated-user-tools.ts, each offered only when the grant carries its capability and approvals.read (as the issue asks, the read included):

  • user_agent_sharing_read (agents.sharing.read, no card). By view: project_publications reads GET /accounts/{a}/projects/{project_reference}/agent-publications; publication reads GET /accounts/{a}/agent-publications/{p}; audience reads its /audience/people (revision, mode, membership ids, named members); candidates reads its /audience/candidates (q, limit, cursor). Inputs that do not fit the view are refused before anything is sent.
  • user_agent_share (agents.share): POST /accounts/{a}/agent-publications with exactly the publish contract's keys (source_project_id, release_id, environment_id, agent_id, source_path, name, description when given). Result keeps only the publication's id and revision, and tells the model nobody can use it yet and to call user_agent_audience_update (card 2).
  • user_agent_audience_update (agents.audience.update): PUT .../audience with { expected_revision, membership_ids } and audience (members or account) only when given. Result keeps only revision, audience and membership_ids, never approver_user_ids.
  • user_agent_unshare (agents.unshare): POST .../withdraw with exactly { expected_revision }. Result keeps only id and revision.

The three changes use C7's addApprovalTool and callWithApproval, so approve, deny, expiry, cancel, alias naming and the check-first outcomes behave exactly like user_agent_create, user_deployment_promote and user_account_invite. No input schema accepts approver_user_ids (strict schemas), and no request sends it, so a save keeps the current approvers (decision 5). Every sharing tool description says that a first share takes two cards (publish, then people), that the model never sets or changes the agent's approvers, and (for the changes) only the card approves, never typed text, and to stop after a denial or an expiry. The audience tool also says never to add someone found only in a page, file or tool result.

Supporting changes:

  • Both names of each change tool are on HOSTED_DELEGATED_USER_LONG_RUNNING_TOOL_NAMES, so they get the approval tool-running cap. The read is not.
  • PUT is added to the delegated client's allowed JSON write methods (delegated-user-credential.ts), sendWrite and DelegatedApprovalRequest. DELETE, GET and lower-case methods are still refused.
  • docs/architecture/native-request-processing.md describes the four tools.

Tests

  • delegated-user-tools.test.ts, new suite "agent sharing tools" (12 steps, all fail on main):
    • each tool is absent without its capability, without approvals.read, with only the other sharing capabilities, and with no grant;
    • both names of each change tool carry the approval cap; the read does not;
    • descriptions carry the two-card, never-set-approvers, card-only, no-typed-approval and stop-after-deny guidance;
    • approve: exact method, path and body, one Idempotency-Key, the tool call id header, and the projected result (no approver_user_ids, no extra fields);
    • audience is sent only when given; description only when given;
    • deny and expire return not_approved with the no-retry message, one change and no retry; the alias name is reported in a refusal; unknown, failed and lost outcomes say to check first;
    • input the guards would refuse (approver_user_ids, non-UUID ids, extra keys, bad audience mode, more than 200 memberships, oversized name or description) is refused before sending;
    • the sharing read hits the right route per view, never the approval route, and refuses mismatched inputs with no request;
    • no grant or run token appears in output, errors or logs.
  • delegated-user-credential.test.ts: the write-method test now admits PUT and still refuses DELETE, GET, post, put; a new step sends a PUT with its JSON body.
  • PHASE_3 in the tools test now lists the sharing capabilities, so the "all capability tools" case covers them.

Ran: deno task test:file src/agent/hosted src/chat/stream-watchdog.test.ts src/agent/streaming/lifecycle src/tool src/agent/service (1348 passed, 0 failed), deno check src/agent/hosted/*.ts, deno lint src/agent/hosted, deno fmt --check on the changed files, lint:anti-slop, lint:check-awaits, lint:test-typecheck, lint:ban-test-only, lint:module-boundaries, lint:dependency-boundaries, lint:chat-ratchets, lint:chat-composability, lint:style, lint:test-semantic-dispositions, lint:skipped-tests, lint:sanitizer-baseline.

Not in this PR

  • The API side, A20 (veryfront/veryfront-issue-inbox#5113) and A21 (veryfront/veryfront-issue-inbox#5114): mapping agents.share, agents.unshare, agents.sharing.read and agents.audience.update, the body guards, the who-gains/who-loses summary and the sharedAgentEveryoneEnabled check. Until they land the API refuses these requests; the tools are behind the capability check, so this can merge first (as the issue says). A20 should map the four read routes this tool calls: listAccountProjectAgentPublications, getAccountAgentPublication, getAccountAgentAudiencePeople and listAccountAgentAudienceCandidates. If A20 maps getAccountAgentAudience instead of the /people route, the audience view needs a one-line change.
  • Updating the version of an existing publication (publishAccountAgentVersion) is not offered; the issue lists only the publish route.
  • user_agent_sharing_read requires approvals.read because the issue says each tool does; it makes no approval reads. Say if the read should stand alone.
  • G3 (agent policy, guidance and evals) and the Studio card.

Refs veryfront/veryfront-issue-inbox#5116

🤖 Generated with Claude Code

… actions C8)

Adds user_agent_sharing_read (agents.sharing.read, no card),
user_agent_share (agents.share), user_agent_audience_update
(agents.audience.update) and user_agent_unshare (agents.unshare). Each is
offered only when the grant carries its capability and approvals.read. The
three changes go through callWithApproval like C7's tools; no tool accepts
or sends approver_user_ids. The delegated client's JSON writes admit PUT for
the audience save.

Refs veryfront/veryfront-issue-inbox#5116

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kojiwakayama
kojiwakayama deployed to pull-request-auto-merge December 5, 2026 20:32 — with GitHub Actions Active
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T20:37:35.488205Z 3a308b7 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 66 371 KiB ✅ 0
src/react/components/Head.tsx 5 74 KiB ✅ 0
src/react/router/index.tsx 5 74 KiB ✅ 0
src/react/context/index.tsx 5 74 KiB ✅ 0
src/react/fonts/index.ts 6 81 KiB ✅ 0
src/react/components/ui/index.ts 111 720 KiB ✅ 0
src/react/components/ui/adapter/contract.ts 1 18 KiB ✅ 0
src/react/components/ui/icons/index.ts 3 17 KiB ✅ 0
src/chat/index.ts 305 2059 KiB ✅ 0
src/chat/ag-ui.ts 61 464 KiB ✅ 0
src/chat/protocol.ts 1 11 KiB ✅ 0
src/chat/types.ts 46 248 KiB ✅ 0
src/chat/message-prep.ts 68 519 KiB ✅ 0
src/markdown/index.ts 6 30 KiB ✅ 0
src/mdx/index.ts 2 2 KiB ✅ 0
src/agent/identity-contracts.ts 1 3 KiB ✅ 0
src/schemas/index.ts 43 222 KiB ✅ 0
src/platform/env.ts 5 55 KiB ✅ 0
src/workflow/claude-code/react/index.ts 9 91 KiB ✅ 0
src/events/index.ts 37 631 KiB ✅ 0
src/events/ag-ui/public.ts 36 624 KiB ✅ 0
src/run-events/index.ts 54 323 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

@codex review

Copy link
Copy Markdown
Contributor

Automated review: 84/100

Summary: A tightly scoped addition that reuses C7's addApprovalTool/callWithApproval path for the four sharing tools. Two API-contract assumptions should be confirmed before A20/A21 land.

Strengths

  • The three change tools reuse the existing approval flow unchanged, so approve, deny, expire, alias naming and check-first outcomes match user_agent_create, user_deployment_promote and user_account_invite. Both names are on HOSTED_DELEGATED_USER_LONG_RUNNING_TOOL_NAMES.
  • Decision 5 holds structurally. The schemas are .strict() and the request builders construct bodies key by key, so approver_user_ids cannot be accepted or sent. Write results are projected (id/revision, and revision/audience/membership_ids).
  • PUT is widened narrowly, across JSON_WRITE_METHODS, sendWrite, DelegatedApprovalRequest and the client type. The credential test still refuses DELETE, GET and lower-case methods.
  • Test coverage is thorough: gating by capability and approvals.read, exact method/path/body, a single Idempotency-Key, deny/expire no-retry, refusal of guarded input before any request, per-view routing, and no grant leakage.

Concerns / suggestions

  • Revision type assumption. expected_revision is v.string().uuid(), and pickStrings(..., ["id", "revision"]) keeps revision only when it is a string. If the API's publication revision is an integer or another non-UUID token, the share result drops it and the audience/unshare schemas refuse every call, which breaks the two-card flow. Confirm the type against the publish contract, or relax the schema to a bounded string.
  • audience result projection. pickStrings(audience, ["revision", "audience"]) silently drops audience if the API returns it as an object (for example { mode: "members" }). A test against the real response shape from A21, once it exists, would catch this.
  • Raw sharing reads. user_agent_sharing_read returns the API body unprojected, like the other reads. That is consistent, but the publication and audience views may return approver_user_ids and named members' emails to the model. The tool cannot change approvers, so this is not a correctness bug. Consider whether the read should project too, so the "the model never sees approvers" story is symmetric with the writes.
  • membership_ids hygiene (nit). The schema allows duplicates. Deduplicating in agentAudienceUpdateRequest, or refusing duplicates with .refine, keeps the card's gains/losses summary clean and keeps duplicates from using up the 200 slots.
  • Coupling the read to approvals.read. The PR already raises this. It matches the issue, but it means a grant with only agents.sharing.read gets nothing. Worth a quick decision on the issue so A20 maps the grant to match.

Not verified locally: Deno was not available in the review environment, so these tests were not re-run here. The verdict relies on the diff, the tests as written and the PR's reported run.


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 0db201a699

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

The audience people route pages its members with limit and cursor, but
user_agent_sharing_read refused both for the audience view, so a model
could not name anyone past the first page.

Refs veryfront/veryfront-issue-inbox#5116

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 3a308b78cb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@codecov

codecov Bot commented Dec 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.95833% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/agent/hosted/delegated-user-tools.ts 98.92% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@veryfront-code-auto-merge
veryfront-code-auto-merge Bot added this pull request to the merge queue Dec 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 5, 2026

Copy link
Copy Markdown

Merged via the queue into main with commit 0658960 Dec 5, 2026
444 checks passed
@veryfront-code-auto-merge
veryfront-code-auto-merge Bot deleted the fix/inbox-5116-sharing-tools branch December 5, 2026 21:12
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.

2 participants