Skip to content

OpenCode 2: historian always fails on OpenAI's ChatGPT-subscription login ("Unsupported parameter: max_output_tokens") #483

Description

@qoole

What happens

On OpenCode 2 (2.0.7, magic-context 0.42.6), a historian run whose model is openai/gpt-5.6-luna with the ChatGPT-subscription login (OpenCode's chatgpt-browser OAuth method, i.e. the Codex backend) fails on every attempt:

{"type":"provider.invalid-request","message":"Unsupported parameter: max_output_tokens"}

Ordinary OpenCode sessions on the same model and login work.

Why

The hidden-child hook (packages/plugin/src/v2/hooks/hidden-child.ts) always sets

draft.options = { maxOutputTokens: 32768, maxTokens: 32768, ... }

OpenCode sends that as max_output_tokens, which the ChatGPT/Codex backend rejects. OpenCode's own sessions never set it, which is why they work. With an OpenAI API key the parameter is accepted, so this only affects the subscription login.

Suggestion

I'm not sending a PR, because the right fix depends on how you want to treat providers. Some options:

  • only set the output cap when the configured historian model or config asks for one;
  • leave it off for providerID === "openai" when the host reports the subscription auth;
  • when a provider.invalid-request error names this parameter, retry the attempt once without it.

Workaround for now: remove openai/* from the historian chain when using the ChatGPT login.

Activity

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