Skip to content

Scheduled jobs fail: launchd plist missing API key environment variables #12

Description

@andrei-hasna

Bug

Scheduled jobs fail with Model not found / ProviderModelNotFoundError because the generated launchd plist only injects PATH into EnvironmentVariables — the OPENCODE_API_KEY is missing.

When launchd spawns the supervisor, the process has a minimal environment with no API key, so opencode can't authenticate with any provider through the opencode proxy.

Where

src/index.ts ~line 1071 — the plist template:

<key>EnvironmentVariables</key>
<dict>
    <key>PATH</key>
    <string>${enhancedPath}</string>
</dict>

Only PATH is injected. The OPENCODE_API_KEY from the user's session is not captured or forwarded.

Expected

At job creation time, the scheduler should capture OPENCODE_API_KEY from the current environment and inject it into the plist EnvironmentVariables dict so the supervisor can authenticate when running opencode.

Repro

  1. opencode (authenticated via opencode.ai)
  2. /schedule 1m "say hello"
  3. Job is created, launchd plist written
  4. Next minute: Model not found because OPENCODE_API_KEY is missing from launchd env

Workaround

Manually edit the plist to add:

<key>OPENCODE_API_KEY</key>
<string>your-key</string>

Then launchctl unload/load the plist.

Environment

  • opencode 1.3.2
  • opencode-scheduler 1.3.0
  • macOS (launchd)

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