# Collaboration

<Callout type="note" title="Experimental">
	Collaboration is experimental.
</Callout>

Collaboration lets the owner of an agentic batch change invite other users to work on it. A collaborator can talk to the agent, answer its questions, run workspaces, and publish, for a fixed time. For example, a platform engineer who owns a framework migration invites a service team member for 24 hours to answer the agent's questions about that team's repositories and fix their CI failures.

Each action runs as the user who does it, not as the owner. See [Whose credentials an action uses](#whose-credentials-an-action-uses).

## Roles

- **Owner**: the user who created the agent, or who got it through a [handover](/agentic-batch-changes/configuration#handing-over-an-agent). There is one owner. The owner can do everything a collaborator can do, and also:
    - Invite, extend, and remove collaborators.
    - Approve publications.
    - Hand over the agent.
    - Rename, share, stop, and delete the agent, and start new threads.
    - Close, move, and delete the batch change.
- **Collaborator**: a user the owner invited. A collaborator sees the full transcript and the list of collaborators, and can:
    - Send messages and upload files.
    - Answer the agent's questions and approve tool calls, except publication approvals.
    - Cancel and retry turns.
    - Run workspaces, publish, and clean up changesets that the current plan no longer produces.
    - Ask the agent to merge changesets, and approve the merge.
    - Act on changesets on the batch change page: publish, push the branch, comment, close, merge, rebase, sync, and retry.
- **Administrator** with the `BATCH_CHANGE_AGENT_ADMINISTRATION#MANAGE` [permission](/admin/access-control/batch-changes): sees every agent on the [Threads page](/agentic-batch-changes/configuration#threads-page), can hand over any agent, and can invite, extend, and remove collaborators. An administrator who is not a collaborator cannot send messages or act on the agent.
- **Previous owner**: after a handover, the previous owner keeps read access to the agent. This access does not expire, and the previous owner cannot act on the agent.
- **Viewer**: a user who opens the agent through its [share link](/agentic-batch-changes/configuration#sharing-and-visibility). A viewer can read the transcript but cannot act on the agent or see the collaborator list.

## Inviting collaborators

The owner or an administrator invites collaborators from the collaborators panel on the agent page. To be invited, a user must:

- Be a user on the instance other than the owner.
- Have the `Batch Changes: Write` and `Batch Changes: Agent Write` [permissions](/agentic-batch-changes/configuration#access). Sourcegraph refuses the invite otherwise.

Sourcegraph does not check the collaborator's repository permissions when they are invited. The collaborator's own repository permissions apply when they act. See [Whose credentials an action uses](#whose-credentials-an-action-uses).

Every collaborator access expires. Select 1 hour, 24 hours, or 7 days when you invite. There is no access without an expiry and no limit on the number of collaborators. The invited user gets a notification in Sourcegraph, and the access starts immediately.

To extend access, select a new duration. The access then ends that long from now, not from the old end time. After access expires or is removed, invite the user again.

A collaborator cannot leave an agent. Access ends when it expires or when the owner or an administrator removes it. Removing a user's `Batch Changes: Agent Write` permission also stops them from acting on the agent.

The [audit log](/agentic-batch-changes/configuration#audit-log) records `collaboratorInvited`, `collaboratorExtended`, and `collaboratorRevoked` with the owner, the collaborator, the user who made the change, and the expiry. Conversation and workspace actions record both the owner and the user who acted.

## Whose credentials an action uses

The user who sends the message, answers the question, approves the tool call, or clicks the action is the user it runs as. That user's repository permissions, Batch Changes credentials, secrets, connectors, guidance, and usage limits apply:

- The agent researches and runs Deep Search as that user. Repository names the agent sees are limited to repositories that both the owner and that user can read.
- Guidance and skills come from that user's settings and from the site and organization settings that apply to them.
- Workspaces and coding agent steps run as that user, with that user's secrets, connectors, and Sourcegraph MCP identity. Coding agent step runs count against that user's [entitlement](/admin/entitlements).
- Tool approvals belong to the user who gave them. An approval from one user does not count for a turn that runs as another user, also when the approval was for this agent or for all agents.

When an action cannot run as that user, it is refused with a reason. It does not fall back to the owner. For example, a publish is refused when the user has no valid Batch Changes credential for a code host and there is no global credential, and a workspace fails when a secret it needs is not available to that user.

### Exceptions

In these cases, the user an action runs as or is charged to is not the user who wrote the message:

- **Automatic turns**: when the agent wakes up on its own, for example after a run finishes or CI reports a result, the turn runs as the current owner.
- **Changeset hooks**: CI and merge conflict automations run as the user whose turn prepared the current plan. When a collaborator's turn prepared it, hooks use that collaborator's permissions, secrets, and connectors.
- **Retry**: a retried turn runs as the user who clicks **Retry**, not as the author of the original message.
- **Answers and approvals**: when a turn is waiting for an answer or an approval, any owner or collaborator can answer. The turn then continues as the user who answered.
- **Publication approvals**: only the owner can approve a publication. A collaborator can publish only to repositories and in a mode, such as draft, that the owner already approved for this agent.
- **Code host pushes and syncs**: Sourcegraph pushes and syncs all changesets of the batch change with the Batch Changes credential of the user who last applied it, or the global credential when that user has none. This also applies to changesets that another user published. Publishing from the conversation makes the publishing user the last applier. Publishing from the batch change page does not change the last applier, so the push uses the credential of the previous last applier. Comment, close, merge, and rebase use the credential of the user who starts them.
- **Published changesets entitlement**: when a collaborator publishes, the published changeset counts against the collaborator's entitlement. When the owner publishes, it counts against the owner's.
- **Billing**: merged changesets are [billed](/agentic-batch-changes/configuration#billing) to the subscription and recorded for the owner, no matter who published or merged them.
- **Batch change namespace**: the batch change stays in the owner's namespace, also when a collaborator's turn creates or updates it.
- **Uploaded files**: files are stored with the agent under the owner, no matter who uploaded them. Every user who can open the agent can download them.
- **Repository visibility at publish**: Sourcegraph checks that the owner can read the target repositories before it publishes, in addition to the publishing user's own permissions.

## When access ends

When a collaborator's access expires or is removed:

- A turn of theirs that has not started yet fails with a message that the author no longer has write access. The owner or another collaborator can retry it. The retry runs as the user who retries.
- A turn of theirs that is running is not stopped. The agent can continue to read and research, but it cannot run workspaces, publish, prune, or merge as that user.
- Questions and approvals that wait in their turn stay open. The owner or another collaborator can answer them, and the turn continues as that user.
- Their approvals for secrets stay saved but apply only to their own turns.

## Handovers

A [handover](/agentic-batch-changes/configuration#handing-over-an-agent) needs the agent to be idle or waiting for input, so no turn is running or queued at that time. During a handover:

- Collaborators keep their access, except the new owner, who becomes the owner.
- The previous owner keeps read access.
- All publication approvals are removed. The new owner approves publications again.
- Questions and approvals that wait stay open. The new owner or a collaborator can answer them, and the turn continues as that user.
