Objective
Fix the create-agent-session safe output so that when features: copilot-requests: true is set in a workflow, it uses ${{ github.token }} instead of ${{ secrets.COPILOT_GITHUB_TOKEN }}. Also ensure the safe-outputs job receives copilot-requests: write permission in that case.
Context
Ref: #24920 (Problem 1)
The intent of features: copilot-requests: true is to eliminate the need for the COPILOT_GITHUB_TOKEN PAT. However, create-agent-session currently always uses secrets.COPILOT_GITHUB_TOKEN regardless of the feature flag, causing runtime failures when users omit the secret.
Additionally, the safe-outputs job is missing copilot-requests: write permission even when the feature flag is active, so even a correct token substitution would still fail.
Files to Modify
pkg/workflow/github_token.go — extend getEffectiveCopilotRequestsToken() to accept (or check) the copilot-requests feature flag and substitute ${{ github.token }} when it is active
pkg/workflow/safe_outputs_permissions.go — in ComputePermissionsForSafeOutputs(), merge copilot-requests: write into the job permissions when copilot-requests feature flag is active and create-agent-session is present
pkg/workflow/compiler_safe_outputs_specialized.go — update buildCreateAgentSessionStepConfig() to accept and forward a useCopilotRequests bool parameter so the corrected token logic is used
Approach
- In
github_token.go, add a fallback in the token chain so that when the copilot-requests feature flag is true, ${{ github.token }} is returned instead of secrets.COPILOT_GITHUB_TOKEN
- In
safe_outputs_permissions.go, check for the copilot-requests feature flag and add copilot-requests: write to safe-outputs job permissions when the flag is set and the create-agent-session output is configured
- In
compiler_safe_outputs_specialized.go, thread the useCopilotRequests flag through buildCreateAgentSessionStepConfig() so the correct token expression is used in the compiled YAML
Acceptance Criteria
Generated by Plan Command for issue #24920 · ● 142.2K · ◷
Objective
Fix the
create-agent-sessionsafe output so that whenfeatures: copilot-requests: trueis set in a workflow, it uses${{ github.token }}instead of${{ secrets.COPILOT_GITHUB_TOKEN }}. Also ensure the safe-outputs job receivescopilot-requests: writepermission in that case.Context
Ref: #24920 (Problem 1)
The intent of
features: copilot-requests: trueis to eliminate the need for theCOPILOT_GITHUB_TOKENPAT. However,create-agent-sessioncurrently always usessecrets.COPILOT_GITHUB_TOKENregardless of the feature flag, causing runtime failures when users omit the secret.Additionally, the safe-outputs job is missing
copilot-requests: writepermission even when the feature flag is active, so even a correct token substitution would still fail.Files to Modify
pkg/workflow/github_token.go— extendgetEffectiveCopilotRequestsToken()to accept (or check) thecopilot-requestsfeature flag and substitute${{ github.token }}when it is activepkg/workflow/safe_outputs_permissions.go— inComputePermissionsForSafeOutputs(), mergecopilot-requests: writeinto the job permissions whencopilot-requestsfeature flag is active andcreate-agent-sessionis presentpkg/workflow/compiler_safe_outputs_specialized.go— updatebuildCreateAgentSessionStepConfig()to accept and forward auseCopilotRequests boolparameter so the corrected token logic is usedApproach
github_token.go, add a fallback in the token chain so that when thecopilot-requestsfeature flag istrue,${{ github.token }}is returned instead ofsecrets.COPILOT_GITHUB_TOKENsafe_outputs_permissions.go, check for thecopilot-requestsfeature flag and addcopilot-requests: writeto safe-outputs job permissions when the flag is set and thecreate-agent-sessionoutput is configuredcompiler_safe_outputs_specialized.go, thread theuseCopilotRequestsflag throughbuildCreateAgentSessionStepConfig()so the correct token expression is used in the compiled YAMLAcceptance Criteria
features: copilot-requests: trueis set, compiledcreate-agent-sessionstep uses${{ github.token }}not${{ secrets.COPILOT_GITHUB_TOKEN }}copilot-requests: writewhen the feature is active andcreate-agent-sessionis presentsecrets.COPILOT_GITHUB_TOKEN)make agent-finishpassesRelated to Bugfix: GitHub Token S2S TTL and Actions Timeouts #24920