Skip to content

[FEATURE]: expose coding agent marker to shell commands #34065

Closed

Description

@davidmokos

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Shell commands launched by opencode should expose a generic environment marker so downstream CLIs can detect that they are running under a coding agent.

Set OPENCODE=1 for shell tool child processes. This mirrors the simple agent-marker convention used by other coding assistants and does not expose session-specific data.

This is narrower than #15739, which asks for session/tool correlation values like OPENCODE_SESSION_ID. This request is only for a boolean opencode agent marker.

Activity

  1. leocagli commented on Jun 26, 2026

    @leocagli

    Hi, I'd like to work on exposing the coding agent environment marker in the shell tool. I can add an OPENCODE_AGENT (or similar) environment variable that the shell tool sets when running inside an agent context, following the pattern used by other coding assistant tools. Could you assign me?

  2. github-actions commented on Jun 26, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • This appears to be a feature request but does not use the Feature Request template. The title should start with [FEATURE]: and the issue should include the required verification checkbox confirming the feature hasn't been suggested before, along with a structured description of the enhancement.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. davidmokos commented on Jun 26, 2026

    @davidmokos
    Author

    Feel free to review this: #34062

  4. changed the title [-]Shell tool should expose coding agent environment marker[/-] [+][FEATURE]: expose coding agent marker to shell commands[/+] on Jun 26, 2026
  5. github-actions commented on Jun 26, 2026

    @github-actions
    Contributor

    Thanks for updating the issue — it now follows the feature request template and clearly explains the request. The needs:compliance label has been removed.

  6. dylbarne commented on Jul 5, 2026

    @dylbarne

    (I was about to post as a new Issue myself, but saw this was essentially the same request, just reposting what I was about to create to reiterate demand for this feature functionality if helps with visibility/priority for repo maintainers etc.)


    Title:
    [FEATURE]: Set OPENCODE_CODING_AGENT env var to mark OpenCode agent process
    Description:
    Similar to what was previously requested/implemented for Pi earendil-works/pi#2868 -> earendil-works/pi@6101583 set some environment variable to signify OpenCode agent process (suggestion OPENCODE_CODING_AGENT)

    for my usecase specifically is related to https://github.com/Dicklesworthstone/destructive_command_guard/blob/main/docs/agents.md#supported-agents but I could see this being generally useful to other customizations/plugins etc.

  7. complynx commented on Aug 4, 2026

    @complynx

    The cross-agent convention for this marker is now AI_AGENT: https://github.com/vercel/vercel/tree/main/packages/detect-agent#the-ai_agent-standard

    For OpenCode, the proposed value would be AI_AGENT=opencode on shell/tool subprocesses. A non-empty value supplied by a wrapper should be preserved so the outer agent can identify itself.

    This complements any OpenCode-specific variables rather than replacing them. It should remain advisory only—not telemetry, authentication, authorization, sandboxing, or a trust boundary. I initially filed #40441 with this naming detail before finding this thread; I am closing that issue as a duplicate and consolidating the proposal here.

  8. rekram1-node commented on Sep 29, 2026

    @rekram1-node
    Collaborator

    Implemented by #51975: shell-tool commands now receive OPENCODE=1 and AGENT=1, with AI_AGENT defaulting to opencode unless an outer agent supplied a marker. This is scoped to the shell tool, not human PTY terminals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions