Skip to content

fix(review): restore CodeReview/DeepReview session creation and turns - #2106

Merged
limityan merged 3 commits into
GCWing:mainfrom
YodonTan:fix/review-session-mode
Aug 6, 2026
Merged

fix(review): restore CodeReview/DeepReview session creation and turns#2106
limityan merged 3 commits into
GCWing:mainfrom
YodonTan:fix/review-session-mode

Conversation

@YodonTan

@YodonTan YodonTan commented Aug 6, 2026

Copy link
Copy Markdown

Problem

Entering /review in the input box fails immediately with:

Failed to create session: Validation error: Unknown session mode: CodeReview

The review child session (agentType=CodeReview for standard review, DeepReview for strict) can no longer be created or run.

Root cause

resolve_primary_agent_for_turn (registry) only accepted AgentCategory::Mode entries in its local fallback, but CodeReview is registered as a SubAgent and DeepReview as Hidden. Session creation, turn start, manual compaction, and session restore all funnel through this resolution, so:

  • /review fails at child-session creation;
  • persisted review sessions could be silently rewritten to agentic on restore.

Regression introduced by ca94825ad ("feat(extensions): activate external primary agent profiles"), which wired this Mode-only filter into the create/turn paths.

Fix

Allow the builtin CodeReview/DeepReview agents to resolve as local session primaries while keeping every other subagent (e.g. ReviewWorker) restricted, and add diagnostics at the rejection point (warn! when a registered non-mode agent is rejected, debug! when the id is unknown). The expected_owner == External fail-closed guard is unchanged.

Follow-up cleanup (2nd commit)

CODE_REVIEW_AGENT_TYPE constant introduced in agent-runtime::deep_review::constants and used in registry review-entry detection and session-primary resolution, replacing the scattered "CodeReview" magic string. This cleanup also served as the verification content for the fix: it was written into a workspace, then reviewed end-to-end with the /review command after installing the fixed Windows build, confirming review sessions create and run correctly.

Tests

  • agentic::agents::registry::tests::builtin_review_agents_resolve_as_local_session_primaries — CodeReview/DeepReview resolve with route owner Local.
  • agentic::agents::registry::tests::non_session_primary_subagents_and_unknown_ids_do_not_resolve — ReviewWorker / unknown ids / external-owner guard stay rejected.
  • agentic::coordination::coordinator::tests::review_agent_child_sessions_create_successfully — coordinator-level session creation for both agent types.

All existing registry (33), coordinator (94), and session-manager (136) tests pass; cargo check -p bitfun-core --no-default-features is clean.

Closes #2100

Review child sessions are created with agentType=CodeReview (standard) or DeepReview (strict), but resolve_primary_agent_for_turn only accepted Mode-category agents, so session creation failed with "Unknown session mode: CodeReview" and persisted review sessions could be silently rewritten to agentic on restore.

Allow the builtin CodeReview/DeepReview agents to resolve as local session primaries while keeping all other subagents restricted, and add diagnostics at the rejection point. Regression introduced by ca94825.

@limityan limityan left a comment

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.

resolve_primary_agent_for_turn 的修复目前只覆盖了无 workspace external route 时的 fallback 分支。命中 ExternalSubagentRoute::Local 时(external.rs 约 439–442 行),代码仍只接受 AgentCategory::Mode,而内置 CodeReview / DeepReview 并非 Mode,因此显式选择 Local route 的 workspace 仍可能在创建、恢复或启动 review session 时失败。

建议提取统一的 local session-primary 判定,并同时用于 ExternalSubagentRoute::Local 与 fallback 两个分支;另外增加安装 CodeReview -> Local route 后仍能成功解析的测试。

Tant added 2 commits August 6, 2026 17:11
…t ids

Introduce CODE_REVIEW_AGENT_TYPE in agent-runtime deep_review constants and use it in registry review-entry detection and session-primary resolution, replacing the scattered "CodeReview" magic string. This keeps review agent ids consistent with the existing DEEP_REVIEW_AGENT_TYPE / REVIEW_JUDGE_AGENT_TYPE constants.

This cleanup also served as the verification content for the /review session fix in this PR: it was written into the workspace and reviewed end-to-end with the /review command after installing the fixed build, confirming review sessions now create and run correctly.
…n primaries

resolve_primary_agent_for_turn still filtered the ExternalSubagentRoute::Local branch to AgentCategory::Mode, so workspaces whose route table pins CodeReview/DeepReview to the local implementation (same-name conflict resolved to the local candidate) could still fail to create, restore, or start review sessions.

Extract a shared is_local_session_primary_entry predicate used by both the explicit Local-route branch and the no-route fallback, and add a diagnostic warn when a registered entry is rejected under a Local route.
@YodonTan

YodonTan commented Aug 6, 2026

Copy link
Copy Markdown
Author

Thanks for the review — you are right. The fix only covered the no-route fallback; the \ExternalSubagentRoute::Local\ branch (workspaces where a same-name conflict was explicitly resolved to the local candidate) still filtered to \AgentCategory::Mode\ and would reject CodeReview/DeepReview.

Addressed in \c02740ad3:

  • Extracted a shared \is_local_session_primary_entry\ predicate (Mode or builtin session-primary) now used by both the explicit Local-route branch and the no-route fallback, so both paths behave identically.
  • The Local-route branch now emits the same diagnostic \warn!\ as the fallback when a registered entry is rejected.
  • Added \local_route_resolves_review_agents_as_session_primaries: with CodeReview/DeepReview/ReviewWorker pinned to \ExternalSubagentRoute::Local, the review agents resolve with route owner Local while ReviewWorker stays rejected.

Registry suite: 34 passed (33 existing + 1 new). \cargo check -p bitfun-core --no-default-features\ clean.

@limityan limityan left a comment

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.

已重新审核最新提交。

上次提出的问题已修复:

  • ExternalSubagentRoute::Local 与无路由 fallback 现在共用 is_local_session_primary_entry
  • CodeReview / DeepReview 使用统一的运行时常量;
  • 新增显式 Local route 的 registry 测试,并确认 ReviewWorker 仍被拒绝;
  • 相关 review agent 标识也完成了常量化,避免继续散落 magic string;
  • GitHub CI 的 7 项检查全部通过。

未发现新的阻塞性问题,批准合并。

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.

/review 无法进入 review:Failed to create session: Validation error: Unknown session mode: CodeReview

2 participants