Skip to content

opencode run hangs forever on API errors (breaks CLI/automation integrations) #8203

Closed

Description

@EivMeyer

Bug Description

When opencode run encounters an API error (e.g., 429 rate limit), it logs the error but never exits - it hangs indefinitely. This breaks any CLI tool or automation system that spawns opencode as a subprocess.

Reproduction

# With an expired/rate-limited account:
timeout 30 opencode run "what is 1+1"
# Result: hangs for 30 seconds, exit code 124 (timeout)

Expected Behavior

opencode should fail fast with a non-zero exit code and clear error message:

Error: API rate limited (429). Please check your subscription status.
Exit code: 1

Actual Behavior

opencode logs the error internally but continues running forever:

ERROR service=llm error={"statusCode":429,...} 
# Then hangs indefinitely - no exit, no output to user

Impact

This breaks integrations like zeroshot which spawn CLI tools as subprocesses:

// zeroshot spawns opencode
exec('opencode run "task"', (error, stdout) => {
  // This callback NEVER fires because opencode never exits
});

Workaround: We've added timeouts to our subprocess calls, but the real fix should be in opencode.

Environment

  • opencode version: 1.1.16
  • OS: Linux (Ubuntu 22.04)
  • Auth: OpenAI OAuth

Suggested Fix

In the error handling path, ensure the process exits with non-zero code:

if (response.status === 429) {
  console.error('Error: API rate limited. Check subscription status.');
  process.exit(1);  // <-- Currently missing
}

Or more generally: any unrecoverable API error should cause opencode run to exit, not hang.

Activity

  1. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

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

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

  2. ucirello commented on Jan 13, 2026

    @ucirello
    Contributor

    And a variant of this problem is when the LLM messes up a MCP tool call, it also doesn't return control the proper way.

  3. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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