Skip to content

feat: unify session configuration mappings and overrides - #11097

Merged
Soulter merged 18 commits into
masterfrom
feat/session-config-mappings
Nov 12, 2026
Merged

Soulter merged 18 commits into
masterfrom
feat/session-config-mappings

Conversation

@Soulter

@Soulter Soulter commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Custom Rules and configuration routing previously stored overlapping session settings with different priority rules. This change resolves each session from one base profile plus explicit field overrides, and manages both from Config → Manage session mappings. Model commands and the WebUI update the same model overrides.

Modifications

  • Store ordered UMOP routes and exact UMO assignments as config_binding records. Keep binding migration in astrbot/core/db/migration/migra_config_bindings.py, separate from the shared storage-key definition. Preserve route order and allow sessions to select a profile or follow routing; field overrides apply afterward without modifying shared profiles.
  • Migrate legacy model, persona, service, plugin, and knowledge-base preferences. Preserve knowledge-base IDs even when their instances are unavailable during startup. Move remarks into UMO aliases, remove the unused session Rerank flag, and retain groups, conversation histories, and unrelated preferences. Groups remain a way to apply changes to current members, without adding group inheritance.
  • Build each message snapshot as a AstrBotConfigSnapshot, constructing values directly from the base profile and overrides with one full copy. Its save methods reject profile writes; explicit override paths live on MessageConfig. Keep public configuration getter signatures unchanged and avoid dynamic markers, copied persistence state, or object-identity checks.
  • Resolve message configuration through an internal ContextVar and a dynamic PipelineContext.astrbot_config property, without adding configuration fields to events. Session configuration readers share an isolated snapshot; changes apply to subsequent messages, and exceptions/cancellation restore the previous scope. Select the pipeline using the final UMO after member isolation. Read third-party runner settings from the effective configuration.
  • Remove the unused internal SessionServiceManager and SessionPluginManager classes and obsolete test mocks. Service and plugin checks now use effective configuration.
  • Remove unused Custom Rules translation modules, handwritten session API wrappers, stale pipeline configuration caches, and the unused provider-preference argument. Simplify persona resolution to the effective configuration and remove redundant legacy conversation-persona queries. Preserve legacy data migration and the old page redirect; retire the unused session-status and batch-setting HTTP APIs described below.
  • Remove GET /api/v1/sessions, PATCH /api/v1/sessions/provider, and PATCH /api/v1/sessions/service, their three legacy /api/session aliases, and dedicated service methods/request schemas. Regenerate the OpenAPI client and public API docs. Document replacements using active UMOs, mapping reads, and per-UMO override writes.
  • Remove the built-in /persona command. Manage session personas and restore inheritance through Config → Manage session mappings → Overrides → Persona.
  • Provide inherited/explicit settings for session status, wake prefixes, AI and voice, models, personas, knowledge bases, and plugins. Lists replace inherited lists; restoring inheritance removes the override. Session status edits each target's blacklist independently.
  • Delete complete session mappings from the Bots editor with the trash action, including override-only sessions. Persist deletion on Save Changes through the existing binding deletion API; retain overrides when the profile dropdown is set to follow routing. Keep pending deletions across mapping-dialog refreshes and allow retry after a failed save.
  • Combine the bot deletion dialog’s Custom Rules and Config Routing options into Session mappings, using the existing API to remove both overrides and profile routing. Update translations and Chinese/English documentation screenshots.
  • Replace the standalone Custom Rules page with the mappings dialog, a two-pane batch editor, and a grouped Material-style settings list. Reuse the session selector and existing write APIs. Include override-only sessions on the Bots page and a direct entry to the shared dialog; preserve unsaved bot edits when returning.
  • Add the inherited-settings preview endpoint, regenerate the API client, and update OpenAPI documentation. Update Chinese/English instructions and screenshots, including old entry → new entry mappings and the changelog.

The navigation change accompanies the storage unification so profile selection and overrides are managed together. The legacy /session-management entry redirects to the mappings dialog.

  • This is NOT a breaking change.

This intentionally changes session-setting semantics: explicit session values take precedence over the profile, model commands and the editor share one value, and unused Rerank settings are removed. The retired session-status and batch-setting APIs no longer accept requests; external callers must migrate to the documented mapping APIs. Startup migrates the legacy preference records automatically; existing aliases and unrelated session data are retained.

Screenshots or Test Results

Manual checks used an isolated local API fixture rather than production configuration: single and batch selection, mixed sessions/groups, inherited and explicit values, saving and restoring wake prefixes, per-session blacklist updates, mapping visibility on the Bots page, opening the shared dialog, and retaining an unsaved mapping draft while refreshing override counts. Chinese and English screenshots are included under docs/{zh,en}/use/images/.

Grouped session overrides

Batch mapping editor

Bots page entry

Validation:

  • After simplifying redundant coverage: 177 tests passed across session overrides, third-party runners, event dispatch, QQ message handling, and runner configuration. Retain behavioral regression coverage for migration, precedence, concurrency, snapshot isolation, and persistence protection; remove duplicate cases and implementation-detail assertions. Ruff and diff checks passed. This run also reported an aiosqlite worker-thread shutdown warning (Event loop is closed).
  • Retired session APIs: 227 existing regression tests passed across Dashboard API, session management, overrides, and OpenAPI documentation. API client regeneration, Dashboard build/type checking, Ruff, and diff checks passed.
  • Bot editor mapping deletion: 7 targeted backend tests passed. Chinese/English browser checks cover inherited profiles retaining overrides, deferred deletion, cancellation by reload, preserving deletion drafts across dialog refreshes, deleting override-only mappings, and retrying failed saves. Frontend build/type checking and Ruff checks passed.
  • Bot cleanup option: 12 backend tests passed; Chinese/English browser checks verify selecting the merged option submits both cleanup targets and deselecting it submits neither. Dashboard build/type checking, Ruff, and diff checks passed.
  • Dead-code cleanup regression run: 514 passed, 3 failed across nine modules covering personas, overrides, main/third-party agents, SDK, preprocessing, images, Mattermost, and decision providers. All three failures are existing caplog assertions in decision-provider tests; they also reproduce individually and with the pre-cleanup ProviderManager loaded from commit a8d7b1ea1. Dashboard build/type checking and Ruff checks passed.
  • Explicit runtime configuration types: 487 passed (391 pipeline/override/persona/SDK tests and 96 configuration/profile-service tests). Verify synchronous and asynchronous save rejection without modifying the profile file, normal profile persistence, one-copy isolation, and stable explicit/inherited persona semantics during message execution.
  • Snapshot-copy optimization: 191 passed across override, dispatch/lifecycle, wakeup, SDK/delivery, and Context tests. A nested-data copy counter verifies one full copy per message with and without overrides, including concurrent messages for the same UMO.
  • Manager removal: 99 passed across session-lock, SDK, delivery, wakeup-pipeline, and session-override tests.
  • uv run ruff format ., uv run ruff check ., and git diff --check: passed.
  • Configuration-snapshot backend regression run: 560 passed across 11 modules covering session overrides, event dispatch/lifecycle, personas, main and third-party agents, wakeup pipelines, SDK delivery, preprocessing, and images. Includes concurrent snapshot isolation, nested execution, cleanup on errors/cancellation, inherited child tasks, AI enable overrides, and final-UMO routing. Earlier validation also covered Dashboard APIs, migration, routing, and bot cleanup.
  • Coverage includes binding migration/retries, ordered routing and concurrent writes, inheritance and list replacement, wake prefixes, blacklist behavior, commands, persona selection, bot cleanup, message pipelines, and Dashboard API routes.
  • cd dashboard && pnpm generate:api && pnpm build: passed, including Vue type checking.
  • cd docs && pnpm run docs:build: passed.

Builds report non-blocking asset/icon and bundle-size warnings; Python tests report deprecation warnings.

Checklist

  • Feature scope and behavior were discussed with the maintainer.
  • Relevant tests and UI verification are described above.
  • Affected Chinese/English WebUI instructions and screenshots were updated, including old-to-new entry mappings in the docs and changelog.
  • No new dependencies were introduced.
  • No malicious code was introduced.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Sorry @Soulter, your pull request is larger than the review limit of 150,000 diff characters

@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

@Soulter
Soulter merged commit d66e3c2 into master Nov 12, 2026
23 checks passed
@Soulter
Soulter deleted the feat/session-config-mappings branch November 12, 2026 14:10
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.

2 participants