feat(service): run an agent a Manager starts as whoever asked

Merged
DA
2d ago
+156-16

What

Adds the workspace experiment Managers act for whoever asked (manager-acts-for-asker). It is unlisted and off by default. With it on, a fresh start_agent call from a Manager creates the worker under the account of the member whose line opened the Manager's current turn. That member is read with turnAsker (#10776).

The start goes to startAgent with that account and opens on agentSessionsAs(asker). So the asker's payer, Macs, skills, GitHub commit identity, and "the developer you work for" now apply to the worker. When runsOn names a device, it is looked up among the asker's devices.

  • No payer, no fallback: if none of the asker's subscriptions or keys pays for the model, the start is refused with a message that names the asker. It tells the Manager to pick a model whose provider the asker connected, or to tell the asker. The owner never pays in the asker's place.
  • Owner keeps it when:
    • the turn has no member asker (an automation, an agent, or the app opened it), since turnAsker falls back to the starter
    • the call is a from start (continue or fork), which lands where the source agent stands
    • the experiment is off
  • Retries: a call run again reads the agent its key made under the same account (startedBefore now takes the account).
  • Reporting: the worker still reports to the Manager with message_agent. Agent-to-agent messages already reach across accounts.
  • Assignee: #10647's assignee path is untouched.

The experiment gets the usual registry entries: counted name, Settings anchor, and the words shown when it is turned on or off. Because it is unlisted, nothing visible changes.

Left open

  • runsOn left out still defaults to where the Manager runs. If the Manager runs on its owner's Mac, the start is refused with the existing "Only can start agents on it… or start it in the cloud" message.
  • Reach rules for another account's agent are unchanged.
  • The worker's reports still trip ledByAnotherAccount on the owner's side. A sibling task fixes that.

Tests

  • Added one case to coder-agent-tools.test.ts. With the flag on, a worker started in a turn a teammate opened belongs to the teammate and its session opens as them. An asker whose only key is OpenAI's is refused for Opus, even though the owner could pay. With the flag off, the worker is the owner's. The case fails without the change.
  • Ran coder-agent-tools.test.ts and experimental-page.test.ts in full (91 passed), tsc -b for @repo/service and @repo/panel, and oxlint and biome on the changed files. The rest is left to CI.

🤖 Generated with Claude Code