Skip to content

gterm: support OpenAI reasoning models such as gpt-6-luna - #47

Open
seonheum wants to merge 1 commit into
madeye:mainfrom
seonheum:feature/gpt-6-reasoning-models
Open

seonheum wants to merge 1 commit into
madeye:mainfrom
seonheum:feature/gpt-6-reasoning-models

Conversation

@seonheum

Copy link
Copy Markdown

Summary

Setting the OpenAI model to gpt-6-luna currently fails: both autocomplete and the AI settings connectivity test get HTTP 400 because GPT-6 models (like gpt-5 and the o-series) are reasoning models that reject temperature.

This PR makes gterm send the right parameters for those models:

  • New OpenAIModelTraits (Sources/LLM/LLMProvider.swift) detects reasoning models by model id: o1/o3/o4, gpt-5* (except the non-reasoning gpt-5-chat-*), gpt-6*. It also understands OpenRouter's openai/ prefix.
  • For those models the streaming ChatQuery omits temperature and sends the lowest reasoning_effort the family accepts, so shell completions stay fast and don't burn reasoning tokens:
    • gpt-6*, gpt-5.1+ → none
    • gpt-5 → minimal
    • o-series → low
  • ProviderRequestFactory.body mirrors this (max_completion_tokens + reasoning_effort instead of max_tokens + temperature).
  • Non-OpenAI vendors (DeepSeek, GLM, Kimi, MiniMax, Groq) and classic models (gpt-4o-mini, gpt-4.1) are unchanged.
  • The OpenAI and OpenRouter presets now default to gpt-6-luna / openai/gpt-6-luna (cheaper than gpt-4o-mini at $0.10 / $0.50 per 1M tokens). Existing saved profiles are not modified.

gpt-6-luna still supports Chat Completions (model docs), so no migration to the Responses API is needed.

Possibly related: #38 (reasoning output showing up in autocomplete). With reasoning_effort: none, OpenAI reasoning models should no longer produce reasoning text, but I haven't confirmed that this resolves the case in that issue.

Verification

  • gtermTests: 112 tests pass, including the new OpenAIModelTraitsTests (model detection, effort selection, request body shape) and a preset default test.
  • Unsigned simulator build (CODE_SIGNING_ALLOWED=NO) succeeds.
  • Built and installed on a physical iPhone 12 mini.

🤖 Generated with Claude Code

GPT-6 models (and gpt-5 / o-series) reject `temperature` with HTTP 400,
so setting the model to gpt-6-luna broke both autocomplete and the
connectivity test. Detect reasoning models by id (including OpenRouter's
"openai/" prefix), drop `temperature` for them, and send the lowest
`reasoning_effort` the family accepts so shell completions stay fast.
Other OpenAI-compatible vendors are unaffected.

Default the OpenAI and OpenRouter presets to gpt-6-luna.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant