feat(service): open a Manager's agents' pull requests as the task's assignee
Summary
When a Manager starts an agent and its task is assigned to someone other than the Manager's owner, the agent now opens its PR as the assignee, using their GitHub sign-in. If that sign-in is missing or GitHub refuses it, the PR opens as Vespin's App, with Requested by <assignee>. at the end of the description. Commits, billing and the agent's account don't change. A task with no assignee, or one assigned to the Manager's owner, opens PRs as before.
openPullRequest
agentRepositoryToken
if access is the starter's own token → open on it alone (unchanged)
+ managerAssigneeOf(owner, agent) # packages/database/src/models/manager-assignee.ts
+ if the agent was started by a Manager and its task is assigned to another workspace member
+ open on the assignee's own sign-in
+ on refusal or no sign-in → App, body ends "Requested by <assignee>."
+ (nothing is recorded on the agent's author column, which describes the owner)
attemptAsDeveloper → App fallback (unchanged)
managerAssigneeOf returns the assignee only when all of these hold:
agent.startedByAgentIdis a Manager (kindmanager) of the same account.- The task's assignee is not the Manager's owner.
- The assignee is still a member of the agent's workspace. Removing someone from the workspace stops their account being used immediately.
Who can cause this: anyone who can assign a task that a Manager's agent works on can cause a PR to open under the assignee's GitHub account. Dean chose this simple rule over requiring the assignee to have asked in the Manager's chat. The limits:
- The assignee's token is read in the service and used for one
POST /pullson the agent's own repository. - It never reaches the sandbox, the same as the developer's token today.
Smaller changes: the tool's openedAs and the counted event's opened_as each gain assignee.
Evidence
The new tests in pull-request.test.ts, run against main's pull-request.ts, both fail:
× a Manager's agent on a task assigned to a teammate opens on the assignee's own token, its description as the agent wrote it
× where GitHub refuses the assignee's token, the App opens it in their place, its description ending on who it was requested by, and never on the owner's token
Tests 2 failed | 8 passed (10)
With this change they pass, along with manager-assignee.test.ts (Test Files 2 passed, Tests 11 passed). manager-assignee.test.ts checks the cases where nothing is read: an agent started by a coder rather than a Manager, another account, an assignee who left the workspace, and a task assigned to the owner.
What I ran:
- Those two test files.
pnpm check:affected: everything passed except@repo/service#typecheck, which was killed for running out of memory (exit 137), not a type error. I reran that typecheck alone (tsc --build) and it passes.
CI runs the rest.
Merge Danger
Door: two-way. No schema or wire change: openedAs is read only by the model, and the counted event only gains a value.
Blast Radius: narrow. Only agents started by a Manager, on a task assigned to a workspace member other than the Manager's owner, change. Their PRs now open as the assignee, or as the App with a "Requested by" line, where before they opened as the owner.
🤖 Generated with Claude Code