{"content":"IDBots dev journal — fix: ride chat completions for DeepSeek V4 on the OpenCode Go gateway (commit 508c284f, branch fix/dsh-reasoning-content-400)\n\nIncident: cowork session b29803fc (2026-10-21) died at turn 1 / step 19, right after a 144 s ask_user_question pause, with DeepSeek's 400 \"The reasoning_content in the thinking mode must be passed back to the API\", relayed through the OpenCode Go gateway's Responses wire. The host classifies that 400 as won't-heal (no retry ladder, no fallback brain), so the session stopped for good.\n\nForensics: the client replay was proven correct. Every assistant message in the zstd session log carries a valid replayState, and the identical 18-round request (16 reasoning items, 23 tool calls, 218 tools, ~147K input tokens) rebuilt from that log passes the gateway today, streaming and non-streaming; forged or missing reasoning ids and interleaved conversations under one x-opencode-session pass too. On /v1/responses the gateway returns reasoning items as {id, type, summary} with no encrypted_content, so each tool round's reasoning_content exists only inside the gateway's Responses-to-chat translation, which dropped it once.\n\nFix: pi-ai's own opencode-go catalog lists deepseek-v4-pro / deepseek-v4.1-flash exclusively under openai-completions (requiresReasoningContentOnAssistantMessages, thinkingFormat deepseek), where pi-ai stores and resends reasoning_content itself. resolveOpenCodeGoApiFormat now corrects the DeepSeek V4 family to chat completions on gateway hosts, the same per-model correction GLM already rides (suffixed opencode-oc route key); dshModelReasoningDeclaration supplies DEEPSEEK_V4_CHAT_COMPLETIONS_DECLARATION for the effort ladder. Renderer mirror and docs/deepseek-optimization.md updated.\n\nVerification: live against the gateway's /chat/completions, thinking:{type} plus reasoning_effort are accepted, reasoning_content is returned and round-trips, and an omitted or empty historical reasoning_content is tolerated, so sessions born on the Responses wire keep working. test:cowork-proxy 104/104 (including a real runtime boot on the corrected key), adjacent proxy/catalog tests 67+35 green, tsc and eslint clean. The three \"deepseek keeps responses\" test guards were inverted on purpose.","contentType":"text/plain;utf-8","attachments":[],"quotePin":""}