Repository navigation
Conversation
The "Revoke app token" step keys off steps.run.outputs.github_token, but run.ts only set that output in its finally block. A cancelled run can leave Bun running past the end of its step without ever reaching the finally, so the output was never written, revocation was skipped, and the app token stayed valid. setOutput appends to $GITHUB_OUTPUT synchronously, so publishing the token right after setupGitHubToken() succeeds puts it on disk before anything later can be interrupted. The finally block still sets it again, keeping it the last value written on paths that complete. Fixes part of anthropics#2111 (the token-output half; stopping the session on cancel is not covered here).
ant-kurt
approved these changes
Nov 23, 2026
This branch has not been deployed
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.
Summary
Publishes the
github_tokenoutput as soon as the token is set up insrc/entrypoints/run.ts, instead of only in thefinallyblock.The "Revoke app token" step keys off
steps.run.outputs.github_token. When a run was cancelled, the runner signalled the step's bash rather than Bun, Bun kept running past the end of the step, and thefinallyblock — whose last statement was the onlysetOutput("github_token", …)on the session path — never ran. The output stayed empty, the revoke step was skipped, and the app token stayed valid.core.setOutputappends to$GITHUB_OUTPUTsynchronously, so writing the token right aftersetupGitHubToken()succeeds puts it on disk before anything later can be interrupted. Thefinallyblock still sets it again, so it remains the last value written on every path that completes — including over anything the session itself wrote to$GITHUB_OUTPUTduring the run.This is fix direction (1) from #2111. It is a one-call move in one file, plus tests.
Fixes the token-revocation half of #2111.
Not covered
exec, signal handling, process-tree cleanup). This PR does not stop Claude or its MCP servers from running past a cancel; it only makes sure the token output exists so the token gets revoked.github_tokenentry to$GITHUB_OUTPUTcould shadow the early value (the runner takes the last value for a repeated key). Every path that completes is covered by thefinallyre-write.Disclosure
PR #2112 by @mhegazy already works on this issue and takes the other direction: both actions start Bun with
exec, a SIGINT/SIGTERM handler stops the process tree, restores files, and writes the outputs. It covers more of the issue than this PR does. If the maintainers prefer #2112, closing this PR is the right call — I'm opening it because the early output is a smaller, independently useful change, not because it supersedes #2112.Test plan
test/github-token-output.test.ts, following the subprocess pattern oftest/agent-mode-moderation.test.ts: it runs the real entrypoint against a local fake GitHub API with a real$GITHUB_OUTPUTfile, leaves the first API call after token setup unanswered (the process is alive mid-run and can never reach itsfinally, the local shape of an orphaned cancelled run), then SIGKILLs it.main: the test fails — the output file stays empty for the full 10 s poll, because the token output only exists in the unreachablefinally.github_tokenvalue.bun test: 1484 pass, 0 fail.tsc --noEmitandprettier --checkclean.finally); the runner-side behaviour it relies on — outputs of a cancelled step being read by thealways()revoke step — is the same mechanism thefinallywrite already depended on.