[FEATURE]: create and expose model-id environment variables for bash from CLI #7482

Open
opened 2026-02-16 18:07:19 -05:00 by yindo · 3 comments
Owner

Originally created by @bdwelle on GitHub (Jan 24, 2026).

Originally assigned to: @thdxr on GitHub.

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

I have shell scripts and other code that runs from opencode (agents, skills, and tools) that need to be aware of which model the user has selected, for model-aware workflows.

For one, I want to be able to compare content generated by different models, and include model id / name in frontmatter.

Having the id of the currently selected model available also enables patterns like this -- using the SDK to query whatever model the user currently has selected in the TUI:

    const result = await opencodeClient.session.prompt({
      path: { id: session.data.id },
      body: {
        model: {
          providerID: process.env.OPENCODE_PROVIDER_ID,
          modelID: process.env.OPENCODE_MODEL_ID,
        },
        parts: [
          {
            type: "text",
            text: prompt,
          },
        ],
      },
    });

I see a few other feature requests that could be solved by this:
#10453
#10247
#6350
#9065
#9292
#7492

Originally created by @bdwelle on GitHub (Jan 24, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request I have shell scripts and other code that runs from opencode (agents, skills, and tools) that need to be aware of which model the user has selected, for model-aware workflows. For one, I want to be able to compare content generated by different models, and include model id / name in frontmatter. Having the id of the currently selected model available also enables patterns like this -- using the SDK to query whatever model the user currently has selected in the TUI: ``` const result = await opencodeClient.session.prompt({ path: { id: session.data.id }, body: { model: { providerID: process.env.OPENCODE_PROVIDER_ID, modelID: process.env.OPENCODE_MODEL_ID, }, parts: [ { type: "text", text: prompt, }, ], }, }); ``` I see a few other feature requests that could be solved by this: #10453 #10247 #6350 #9065 #9292 #7492
yindo added the discussion label 2026-02-16 18:07:19 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 24, 2026):

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

  • #10247: Add a variable {CURRENT_MODEL} for commands - directly requests exposing current model name to commands, same goal using different terminology
  • #9065: Add model identity info to system prompt - related feature that adds model awareness to prompts
  • #9292: Expose session context to child processes via environment variables - uses similar environment variable mechanism for other metadata
  • #7492: Primary agents lack identity awareness - related identity awareness issue for agents

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 24, 2026): This issue might be a duplicate of existing issues. Please check: - #10247: Add a variable {CURRENT_MODEL} for commands - directly requests exposing current model name to commands, same goal using different terminology - #9065: Add model identity info to system prompt - related feature that adds model awareness to prompts - #9292: Expose session context to child processes via environment variables - uses similar environment variable mechanism for other metadata - #7492: Primary agents lack identity awareness - related identity awareness issue for agents Feel free to ignore if none of these address your specific case.
Author
Owner

@bdwelle commented on GitHub (Jan 24, 2026):

I submitted a draft PR 10451 - create and expose model-id environment variables for bash from CLI that would provide a solution for this feature request.

@bdwelle commented on GitHub (Jan 24, 2026): I submitted a draft [PR 10451 - create and expose model-id environment variables for bash from CLI](https://github.com/anomalyco/opencode/pull/10451) that would provide a solution for this feature request.
Author
Owner

@bdwelle commented on GitHub (Jan 28, 2026):

Hi @thdx

I'm trying to figure out if this would be a good addition to opencode. I've been using this on my own dev branch for a couple of weeks now and it's providing the functionality I'm looking for. As noted above, I think this feature would also address several other existing feature requests. I made a draft PR. Any chance you could have a look and let me know what you think?

🙏🏻

@bdwelle commented on GitHub (Jan 28, 2026): Hi @thdx I'm trying to figure out if this would be a good addition to opencode. I've been using this on my own dev branch for a couple of weeks now and it's providing the functionality I'm looking for. As noted above, I think this feature would also address several other existing feature requests. I made a draft PR. Any chance you could have a look and let me know what you think? 🙏🏻
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7482