Skip to content

feat(chat): model override per conversation via inline selector - #554

Merged
esafwan merged 6 commits into
developfrom
feat/chat-model-switching
Aug 2, 2026
Merged

feat(chat): model override per conversation via inline selector#554
esafwan merged 6 commits into
developfrom
feat/chat-model-switching

Conversation

@esafwan

@esafwan esafwan commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What

The inline agent/model selector in the chat input now switches the model/provider for the current agent within the same conversation, instead of jumping to a different agent.

How

  • Added backend model-override resolution in AgentManager / run_agent_sync / run_agent_stream: when a model override is supplied, the effective provider and model_name are resolved from the AI Model doc.
  • Added set_conversation_model_override whitelisted API to persist (or clear) the override on the Agent Conversation.
  • Threaded model_override through new_conversation, send_message_to_conversation, audio transcription, file upload/prepare, and the streaming renderer.
  • Frontend loads AI Models grouped by provider and forwards the selected override to every send/upload path.
  • The selector pill now reflects the selected override even when the popover is closed.
  • Blocks modality-mismatched switches (e.g. image/audio history → non-vision model) and shows a cache-reset notice.
  • Provider-level filter chips in the selector let users narrow models by provider.
  • Modality badges shown on each model item.
  • Key-gating: only providers with a configured API key (or local LLMs) are offered; models from unauthenticated providers are hidden to prevent cross-provider auth errors.
  • Streaming renderer: parse JSON body once, resolve provider from the override model for cross-provider switches, and include the normalized model in error sanitization so users see specific messages (e.g. model unavailable).

Verification

  • Bench migrated, cache cleared, and frontend rebuilt on the isolated chat-model-switching worktree bench at http://localhost:8002.
  • Backend resolution test confirms an OpenAI-default agent resolves to Google when a Gemini model override is supplied.
  • Selector opens, provider chips filter the list, modality badges render, and only configured providers appear.

Notes

  • If a selected model is itself unavailable (e.g. Gemini 2.5 Pro returns 404 for new users), the UI now surfaces a model-specific unavailable message instead of a generic provider error.

@esafwan
esafwan force-pushed the feat/chat-model-switching branch from 3216c0f to 3e50974 Compare August 1, 2026 11:15
@esafwan esafwan changed the title WIP: Inline agent/model switcher in chat input feat(chat): inline agent/model switcher in chat input Aug 1, 2026
esafwan added 2 commits August 1, 2026 17:01
- Add a pill-style AgentModelSelector variant showing current agent name + model.
- Render the selector inside ChatInput's bottom toolbar, similar to Claude/ChatGPT.
- Switching agent on a new chat updates the ?agent= param; switching on an
  existing conversation starts a fresh chat, preserving the pinned model rule.
- Filter chat-enabled agents and model-selector agents to only those whose
  provider exists in AI Provider (fail-open on permission errors).
- Extend useChatAgentIdentity to expose agent display name and model.
- Backend resolves effective provider/model from an AI Model override.

- New set_conversation_model_override API persists the choice on the conversation.

- Chat input forwards model_override to sync/stream, audio, and file uploads.

- Frontend loads models on mount so the pill reflects the override even when closed.

- Blocks modality-mismatched switches and warns that provider cache may reset.
@esafwan
esafwan force-pushed the feat/chat-model-switching branch from 3e50974 to 4bc42c3 Compare August 1, 2026 13:01
@esafwan esafwan changed the title feat(chat): inline agent/model switcher in chat input feat(chat): model override per conversation via inline selector [WIP] Aug 1, 2026
esafwan added 3 commits August 1, 2026 17:46
… key-gating

- Add get_configured_providers whitelist to only return AI providers that have a decrypted API key or are local LLMs

- Filter AI Model list in getAIModels() so only models from configured providers are offered

- Add provider chip filter row and modality badges to AgentModelSelector

- Allow searching by modality and keep catalog loaded for closed pill state
- Parse JSON body once in agent stream renderer so model_override is read reliably

- Resolve provider from override model in streaming renderer for cross-provider switches

- Include normalized_model in streaming LiteLLM error sanitization so users see specific messages (e.g. model unavailable)
@esafwan esafwan changed the title feat(chat): model override per conversation via inline selector [WIP] feat(chat): model override per conversation via inline selector Aug 2, 2026
@esafwan
esafwan marked this pull request as ready for review August 2, 2026 03:50
@esafwan
esafwan merged commit 11c5987 into develop Aug 2, 2026
4 of 5 checks passed
@esafwan
esafwan deleted the feat/chat-model-switching branch August 2, 2026 03:50
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