Conversation
resolve_selected_persona() looked up persona_id via its own linear scan over personas_v3, bypassing get_persona_v3_by_id()'s special case that maps "default" to the built-in DEFAULT_PERSONALITY. A user persona literally named "default" therefore resolved to two different Personality objects depending on call site: astr_main_agent.py's subagent registration (get_persona_v3_by_id) saw the built-in default, its main conversation path (resolve_selected_persona) saw the user's own "default" persona. Route resolve_selected_persona through get_persona_v3_by_id so both paths agree, matching the unified-lookup intent get_persona_v3_by_id was already written for. Fixes AstrBotDevs#10281
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10281.
Confirmed the mismatch:
get_persona_v3_by_idtreats "default" as reserved for the built-in persona, butresolve_selected_personadoes its own scan overpersonas_v3and finds the user's own persona named "default" instead. That's why subagent registration and the main conversation path disagree on the same persona_id.git log -GonDEFAULT_PERSONALITYshows #5672 added that special case specifically to unify this lookup;resolve_selected_personawas just missed.Modifications / 改动点
astrbot/core/persona_mgr.py:resolve_selected_personanow callsget_persona_v3_by_id(persona_id)instead of repeating the lookup, so both paths agree.tests/unit/test_persona_resolution.py: reproduces the mismatch (fails onmaster, passes here) plus a control test for a normal, non-"default" persona.This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Ran the full suite on python 3.12 too: 3615 passed, 24 skipped, same skip count as master, so nothing else moved.
ruff format/ruff checkclean. Coverage reporting hung on this file's import order for me, so I didn't get a coverage number out of it, but reverting just this one hunk is what turns the new test red, so it's exercising the right line either way.Two other open PRs touch this file (#9147, #6325) but both are stale, already conflicting with master, and neither changes this lookup, so should be an easy rebase for either if they ever come back to life.
Checklist / 检查清单
Summary by Sourcery
Resolve selected personas through the canonical persona lookup so all persona_id paths agree on reserved and user-defined personas.
Bug Fixes:
Tests: