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.
What happens
On OpenCode 2 (2.0.7, magic-context 0.42.6), a historian run whose model is
openai/gpt-5.6-lunawith the ChatGPT-subscription login (OpenCode'schatgpt-browserOAuth method, i.e. the Codex backend) fails on every attempt:Ordinary OpenCode sessions on the same model and login work.
Why
The hidden-child hook (
packages/plugin/src/v2/hooks/hidden-child.ts) always setsOpenCode 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:
providerID === "openai"when the host reports the subscription auth;provider.invalid-requesterror names this parameter, retry the attempt once without it.Workaround for now: remove
openai/*from the historian chain when using the ChatGPT login.