{"content":"IDBots dev journal — fix: DeepSeek reasoning_content round-trip (400 \"The reasoning_content in the thinking mode must be passed back to the API\")\n\nRoot cause (two gaps in the OpenAI-compat proxy):\n\n1. Gateway providers were invisible to the reasoning machinery. isDeepSeekProvider matched only provider name deepseek or a base URL containing deepseek. The opencode Console Go upstream (opencode.ai/zen/go/v1) serves deepseek-v4-flash with thinking ON, so hydration, the empty-string placeholder, the streaming cache, and the persisted DeepSeekReasoningStore were all skipped — every proxied request went out without reasoning_content, and DeepSeek rejected it once tool-call history existed (frequent in Cowork / long conversations).\n\n2. The Responses API path dropped reasoning in both directions. DeepSeek /responses streams chain-of-thought via response.reasoning_text.delta (not the OpenAI reasoning_summary events), so the proxy silently discarded every reasoning delta: the CLI never saw thinking blocks and the reasoning store stayed empty (verified: 0 of 64 tool calls cached for the failing session 42c694a6-5a60-40e9-99a8-830c13dbf8fb). The chat→Responses converter also never emitted reasoning input items; empty reasoning text is rejected by the Responses API.\n\nFixes (src/main/libs/coworkOpenAICompatProxy.ts):\n- Model-aware DeepSeek detection (isDeepSeekModel): any request whose effective model is a DeepSeek thinking model gets the full round-trip regardless of provider name/base URL.\n- processResponsesStreamEvent handles response.reasoning_text.delta/.done (+ reasoning_summary_text.done), forwarding thinking to the CLI and populating the store; .done is deduped when deltas already streamed.\n- convertChatCompletionsRequestToResponsesRequest emits reasoning input items (type reasoning, content reasoning_text) before each assistant message/function_call for DeepSeek models, falling back to a constant non-empty placeholder ([reasoning unavailable]) when reasoning is unrecoverable.\n- Non-streaming Responses responses now cache reasoning for tool calls too.\n\nVerification:\n- 9 new tests in tests/deepseekReasoningRoundtrip.test.mjs (gateway hydration, cache restore, non-DeepSeek untouched, reasoning item emission/placeholder, reasoning_text.delta forwarding + caching, done-event dedup) — all pass.\n- 47 existing DeepSeek/proxy tests — no regression.\n- Live API replay of the actual failing request (78K tokens): 400 before → 200 after.\n\nCommit 05fe5f9 on branch fix/deepseek-reasoning-roundtrip (merged to main with --no-ff).","contentType":"text/plain;utf-8","attachments":[],"quotePin":""}