Repository navigation
Description
I've modeled an agentic workflow after the test-copilot-create-agent-session workflow. I am encountering an Oauth Token error in that workflow. To troubleshoot I copied and compiled the test-copilot-create-agent-session.md as written, compiled it and dispatched that workflow.
In both cases the workflow runs and progresses through the agent job with no errors but the safe-outputs job fails with the following error
Found 1 create-agent-session item(s)
Task 1: Task description written to /tmp/gh-aw/agent-task-description-1.md
Task 1: Creating agent session with command: gh agent-task create --from-file /tmp/gh-aw/agent-task-description-1.md --base main
/usr/bin/gh agent-task create --from-file /tmp/gh-aw/agent-task-description-1.md --base main
this command requires an OAuth token. Re-authenticate with: gh auth login
In my repository, I have the following action repository environment variables and secrets
- COPILOT_GITHUB_TOKEN: as created via
gh aw secret bootstrap - GH_AW_GITHUB_TOKEN: is a fine-grained token that grants (used in other agentic workflow use cases I've got)
- Contents → Read and write
- Issues → Read and write
- Pull requests → Read and write
I've also attempted to set a custom github-token to a secret I have defined as GH_AW_AGENT_SESSION_TOKEN
create-agent-session:
github-token: ${{ secrets.GH_AW_AGENT_SESSION_TOKEN }}
The value of this secret is gh secret set GH_AW_AGENT_SESSION_TOKEN -a actions --body "$(gh auth token)" which is an attempt address the suggestion in the error output but the workflow still fails with the OAuth Error. I'd prefer to use a fine grained access token rather than an auth token. Looking at the code for create-agent-session I am not sure that I am seeing where the github-token attribute is used when preparing the gh agent-task create command which may be part of the problem in my attempt to set a custom token
https://raw.githubusercontent.com/github/gh-aw/9cbca3cd9be433a23a38e4da332635097fd40251/actions/setup/js/create_agent_session.cjs
but I would also expect the safe output to work without a custom token as the test workflow would imply
Activity
pelikhan commentedon Mar 1, 2026
/scout make sure GH_AW_AGENT_SESSION_TOKEN is the token generated by the compiler
github-actions commentedon Mar 1, 2026
🔍 Scout Research Report
Triggered by
@pelikhanExecutive Summary
The compiler does not generate a secret named
GH_AW_AGENT_SESSION_TOKEN. The default token the compiler uses forcreate-agent-sessionissecrets.COPILOT_GITHUB_TOKEN. The user's custom secret name (GH_AW_AGENT_SESSION_TOKEN) can work as an override, but only if wired correctly in the frontmatter.Click to expand detailed findings
Research Findings
Token Precedence for
create-agent-sessionThe compiler sets
UseCopilotRequestsToken: truefor thecreate-agent-sessionsafe output (seecompiler_safe_outputs_specialized.go:134andcreate_agent_session.go:138). This means the compiled workflow uses:Source:
github_token.go:42-48How the Token Flows to
gh agent-task createIn
create_agent_session.cjs:150-157, theGH_TOKENfor theghCLI is set from:GITHUB_TOKENinside the step is injected byactions/github-scriptfrom itsgithub-token:input. The compiler writes that input as${{ secrets.COPILOT_GITHUB_TOKEN }}by default, or the user's custom token if one is provided.What
GH_AW_AGENT_SESSION_TOKENIs (and Isn't)GH_AW_AGENT_SESSION_TOKENdoes not appear anywhere in the gh-aw codebase — it is purely a user-defined secret name. The compiler has no special awareness of it. For the user's custom token to be used, the frontmatter must explicitly wire it:Without that
github-token:line, the compiled workflow will always fall back tosecrets.COPILOT_GITHUB_TOKEN.Root Cause of the OAuth Error
The
test-copilot-create-agent-session.mdfixture has nogithub-token:override:So the compiled workflow uses
secrets.COPILOT_GITHUB_TOKEN.gh agent-task createrequires an OAuth token; theCOPILOT_GITHUB_TOKENprovisioned bygh aw secret bootstrapis designed for the Copilot engine, but may not satisfy the OAuth requirement forgh agent-task create.The default GitHub Actions
GITHUB_TOKENdefinitely won't work — this is noted explicitly in the code comment:Recommendations
Correct secret to use: Set
COPILOT_GITHUB_TOKEN(not a custom name) with a token that is a valid OAuth token (e.g., a classic PAT withrepoandworkflowscopes, or the output ofgh auth token). This is the secret the compiler generates by default forcreate-agent-session.If using a custom secret name: Wire it explicitly in frontmatter:
Token type requirement:
gh agent-task createrequires an OAuth token with appropriate Copilot permissions. A fine-grained PAT alone (even with contents/issues/PRs read+write) may not have the required Copilot API access — a classic PAT or the result ofgh auth tokenis more likely to work.Key Sources
github_token.go— token precedence logiccreate_agent_session.cjs— runtime token usagecompiler_safe_outputs_specialized.go— step config withUseCopilotRequestsToken: truesafe_outputs_config.go:568-574—github-tokenfield parsingSuggested Next Steps
gh aw secret bootstrapcreates a token that satisfiesgh agent-task create's OAuth requirement.COPILOT_GITHUB_TOKENmust be an OAuth-capable token forcreate-agent-session.test-copilot-create-agent-session.mdtest workflow should include a note or require a correctly scopedCOPILOT_GITHUB_TOKEN.References:
abillingsley commentedon Mar 1, 2026
I don't think scout's analysis is correct but regardless I'd direct focus on the base case of test-copilot-create-agent-session this fails without specifying a
github-tokenso just using the COPILOT_GITHUB_TOKEN. The default COPILOT_GITHUB_TOKEN is a fine grained token not an oauth token so it fails with the same oauth errorpelikhan commentedon Mar 1, 2026
It should be using the same token as assign-to-agent safe output
abillingsley commentedon Mar 1, 2026
I haven't tested that safe output yet is there an example of that one working?
abillingsley commentedon Mar 4, 2026
I recompiled the
test-copilot-create-agent-session(copied below for reference) given recent updatesworkflow.md
compiled workflow
This still fails to invoke
gh agent-task createsuccessfully due to an OAuth Error.The full safeouputs job log is below
abillingsley commentedon Mar 7, 2026
@pelikhan I took some time to dig into this with Opus 4.6, sharing as it may provide further context to someone closer to the internals of gh-aw
Opus Analysis
The Setup
The compiler produces a correct workflow file using
addSafeOutputCopilotGitHubTokenForConfigandgetEffectiveCopilotRequestsTokengh-aw/pkg/workflow/safe_outputs_jobs.go
Lines 941 to 962 in dfe305a
gh-aw/pkg/workflow/github_token.go
Lines 42 to 47 in dfe305a
in the case of the test workflow this sets github-token: ${{ secrets.COPILOT_GITHUB_TOKEN }} as we would expect
the step in the workflow does:
The bug:
gh-aw/actions/setup/js/create_agent_session.cjs
Lines 149 to 157 in dfe305a
The script passes GH_TOKEN to the gh CLI. This works for most gh commands, but gh agent-task create requires an OAuth token — it doesn't accept PATs or GitHub App installation tokens via GH_TOKEN by using the COPILOT_GITHUB_TOKEN (a PAT created during bootstrap of agentic workflows)
Proposed fix should be in create_agent_session.cjs
The script at line 155 sets GH_TOKEN, but the gh agent-task command ignores GH_TOKEN for OAuth-gated endpoints. The fix would need to either:
casanova-21 commentedon Mar 26, 2026
Chiming in here that I'm also running into this problem tonight. I thought it might be due to an outdated version on 0.58 and upgraded to the latest 0.64 and still experienced the same issue.
Copilot's assessment:
"Confirmed — the file on main (even after recompile with v0.64.0) still has:
No GH_TOKEN in env. The gh CLI sees no token and fails with "this command requires an OAuth token."
This is not a version-specific bug — it's how create-agent-session is currently implemented across all compiler versions. The create_agent_session.cjs script shells out to gh agent-task create which needs GH_TOKEN, but the compiler only passes it via github-token (Octokit-only).
Summary: This is a gap in the gh-aw platform's create-agent-session safe output. You should file a bug against github/gh-aw requesting that the compiled Create Agent Session step include GH_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} (or GH_AW_GITHUB_TOKEN) in its env: block. Until that's fixed, create-agent-session won't work."
pelikhan commentedon May 24, 2026
Fixed now.