Skip to content

feat: per-thread /model, fallback notifications, subagent model in progress#3984

Closed
web3blind wants to merge 2 commits into
NousResearch:mainfrom
web3blind:feat/per-thread-model-fallback-notifications
Closed

feat: per-thread /model, fallback notifications, subagent model in progress#3984
web3blind wants to merge 2 commits into
NousResearch:mainfrom
web3blind:feat/per-thread-model-fallback-notifications

Conversation

@web3blind

Copy link
Copy Markdown
Contributor

Summary

Three UX improvements for Telegram DM topics and subagent visibility.

1. Per-thread /model command (gateway/run.py)

Previously /model changed the global config, affecting all DM topic threads simultaneously.
Now each thread gets its own model override stored in _session_model_overrides.

  • /model claude-opus-4-6 in thread A applies only to thread A
  • /model reset or /model default reverts to the global config default
  • Config.yaml is still written as global fallback for new threads and post-restart
  • Agent cache is evicted immediately so the change takes effect on the next message

2. Fallback model notifications (run_agent.py)

When the primary model fails and _try_activate_fallback() switches to the backup,
the user now receives a chat message via status_callback:

⚠️ Primary model (claude-opus-4-6) failed — switched to fallback: gpt-5.4 (openai-codex)

When the session resets and a fresh agent is created, a cleared message is sent:

✅ Fallback cleared — resuming with primary model: claude-opus-4-6

3. Model name in subagent progress line (tools/delegate_tool.py, gateway/run.py)

Previously the delegate progress showed:

🔀 delegate_task: "Say hello..."

Now it shows:

🔀 delegate_task: "Say hello..." (model: claude-sonnet-4-6)

Implementation: delegate_tool fires a _delegate_model progress event after resolving
credentials; gateway/run.py handles it by patching the last progress line in-place
via a new __patch_last__ queue message type (edits the existing Telegram message rather
than sending a second one).

Testing

Tested manually via Telegram DM topics:

  • /model per-thread isolation confirmed: changing model in one topic does not affect others
  • Subagent model shown inline in progress line confirmed
  • Fallback notification fires on primary model rate-limit errors

…ogress

- gateway/run.py: per-session-key model overrides (_session_model_overrides)
  so /model works independently per DM topic thread; /model reset to revert
- gateway/run.py: patch_last progress queue event to append model to
  delegate_task progress line
- run_agent.py: fire status_callback('fallback_activated') when primary model
  fails and fallback activates, so gateway can notify the user in chat
- tools/delegate_tool.py: send _delegate_model progress event after children
  are built, so gateway edits the delegate_task line to include model name
- gateway/platforms/telegram.py: merge conflict resolved (prefer upstream)
@flashfork

Copy link
Copy Markdown

Neat!

- register /model in central command registry\n- restore CLI and gateway /model handlers\n- add regression tests for registry, dispatch, and shared model switch pipeline
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter tool/delegate Subagent delegation labels May 2, 2026
@web3blind

Copy link
Copy Markdown
Contributor Author

Closing this old broad branch as superseded/stale.

Several pieces it tried to add now exist on main in newer form: gateway session-scoped /model overrides, model switch routing tests, delegation provider/model config, and fallback/runtime restore infrastructure. The remaining ideas here are mixed together across many files and conflict with current main.

If any specific missing behavior is still needed, it should be resubmitted as a small focused PR rather than reviving this large mixed branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter tool/delegate Subagent delegation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants