Skip to content

refactor: embed agent runner configuration in profiles - #9821

Open
Soulter wants to merge 5 commits into
masterfrom
codex/refactor-provider-agent-runner
Open

refactor: embed agent runner configuration in profiles#9821
Soulter wants to merge 5 commits into
masterfrom
codex/refactor-provider-agent-runner

Conversation

@Soulter

@Soulter Soulter commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • embed Local, Dify, Coze, DashScope, and DeerFlow runner settings directly in each configuration profile
  • migrate legacy runner fields and provider-backed runner settings into the new profile structure
  • remove Agent Runner providers and their management UI from the provider page
  • keep persona selection exclusive to Local Runner and group context compression settings separately
  • add a compact floating notice for unsaved configuration changes

Dependency

Validation

  • uv run pytest tests/unit/test_agent_runner_config.py tests/unit/test_astrbot_config_manager.py tests/unit/test_config.py tests/unit/test_config_profile_service.py tests/unit/test_cron_manager.py tests/unit/test_astr_agent_tool_exec.py tests/test_conversation_checkpoint.py tests/test_deerflow_agent_runner.py -q
  • uv run ruff check .
  • cd dashboard && pnpm typecheck
  • cd dashboard && pnpm build
  • git diff --check

Summary by Sourcery

Embed Agent Runner configuration in profiles and migrate existing settings away from provider-backed storage.

New Features:

  • Embed Local, Dify, Coze, DashScope, and DeerFlow runner settings directly in configuration profiles.
  • Add profile-aware runner configuration controls, including runner-specific settings and a compact unsaved-changes notice.


Bug Fixes:

  • Migrate legacy runner and provider-backed settings while preserving valid model references and removing obsolete runner providers.

Enhancements:

  • Restructure local runner model, persona, compression, and miscellaneous settings under the Agent Runner configuration.
  • Use inline profile configuration for third-party runners and restrict persona selection to the Local Runner.
  • Remove Agent Runner providers and their selection, testing, and management UI from the provider page.

Tests:

  • Add coverage for runner defaults, normalization, migration, profile round-tripping, inline third-party configuration, and updated runner consumers.

Chores:

  • Bump the configuration schema version and retire legacy Agent Runner fields from the default configuration.

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. area:webui The bug / feature is about webui(dashboard) of astrbot. labels Aug 26, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="astrbot/core/config/astrbot_config.py" line_range="196-198" />
<code_context>
                     # 类型不匹配,使用默认值
                     new_conf[key] = value
                     has_new = True
+                elif (path + "." + key if path else key) == "agent_runner.config":
+                    # Runner config is normalized according to runner_type when saved.
+                    new_conf[key] = conf[key]
                 else:
                     # 递归检查并同步顺序
</code_context>
<issue_to_address>
**issue (bug_risk):** A persisted `agent_runner` object with a malformed or incomplete `config` bypasses recursive integrity checking and is copied unchanged. `InternalAgentSubStage.initialize` then indexes `runner_config["model"]`, `runner_config["persona"]`, `runner_config["compression"]`, and `runner_config["misc"]`, so such a configuration raises `KeyError` during pipeline initialization instead of being repaired with runner defaults.

**Triggers:** When an existing profile contains an incomplete `agent_runner.config`, such as after manual editing or a partial migration.

**Suggested fix:** Normalize `agent_runner` with `normalize_agent_runner` before accepting it in `check_config_integrity`, or ensure every consumer handles missing nested sections.
</issue_to_address>

### Comment 2
<location path="astrbot/core/config/agent_runner.py" line_range="213-224" />
<code_context>
+    return None
+
+
+def _copy_provider_config(
+    runner_type: str,
+    provider: dict[str, Any],
+) -> dict[str, Any]:
+    config = {
+        key: copy.deepcopy(value)
+        for key, value in provider.items()
+        if key not in _LEGACY_PROVIDER_IDENTITY_FIELDS
+    }
+    return normalize_agent_runner({"runner_type": runner_type, "config": config})[
+        "config"
+    ]
+
+
</code_context>
<issue_to_address>
**issue (broader_impact):** Migration copies the raw legacy runner provider dictionary directly into the embedded profile configuration and removes provider identity fields, but it never merges the provider's `provider_source_id` source configuration. Legacy runner settings stored in a provider source therefore disappear during migration, leaving the embedded runner with defaults or incomplete credentials.

**Triggers:** When a legacy Dify, Coze, DashScope, or DeerFlow provider uses `provider_source_id` for API settings.

**Suggested fix:** Resolve the provider through the same merged-provider path used at runtime before passing it to `_copy_provider_config`, or explicitly merge the referenced provider source during migration.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and this migration rewrites persisted profile settings, embeds runner credentials, and removes the old agent-runner provider records; an incorrect mapping could alter future requests or lose stored configuration. Reverting the code would not restore already-saved profiles or deleted provider records.

Blocking findings: astrbot/core/config/astrbot_config.py:198, astrbot/core/config/agent_runner.py:224


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +196 to +198
elif (path + "." + key if path else key) == "agent_runner.config":
# Runner config is normalized according to runner_type when saved.
new_conf[key] = conf[key]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): A persisted agent_runner object with a malformed or incomplete config bypasses recursive integrity checking and is copied unchanged. InternalAgentSubStage.initialize then indexes runner_config["model"], runner_config["persona"], runner_config["compression"], and runner_config["misc"], so such a configuration raises KeyError during pipeline initialization instead of being repaired with runner defaults.

Triggers: When an existing profile contains an incomplete agent_runner.config, such as after manual editing or a partial migration.

Suggested fix: Normalize agent_runner with normalize_agent_runner before accepting it in check_config_integrity, or ensure every consumer handles missing nested sections.

Comment on lines +213 to +224
def _copy_provider_config(
runner_type: str,
provider: dict[str, Any],
) -> dict[str, Any]:
config = {
key: copy.deepcopy(value)
for key, value in provider.items()
if key not in _LEGACY_PROVIDER_IDENTITY_FIELDS
}
return normalize_agent_runner({"runner_type": runner_type, "config": config})[
"config"
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (broader_impact): Migration copies the raw legacy runner provider dictionary directly into the embedded profile configuration and removes provider identity fields, but it never merges the provider's provider_source_id source configuration. Legacy runner settings stored in a provider source therefore disappear during migration, leaving the embedded runner with defaults or incomplete credentials.

Triggers: When a legacy Dify, Coze, DashScope, or DeerFlow provider uses provider_source_id for API settings.

Suggested fix: Resolve the provider through the same merged-provider path used at runtime before passing it to _copy_provider_config, or explicitly merge the referenced provider source during migration.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
astrbot-docs c985490 Commit Preview URL

Branch Preview URL
Aug 28 2026, 09:29 AM

@Soulter
Soulter force-pushed the codex/refactor-provider-agent-runner branch from 1a3d1d1 to ddb78df Compare August 26, 2026 10:58
Base automatically changed from codex/provider-management-workspace to master August 26, 2026 11:12
@Soulter
Soulter force-pushed the codex/refactor-provider-agent-runner branch from ddb78df to bea61ff Compare August 26, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. area:webui The bug / feature is about webui(dashboard) of astrbot. size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant