Skip to content

github run: agent input from action.yml is ignored by the binary #21730

@wewelll

Description

@wewelll

Bug Description

The agent input defined in github/action.yml is set as the AGENT environment variable, but the opencode github run binary command (packages/opencode/src/cli/cmd/github.ts) never reads process.env.AGENT.

This means the agent: input in GitHub Action workflows has no effect — the session always falls back to default_agent from config, or "build" if unset.

Steps to Reproduce

  1. Configure a GitHub Action workflow with a custom agent:

    - uses: anomalyco/opencode/github@latest
      with:
        model: opencode/gpt-5.4
        agent: on-call  # <-- This is ignored
  2. The action.yml correctly maps this to an env var:

    env:
      AGENT: ${{ inputs.agent }}
  3. But github.ts line 943 explicitly omits the agent:

    // agent is omitted - server will use default_agent from config or fall back to "build"
  4. The session runs under "build" regardless of what agent: was set to.

Expected Behavior

The agent input should be passed through to SessionPrompt.prompt() so the session uses the specified agent and its tool permissions.

Actual Behavior

The AGENT env var is set but never consumed. The session always uses the default agent ("build"), which means agent-specific tool permissions (e.g., datadog_*: true on an on-call agent) are never applied.

Impact

This is a silent failure — the workflow appears to work, but the agent doesn't have access to the MCP tools it needs. In our case, an on-call agent configured with Datadog access was running as build with Datadog tools denied, causing it to fall back to manual investigation methods (grep, curl, etc.) instead of using the Datadog MCP tools.

Suggested Fix

In packages/opencode/src/cli/cmd/github.ts, the chat() function should read process.env.AGENT and pass it to SessionPrompt.prompt():

const agent = process.env["AGENT"] || undefined

const result = await SessionPrompt.prompt({
  sessionID: session.id,
  messageID: MessageID.ascending(),
  variant,
  agent,  // <-- pass the agent
  model: { providerID, modelID },
  parts: [ ... ],
})

Workaround

Setting "default_agent": "on-call" in OPENCODE_CONFIG_CONTENT env var overrides the config-level default and works around this issue.

References

  • github/action.yml — sets AGENT env var from input
  • packages/opencode/src/cli/cmd/github.ts line 943 — agent omitted comment
  • packages/opencode/src/session/prompt.ts line 953 — input.agent || defaultAgent() fallback

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions