From 50dfff274aaf47864bd900841a806e11f162e096 Mon Sep 17 00:00:00 2001 From: Jeff Bryner Date: Wed, 8 Apr 2026 09:24:13 -0700 Subject: [PATCH] fix for https://github.com/antinomyhq/forgecode/issues/2846 fix :agent in zsh to choose agent model instead of default model --- crates/forge_main/src/ui.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/crates/forge_main/src/ui.rs b/crates/forge_main/src/ui.rs index 6605f56813..fa7063ca44 100644 --- a/crates/forge_main/src/ui.rs +++ b/crates/forge_main/src/ui.rs @@ -194,6 +194,11 @@ impl A + Send + Sync> UI // Update the app config with the new operating agent. self.api.set_active_agent(agent.id.clone()).await?; + + // Update model tracking to reflect the new agent's model + let model = self.get_agent_model(Some(agent.id.clone())).await; + self.update_model(model.clone()); + let name = agent.id.as_str().to_case(Case::UpperSnake).bold(); let title = format!( @@ -201,7 +206,13 @@ impl A + Send + Sync> UI agent.title.as_deref().unwrap_or(MISSING_AGENT_TITLE) ) .dimmed(); - self.writeln_title(TitleFormat::action(format!("{name} {title}")))?; + + // Show model info if agent uses a specific model + let model_info = model + .map(|m| format!(" ∙ model: {m}").dimmed().to_string()) + .unwrap_or_default(); + + self.writeln_title(TitleFormat::action(format!("{name} {title}{model_info}")))?; Ok(()) } @@ -4362,9 +4373,14 @@ impl A + Send + Sync> UI .filter(|text| !text.trim().is_empty()) .and_then(|str| ConversationId::from_str(str.as_str()).ok()); + let agent_id = std::env::var("_FORGE_ACTIVE_AGENT") + .ok() + .filter(|text| !text.trim().is_empty()) + .map(AgentId::new); + // Make IO calls in parallel let (model_id, conversation, reasoning_effort) = tokio::join!( - async { self.api.get_session_config().await.map(|c| c.model) }, + self.get_agent_model(agent_id.clone()), async { if let Some(cid) = cid { self.api.conversation(&cid).await.ok().flatten() @@ -4402,12 +4418,7 @@ impl A + Send + Sync> UI .and_then(|s| s.parse::().ok()); let rprompt = ZshRPrompt::from_config(&self.config) - .agent( - std::env::var("_FORGE_ACTIVE_AGENT") - .ok() - .filter(|text| !text.trim().is_empty()) - .map(AgentId::new), - ) + .agent(agent_id) .model(model_id) .token_count(conversation.and_then(|conversation| conversation.token_count())) .cost(cost)