Skip to content

fix(desktop): preserve streamed reasoning on late fallback - #65432

Closed
rasitakyol wants to merge 2 commits into
NousResearch:mainfrom
rasitakyol:agent/preserve-streamed-reasoning
Closed

fix(desktop): preserve streamed reasoning on late fallback#65432
rasitakyol wants to merge 2 commits into
NousResearch:mainfrom
rasitakyol:agent/preserve-streamed-reasoning

Conversation

@rasitakyol

Copy link
Copy Markdown
Contributor

What does this PR do?

Prevents a late reasoning.available fallback from replacing reasoning that already streamed through reasoning.delta. When no reasoning delta was received, the fallback is still inserted before assistant text. The backend now sends the complete inline reasoning fallback instead of truncating it to 500 characters.

The frontend portion mechanically salvages #47183 onto the current split hook layout while preserving skyc1e's original commit authorship. The additional backend and end-to-end event coverage address #64995's truncation/remount case.

Related Issue

Fixes #64995

Salvages and extends #47183 with original author credit preserved. #64689 remains a separate MoA-reference accumulation fix.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Security fix
  • Documentation update
  • Tests (adding or improving test coverage)
  • Refactor (no behavior change)

Changes Made

  • apps/desktop/src/app/session/hooks/use-message-stream/index.ts: adds an idempotent late-reasoning fallback reducer, preserves the existing reasoning part object, and inserts a fallback before assistant text when no delta arrived.
  • agent/conversation_loop.py: relays complete available reasoning without the 500-character truncation while preserving bounded subagent previews.
  • Desktop and Python regressions cover streamed preservation, no-delta fallback, full payload relay, and subagent preview bounds.

How to Test

  1. Stream more than 500 characters through reasoning.delta, then emit reasoning.available; verify the displayed reasoning text and part identity remain unchanged.

  2. Emit assistant text followed by reasoning.available without prior reasoning deltas; verify reasoning appears before the text.

  3. Run:

    scripts/run_tests.sh tests/run_agent/ tests/agent/test_reasoning_available.py tests/tools/test_delegate.py -q
    PATH=/opt/homebrew/opt/node@22/bin:$PATH npx vitest run --maxWorkers=1
    PATH=/opt/homebrew/opt/node@22/bin:$PATH npm run typecheck
    

Results:

  • Python conversation/delegation coverage: 2,202 passed
  • Desktop Vitest suite on supported Node 22: 1,724 passed, 1 skipped
  • focused desktop event/reducer tests after final rebase: 4 passed
  • desktop TypeScript typecheck passed
  • ESLint, Prettier, Ruff, and git diff --check passed

A parallel full-desktop run exposed an existing cross-file isolation race in src/app/skills/index.test.tsx; the same file passed 3/3 in isolation, and the serial supported-Node run passed the complete suite.

Checklist

Code

Documentation and Housekeeping

  • Documentation update: N/A; no user-facing configuration changed.
  • cli-config.yaml.example: N/A.
  • Architecture/workflow docs: N/A.
  • Cross-platform impact considered; no platform-specific I/O changed.
  • Tool descriptions/schemas: N/A.

Screenshots / Logs

No UI layout changes; regression tests exercise the gateway-event timeline and reasoning-part identity directly.

@rasitakyol
rasitakyol marked this pull request as ready for review July 16, 2026 07:07
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have labels Jul 16, 2026
@rasitakyol rasitakyol closed this Jul 17, 2026
@rasitakyol
rasitakyol deleted the agent/preserve-streamed-reasoning branch July 17, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: reasoning.available replace truncates streamed reasoning to 500 chars, causing thinking disclosure to re-render from scratch

3 participants