You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: stream DeepSeek reasoning and coalesce per-step Thoughts disclosures (#234)
After the model swap in #224 (Grok 4.1 → DeepSeek V4 via OpenRouter),
two regressions surfaced when sending default-flow prompts like "Build a
modern, responsive landing page":
1. Two "Thought" disclosures rendered per assistant turn instead of one,
because ToolLoopAgent emits one reasoning part per step (reason → tool
→ reason → text) and groupConsecutiveParts only coalesces tool parts.
2. The UI appeared to freeze for many seconds, then everything dumped
in at once — DeepSeek-via-OpenRouter returns reasoning as a single
non-streamed blob unless the provider's reasoning streaming flag is
explicitly enabled.
Three surgical fixes:
- config/models/{default,cloud}.json: add providerOptions.openrouter.reasoning
to all four byMode entries (enabled:true, effort:low for speed and
effort:medium for quality). Add exclude:true on relatedQuestions and
trendingSuggestions so background calls skip reasoning cost.
- components/research-process-section.tsx: new coalesceReasoningParts
helper hoists all reasoning parts within a segment into one merged
reasoning at the position of the first one. Tool parts keep their
natural position. The existing RenderPart branch renders the merged
part unchanged.
- lib/streaming/create-chat-stream-response.ts: extend the reasoning-strip
gate to cover openrouter:deepseek/* so per-step reasoning_details
metadata isn't replayed to OpenRouter on the next turn (prevents 400s
and silent drops in multi-turn DeepSeek chats).
Tests:
- New coalesce + leaves-single-untouched cases in the existing
research-process-section test (plus updated the 5-reasoning-parts
parent-collapsible test to use 5 distinct tool types — coalescing now
merges 5 reasoning into 1 and would drop totalParts below the
needsParentCollapsible threshold).
- New lib/config/__tests__/load-models-config.test.ts guards the
providerOptions across both default and cloud profiles.
bun lint, bun typecheck, and bun run test (1441/1441) all clean.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments