feat(tasks): rebind sandbox GitHub identity and git author to the actor - #70024
Closed
VojtechBartos wants to merge 1 commit into
Closed
Conversation
Extends the per-message identity rebind: when the acting user has a personal GitHub install covering the task's repository, swap the git remote token, GITHUB_TOKEN/GH_TOKEN, and GIT_AUTHOR_*/GIT_COMMITTER_* in the live sandbox via the agentsh env file (re-sourced per command, so no restart), making this turn's commits and PRs theirs. Actors without a covering install keep the previous identity; bot-authored and caller-token runs are never swapped. The github/github_user identity marks make the credential refresh loop resolve the swapped integration instead of the task creator's, keep token-rotation propagation from reverting a swap, and let same-actor messages skip integration resolution entirely. Sandbox liveness is checked before the rotation lock so a dead sandbox never triggers a token mint-and-revoke.
VojtechBartos
force-pushed
the
vojtab/slack-app-per-message-github-identity
branch
from
July 13, 2026 11:16
86e4de7 to
cb3ffdd
Compare
Contributor
🤖 CI reportℹ️ ClickHouse migration SQL — 1 migration(s)ClickHouse migration SQL per cloud environment
|
2 tasks
Member
Author
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Stacked on #69618 (which rebinds the PostHog MCP identity per message). Commits and PRs from the agent sandbox are still authored by whoever created the task, even when a teammate is the one driving the turn — their work lands under someone else's name.
Changes
Extends the per-message rebind to GitHub: when the acting user has a personal GitHub install covering the task's repository, the live sandbox's git remote token,
GITHUB_TOKEN/GH_TOKEN, andGIT_AUTHOR_*/GIT_COMMITTER_*are swapped via the agentsh env file — which the exec wrapper re-sources per command, so the change reaches the agent's latergit/ghcalls (includinggh pr create) with no sandbox restart. The facade'srebind_sandbox_identity_for_usergains the GitHub half; the Slack layer is untouched.Guardrails, since two background systems re-apply GitHub credentials and would otherwise fight a swap:
github_useridentity mark lets same-actor messages skip integration resolution entirely (a DB query and, on a stale repo cache, a paginated GitHub API sync per message otherwise), and it survives swaps — including switching back to the creator.How did you test this code?
Automated only; manual multiplayer verification planned with the queue-workflow dev rollout.
test_sandbox_credentials.py, each pinning a distinct regression: the swap applies token + git author through the shared apply helper in one env write and records both identity marks; actors without a covering install, bot-authored runs, and same-identity messages are skipped; switching back to the creator re-applies their identity; and the creator fast path skips integration resolution on never-swapped runs.Automatic notifications
Docs update
N/A, internal credential mechanics behind the queue-workflow flag.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Authored with Claude Code; split out of a combined MCP+GitHub identity PR so this tasks-owned half reviews independently. Decisions: identity marks live in the tasks cache alongside the MCP one (durable
TaskRun.statestorage is a named follow-up, as is including swapped-to sandboxes in rotation propagation); the swap reusesapply_github_credentials_to_sandboxvia a newextra_envparameter so there is one definition of where a sandbox reads GitHub tokens from; the agentsh env-file mechanism was verified to re-source per command, so no sandbox-side changes were needed.