Skip to content

opencode subprocess is forced to OPENCODE_CONFIG_CONTENT="{}", hiding all user providers/models #4239

Description

@jonocodes

Summary

When t3code launches the opencode CLI as a provider subprocess, it unconditionally sets OPENCODE_CONFIG_CONTENT="{}" in the child environment. Because this is written after spreading the inherited environment, it clobbers any value the user (or their shell/systemd unit) provided. The result: opencode ignores the user's opencode.json / inherited OPENCODE_CONFIG_CONTENT, so no custom providers or models appear in the t3code UI.

Root cause

apps/server/src/provider/opencodeRuntime.ts (default branch, and v0.0.28 stable):

const OPENCODE_EMPTY_CONFIG_CONTENT = "{}";
// ...
env: {
  ...input.environment,
  OPENCODE_CONFIG_CONTENT: OPENCODE_EMPTY_CONFIG_CONTENT,
},

The explicit key wins over the spread, so an inherited OPENCODE_CONFIG_CONTENT can never take effect.

Steps to reproduce

  1. Configure opencode with custom providers/models in ~/.config/opencode/opencode.json (verify opencode on its own shows them).
  2. Launch the same opencode provider through t3code (t3 serve).
  3. Open the model picker in the t3code UI.

Expected: the providers/models from the user's opencode config are available.

Actual: none appear — opencode runs with an empty config ({}).

Suggested fix

Only default OPENCODE_CONFIG_CONTENT to empty when it isn't already provided, e.g.:

env: {
  ...input.environment,
  ...(process.env.OPENCODE_CONFIG_CONTENT
    ? {}
    : { OPENCODE_CONFIG_CONTENT: OPENCODE_EMPTY_CONFIG_CONTENT }),
},

(or make the empty default opt-in). Happy to open a PR.

Environment

  • t3code v0.0.28 (also present on the default branch / 0.0.29-nightly.* as of 2026-07-21)
  • Provider: opencode (headless t3 serve)

Note

This is distinct from #2797 (closed as completed): that report's log pointed at generateThreadTitle (the separate text-generation model), whereas this is the opencode conversation subprocess env in opencodeRuntime.ts, which is still present in current source.

Activity

  1. nathnael-desta commented on Jul 26, 2026

    @nathnael-desta

    I can confirm this issue and provide an additional deterministic reproduction.

    Area

    apps/server

    Steps to reproduce

    1. Run T3 Code with OpenCode configured as a provider.
    2. Confirm that OpenAI/GPT models initially appear in the T3 Code model picker.
    3. Keep T3 Code running for approximately 30 minutes.
    4. Open the model picker again.

    Expected behavior

    OpenAI models should remain available while OpenCode reports that the OpenAI provider is connected.

    Actual behavior

    The OpenAI/GPT models disappear from T3 Code's model picker after a scheduled provider refresh.

    I monitored the OpenCode server started by T3 Code every 10 seconds while reproducing the problem. When the models disappeared:

    • OpenCode remained healthy.
    • openai remained in the connected-provider list.
    • The OpenCode server continued returning all 13 OpenAI models.
    • opencode models openai continued listing the models.
    • No corresponding OpenAI authentication or connection failure occurred.

    At approximately the same time, T3 Code rewrote ~/.t3/caches/opencode.json. Its checkedAt value was 2026-07-26T08:20:39.938Z. The refreshed cache reported only three upstream providers and omitted all OpenAI models.

    This indicates that the scheduled T3 Code discovery refresh is producing a different inventory from the live OpenCode server and replacing the previously valid cached inventory.

    Impact

    Major degradation or frequent failure.

    Version and environment

    • OS: Linux, Ubuntu 24.04
    • T3 Code: 0.0.29-nightly.20260725.899
    • T3 Code commit: 5719e8ac4020
    • OpenCode: 1.18.5
    • Provider: OpenAI through OpenCode OAuth

    Relevant diagnostic output

    Before and after the models disappeared:
    
    {"openai_models":13,"openai_connected":true}
    
    OpenCode health endpoint:
    
    {"healthy":true,"version":"1.18.5"}
    

    Workaround

    Restarting T3 Code temporarily restores the models. They disappear again after a later provider refresh.

  2. rodrgds commented on Aug 2, 2026

    @rodrgds

    The custom provider and models I have appear in T3 Code, but requests fail with Authentication Error: No api key passed in, while the same model works directly in OpenCode.

  3. added a commit that references this issue on Aug 15, 2026
    7d0858e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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