Skip to content

Disable Specific User Personas#65

Open
NeonRyan wants to merge 12 commits into
devfrom
feat/disable-specific-personas
Open

Disable Specific User Personas#65
NeonRyan wants to merge 12 commits into
devfrom
feat/disable-specific-personas

Conversation

@NeonRyan
Copy link
Copy Markdown
Collaborator

@NeonRyan NeonRyan commented May 12, 2026

Description

Backend

  • Added a system-level advisor whitelist (allowed_advisors) to phd_config.yaml, allowing admins to restrict which personas are available without removing their config files.
  • Introduced persona_filter.py that applies a two-layer filter: system whitelist → user blocklist.
  • Added per-user disabled_advisors field to the User model.
  • Created GET/PUT /api/me/advisor-preferences endpoints for retrieving and persisting user advisor preferences, with validation against registered persona IDs.
  • Wired persona filtering into the chat-stream orchestrator so disabled/disallowed advisors are excluded from LLM ranking and response generation.
  • get_frontend_config() omits personas not in the system whitelist, preventing disallowed advisors from appearing in the UI at all.
  • Added a warning log when allowed_advisors is configured as an empty list (no advisors available).

Frontend

New Toggle component - small, accessible on/off switch used by both the Settings modal and the in-chat advisor dropdown.
AppConfigContext now owns the advisor enable/disable state
The ability to turn all on and off was added.

Issues

Closes #64

Other Notes

Backend

  • Breaking change (minor): The get_top_personas method on ImprovedOrchestrator now accepts an optional allowed_ids parameter. Existing callers that don't pass it will see no behavior change (defaults to all registered personas).
  • No minimum number of advisors enforced If a user disables all advisors, the chat stream will return zero persona responses with no explicit error. Need to consider if we should retain a minimum number of advisors and whether this should be handled on the front-end or backend (or combination of both).
  • New test coverage added: test_persona_filter.py, test_advisor_preferences.py, and new cases in test_persona_config.py cover the filtering logic, API endpoints, and config validation.

Frontend

@NeonDaniel NeonDaniel changed the base branch from main to dev May 19, 2026 00:46
@NeonDaniel NeonDaniel added this to the 2.1 milestone May 19, 2026
@NeonRyan NeonRyan force-pushed the feat/disable-specific-personas branch from 4489333 to 72de25c Compare May 21, 2026 20:53
@NeonCharlie-24 NeonCharlie-24 marked this pull request as ready for review May 21, 2026 21:07
@NeonCharlie-24 NeonCharlie-24 requested a review from NeonDaniel May 21, 2026 21:07
Copy link
Copy Markdown
Member

@NeonDaniel NeonDaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left initial feedback based on reading through changes. I will pull and test locally next and comment with any observed bugs

Comment thread multi_llm_chatbot_backend/app/core/persona_filter.py Outdated
Comment thread multi_llm_chatbot_backend/app/core/persona_filter.py Outdated
Comment thread multi_llm_chatbot_backend/app/config.py Outdated
Comment on lines +175 to +180
def _warn_empty_allowed_advisors(self):
if self.allowed_advisors is not None and len(self.allowed_advisors) == 0:
logger.warning(
"allowed_advisors is set to an empty list; no advisors will be available"
)
return self
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any case where this would lead to a working application?

I think we should decide to either raise an exception here, or treat an empty list the same as None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the app won't work if every advisor is filtered out. I think it makes the most sense to raise an exception here so we catch it right away.

Comment thread phd_config.yaml
@NeonDaniel
Copy link
Copy Markdown
Member

Two suggestions:

  1. If there are 0 available advisors, consider graying out the "Send" button OR have the Orchestrator respond in that case that no advisors are available
  2. In the Advisors drop-down, consider disabling the slider on the last remaining advisor so the user can't disable all advisors. (Note that this doesn't necessarily prevent a case where 0 advisors are available since the advisors may change)

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.

[FEAT] Disable Specific Personas

3 participants