Skip to content

fix: route GPT 5.6 Luna to Responses API + tool call flush + reasoning (#93) - #97

Merged
ltmoerdani merged 2 commits into
mainfrom
fix/issue-93-gpt56-luna-routing
Aug 2, 2026
Merged

fix: route GPT 5.6 Luna to Responses API + tool call flush + reasoning (#93)#97
ltmoerdani merged 2 commits into
mainfrom
fix/issue-93-gpt56-luna-routing

Conversation

@ltmoerdani

Copy link
Copy Markdown
Owner

Summary

Fix GPT 5.6 Luna on OpenCode Go — model was unusable in agent mode (tool calling) and reasoning/thinking was not working.

Root Causes Found

# Root Cause Fix
1 Routing wrong — GPT 5.6 Luna sent to chat-completions, but OpenCode Go docs require Responses API () Route all GPT models to Responses API
2 Tool calls not flushed — gateway sends finish_reason: null on final chunk instead of "tool_calls"; extractor only flushed on exact match Flush pending tool calls when finish_reason is null + calls exist
3 Reasoning payload missingbuildResponsesRequestBody() did not include thinkingPayload Add thinkingPayload to Responses API body
4 Reasoning format wrong — sent { reasoning_effort } (chat-completions format) instead of { reasoning: { effort } } (Responses API format) Fix to nested Responses API format
5 Model not registeredgpt-5.6-luna missing from metadata and fallback lists Add to Go vendor metadata + fallbackModels

Changes

  • src/routing.ts — Route ALL GPT models to Responses API (per OpenCode Go docs)
  • src/streaming.ts — Flush tool calls when finish_reason is null; add diagnostic logging for empty responses
  • src/thinking.ts — Add openai thinking family (off/low/medium/high/xhigh); fix reasoning payload to nested format
  • src/extension.ts — Add gpt-5.6-luna to Go metadata + fallback; add responsesUrl to Go provider; add openai to thinking settings + picker; add thinkingPayload to buildResponsesRequestBody()
  • src/metadata.ts — Add gpt-5.6-luna limits (1.05M context, 128K output) + snapshot
  • docs/issues/41-20260803-gpt56-luna-routing-fix.md — Full investigation doc

Testing

  • npm run compile passes
  • ✅ Simple chat with gpt-5.6-luna works (textChars=238)
  • ✅ Agent mode tool calls now flush correctly (verified via diagnostic SSE logs)
  • ✅ Reasoning payload sent in correct Responses API format

Verification

Verified that OpenCode Go docs require gpt-5.6-luna on /v1/responses endpoint:

| GPT 5.6 Luna | gpt-5.6-luna | https://opencode.ai/zen/go/v1/responses | @ai-sdk/openai |

Fixes #93

Root cause of thinking not showing:

1. OpenCode Go docs require gpt-5.6-luna on /v1/responses endpoint,
   NOT chat-completions. Our routing was sending to chat-completions.

2. Reasoning payload format was wrong: we sent { reasoning_effort: "medium" }
   (chat-completions format) instead of { reasoning: { effort: "medium" } }
   (Responses API format).

3. buildResponsesRequestBody() did not include thinkingPayload at all.

Fixes:
- Route ALL GPT models to Responses API (per OpenCode Go docs)
- Fix reasoning payload to nested format: { reasoning: { effort } }
- Add thinkingPayload to buildResponsesRequestBody()
- Add openai thinking family (off/low/medium/high/xhigh)
- Flush tool calls when finish_reason is null (gateway bug)
- Add diagnostic logging for empty responses

Fixes #93
@ltmoerdani
ltmoerdani merged commit c7929e9 into main Aug 2, 2026
2 checks passed
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.

OpenCode Go / Gpt 5.6 Luna not working

1 participant