Skip to content

feat: gateway reasoning visibility modes#1214

Closed
raulvidis wants to merge 11 commits into
NousResearch:mainfrom
raulvidis:feat/reasoning-clean
Closed

feat: gateway reasoning visibility modes#1214
raulvidis wants to merge 11 commits into
NousResearch:mainfrom
raulvidis:feat/reasoning-clean

Conversation

@raulvidis

@raulvidis raulvidis commented Mar 13, 2026

Copy link
Copy Markdown

Summary

  • Per-chat reasoning visibility via /reasoning [off|on|stream]: off disables reasoning at the provider level, on enables reasoning silently (for future use), stream shows live italicized reasoning previews that auto-delete when the final response arrives.
  • Inline keyboard picker on Telegram — /reasoning with no argument shows an Off / On / Stream button row; callback queries route through the gateway command handler.
  • Reasoning streaming infrastructurereasoning_callback on AIAgent surfaces reasoning deltas from both chat completions and Codex Responses API streams. Gateway consumes these via an async queue + background task that edits a single preview message.
  • Edit failure recovery — when Telegram rejects an edit (e.g. "message is not modified"), the preview is deleted and a fresh message is sent instead of silently dropping updates.
  • Typing metadatasend_typing now accepts metadata so typing indicators go to the correct forum thread.

Changed files

File Key changes
run_agent.py reasoning_callback param, _merge_stream_reasoning(), _run_streaming_chat_completion() for reasoning deltas, last_reasoning in result dict
gateway/run.py /reasoning command handler, _resolve_session_reasoning_config(), send_reasoning_updates() background task, _format_reasoning_preview(), _delete_preview_message()
gateway/platforms/telegram.py delete_message(), inline keyboard for /reasoning, CallbackQueryHandler, "not modified" treated as success in edit_message
gateway/platforms/base.py delete_message() base method, send_typing(metadata=) signature, _keep_typing metadata forwarding
gateway/session.py reasoning_mode field on SessionEntry, set_reasoning_mode(), preserved across /reset

New test files

File Coverage
tests/gateway/test_reasoning_command.py 8 tests: command output, mode persistence, config resolution, preview formatting, preview deletion, edit-failure recovery
tests/gateway/test_session.py 3 new tests: reasoning mode roundtrip, reset preservation, group session keys
tests/gateway/test_telegram_format.py 1 new test: "not modified" edit treated as success
tests/test_run_agent_reasoning_stream.py 1 test: streaming chat completion emits reasoning callback

Test plan

  • pytest tests/gateway/test_reasoning_command.py — 8/8 pass
  • pytest tests/gateway/test_session.py — 21/21 pass (including 3 new)
  • pytest tests/gateway/test_telegram_format.py — 54/54 pass (including 1 new)
  • pytest tests/test_run_agent_reasoning_stream.py — requires full dep install (firecrawl)
  • Manual: /reasoning stream on Telegram shows italic preview that deletes on completion
  • Manual: /reasoning off disables provider-level reasoning
  • Manual: inline keyboard picker works in DM and group chats

🤖 Generated with Claude Code

raulvidis and others added 11 commits March 14, 2026 00:19
- /reasoning now supports display modes (show/hide/stream) and effort
  levels (none/minimal/low/medium/high/xhigh)
- Telegram inline keyboard shows all options in 3 rows with current
  status displayed above
- "show" mode sends reasoning as a separate message after the response
- "stream" mode streams reasoning live and auto-deletes (Telegram only)
- "hide" mode enables reasoning at API level but doesn't display it
- Effort levels set the reasoning budget without changing display mode
- CLI reasoning callback is now a no-op (uses TUI spinner instead)
- Fix: /reasoning effort changes no longer overwritten by config reload

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
teknium1 added a commit that referenced this pull request Mar 16, 2026
… providers

Stage 1 of streaming support. Adds:

- stream_delta_callback parameter on AIAgent.__init__ for real-time token delivery
- _interruptible_streaming_api_call() handling chat_completions + anthropic_messages
- Enhanced _run_codex_stream() to fire delta callbacks during Codex streaming
- _fire_stream_delta() fires both display and TTS callbacks
- _fire_reasoning_delta() for reasoning content streaming
- Tool-call suppression: callbacks only fire on text-only responses
- on_first_delta callback for spinner control on first token
- Provider fallback: graceful degradation to non-streaming
- _has_stream_consumers() unifies stream_delta_callback and _stream_callback checks
- Anthropic streaming returns native Message for downstream compatibility

Drawing from PRs #922 (unified streaming), #1312 (gateway consumer),
#774 (Telegram streaming), #798 (CLI streaming), #1214 (reasoning modes).
Credit: jobless0x, OutThisLife, clicksingh, raulvidis.
teknium1 added a commit that referenced this pull request Mar 16, 2026
…ment

The streaming infrastructure already fires reasoning deltas via
_fire_reasoning_delta() during streaming. The remaining work is the
CLI display layer: a dim reasoning box that opens on first reasoning
token, streams live, then transitions to the response box.

Reference: PR #1214 (raulvidis) for gateway reasoning visibility.
@raulvidis

Copy link
Copy Markdown
Author

Closing — superseded by merged streaming infrastructure #1538

@raulvidis raulvidis closed this Mar 19, 2026
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
… providers

Stage 1 of streaming support. Adds:

- stream_delta_callback parameter on AIAgent.__init__ for real-time token delivery
- _interruptible_streaming_api_call() handling chat_completions + anthropic_messages
- Enhanced _run_codex_stream() to fire delta callbacks during Codex streaming
- _fire_stream_delta() fires both display and TTS callbacks
- _fire_reasoning_delta() for reasoning content streaming
- Tool-call suppression: callbacks only fire on text-only responses
- on_first_delta callback for spinner control on first token
- Provider fallback: graceful degradation to non-streaming
- _has_stream_consumers() unifies stream_delta_callback and _stream_callback checks
- Anthropic streaming returns native Message for downstream compatibility

Drawing from PRs NousResearch#922 (unified streaming), NousResearch#1312 (gateway consumer),
NousResearch#774 (Telegram streaming), NousResearch#798 (CLI streaming), NousResearch#1214 (reasoning modes).
Credit: jobless0x, OutThisLife, clicksingh, raulvidis.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…ment

The streaming infrastructure already fires reasoning deltas via
_fire_reasoning_delta() during streaming. The remaining work is the
CLI display layer: a dim reasoning box that opens on first reasoning
token, streams live, then transitions to the response box.

Reference: PR NousResearch#1214 (raulvidis) for gateway reasoning visibility.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
… providers

Stage 1 of streaming support. Adds:

- stream_delta_callback parameter on AIAgent.__init__ for real-time token delivery
- _interruptible_streaming_api_call() handling chat_completions + anthropic_messages
- Enhanced _run_codex_stream() to fire delta callbacks during Codex streaming
- _fire_stream_delta() fires both display and TTS callbacks
- _fire_reasoning_delta() for reasoning content streaming
- Tool-call suppression: callbacks only fire on text-only responses
- on_first_delta callback for spinner control on first token
- Provider fallback: graceful degradation to non-streaming
- _has_stream_consumers() unifies stream_delta_callback and _stream_callback checks
- Anthropic streaming returns native Message for downstream compatibility

Drawing from PRs NousResearch#922 (unified streaming), NousResearch#1312 (gateway consumer),
NousResearch#774 (Telegram streaming), NousResearch#798 (CLI streaming), NousResearch#1214 (reasoning modes).
Credit: jobless0x, OutThisLife, clicksingh, raulvidis.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…ment

The streaming infrastructure already fires reasoning deltas via
_fire_reasoning_delta() during streaming. The remaining work is the
CLI display layer: a dim reasoning box that opens on first reasoning
token, streams live, then transitions to the response box.

Reference: PR NousResearch#1214 (raulvidis) for gateway reasoning visibility.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
… providers

Stage 1 of streaming support. Adds:

- stream_delta_callback parameter on AIAgent.__init__ for real-time token delivery
- _interruptible_streaming_api_call() handling chat_completions + anthropic_messages
- Enhanced _run_codex_stream() to fire delta callbacks during Codex streaming
- _fire_stream_delta() fires both display and TTS callbacks
- _fire_reasoning_delta() for reasoning content streaming
- Tool-call suppression: callbacks only fire on text-only responses
- on_first_delta callback for spinner control on first token
- Provider fallback: graceful degradation to non-streaming
- _has_stream_consumers() unifies stream_delta_callback and _stream_callback checks
- Anthropic streaming returns native Message for downstream compatibility

Drawing from PRs NousResearch#922 (unified streaming), NousResearch#1312 (gateway consumer),
NousResearch#774 (Telegram streaming), NousResearch#798 (CLI streaming), NousResearch#1214 (reasoning modes).
Credit: jobless0x, OutThisLife, clicksingh, raulvidis.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…ment

The streaming infrastructure already fires reasoning deltas via
_fire_reasoning_delta() during streaming. The remaining work is the
CLI display layer: a dim reasoning box that opens on first reasoning
token, streams live, then transitions to the response box.

Reference: PR NousResearch#1214 (raulvidis) for gateway reasoning visibility.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
… providers

Stage 1 of streaming support. Adds:

- stream_delta_callback parameter on AIAgent.__init__ for real-time token delivery
- _interruptible_streaming_api_call() handling chat_completions + anthropic_messages
- Enhanced _run_codex_stream() to fire delta callbacks during Codex streaming
- _fire_stream_delta() fires both display and TTS callbacks
- _fire_reasoning_delta() for reasoning content streaming
- Tool-call suppression: callbacks only fire on text-only responses
- on_first_delta callback for spinner control on first token
- Provider fallback: graceful degradation to non-streaming
- _has_stream_consumers() unifies stream_delta_callback and _stream_callback checks
- Anthropic streaming returns native Message for downstream compatibility

Drawing from PRs NousResearch#922 (unified streaming), NousResearch#1312 (gateway consumer),
NousResearch#774 (Telegram streaming), NousResearch#798 (CLI streaming), NousResearch#1214 (reasoning modes).
Credit: jobless0x, OutThisLife, clicksingh, raulvidis.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…ment

The streaming infrastructure already fires reasoning deltas via
_fire_reasoning_delta() during streaming. The remaining work is the
CLI display layer: a dim reasoning box that opens on first reasoning
token, streams live, then transitions to the response box.

Reference: PR NousResearch#1214 (raulvidis) for gateway reasoning visibility.
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.

1 participant