Skip to content

armgit / agtx

Public Imported from GitHub
0

πŸ„πŸΌβ€β™‚οΈ The blackboard for coding agents - agentic development environment for claude code, codex, cursor, opencode, grok and more.

fix: agent switch when fallback to default agent per phase

fynnfluegge981316e0d73d
diff --git a/src/tui/app.rs b/src/tui/app.rs
index 21a3d27..a35f249 100644
--- a/src/tui/app.rs
+++ b/src/tui/app.rs
@@ -5208,19 +5208,12 @@ fn glob_path_exists(pattern: &str) -> bool {
/// Check if a phase transition requires switching to a different agent.
/// Returns (target_agent_name, needs_switch).
-/// Only switches when an explicit phase-specific agent is configured.
-/// When no override exists, the current agent is kept (no switch).
+/// Determine the target agent for a phase and whether a switch is needed.
+/// Uses the phase-specific agent if configured, otherwise falls back to default_agent.
fn needs_agent_switch(config: &MergedConfig, task: &Task, phase: &str) -> (String, bool) {
- match config.explicit_agent_for_phase(phase) {
- Some(target) => {
- let switch = task.agent != target;
- (target.to_string(), switch)
- }
- None => {
- // No explicit agent for this phase β€” keep the current session
- (task.agent.clone(), false)
- }
- }
+ let target = config.agent_for_phase(phase);
+ let switch = task.agent != target;
+ (target.to_string(), switch)
}
/// Collect all unique agent names configured across phases.
diff --git a/src/tui/app_tests.rs b/src/tui/app_tests.rs
index 7b6cfdc..7a207ce 100644
--- a/src/tui/app_tests.rs
+++ b/src/tui/app_tests.rs
@@ -2436,12 +2436,12 @@ fn test_needs_agent_switch_no_config_keeps_current() {
}
#[test]
-fn test_needs_agent_switch_no_config_keeps_non_default_agent() {
+fn test_needs_agent_switch_no_config_falls_back_to_default() {
use crate::config::{GlobalConfig, ProjectConfig, MergedConfig};
use crate::db::Task;
- // No review agent configured, but task is running codex (set by explicit running override).
- // Moving to review should NOT switch back to default β€” keep codex.
+ // No review agent configured, task is running codex (set by explicit running override).
+ // Moving to review should switch back to default agent (claude).
let mut global = GlobalConfig::default();
global.agents.running = Some("codex".to_string());
let config = MergedConfig::merge(&global, &ProjectConfig::default());
@@ -2449,8 +2449,8 @@ fn test_needs_agent_switch_no_config_keeps_non_default_agent() {
task.agent = "codex".to_string(); // was switched to codex for running phase
let (agent, switch) = needs_agent_switch(&config, &task, "review");
- assert_eq!(agent, "codex"); // keeps codex, not fallback to claude
- assert!(!switch);
+ assert_eq!(agent, "claude"); // falls back to default agent
+ assert!(switch);
}
#[test]