agent: Model name context (#41490)

versecafe created

Closes #41478

Release Notes:

- Fixed #41478

<img width="459" height="916" alt="Screenshot 2025-10-29 at 1 31 26 PM"
src="https://github.com/user-attachments/assets/1d5b9fdf-9800-44e4-bdd5-f0964f93625f"
/>

> caused by using haiku 4.5 from the anthropic provider and then
swapping to sonnet 3.7 through zed, doing this does mess with prompt
caching but a model swap already invalidates that so it shouldn't have
any cost impact on end users

Change summary

crates/agent/src/edit_agent/evals.rs         | 1 +
crates/agent/src/templates.rs                | 3 +++
crates/agent/src/templates/system_prompt.hbs | 6 ++++++
crates/agent/src/thread.rs                   | 1 +
4 files changed, 11 insertions(+)

Detailed changes

crates/agent/src/edit_agent/evals.rs 🔗

@@ -1581,6 +1581,7 @@ impl EditAgentTest {
             let template = crate::SystemPromptTemplate {
                 project: &project_context,
                 available_tools: tool_names,
+                model_name: None,
             };
             let templates = Templates::new();
             template.render(&templates).unwrap()

crates/agent/src/templates.rs 🔗

@@ -38,6 +38,7 @@ pub struct SystemPromptTemplate<'a> {
     #[serde(flatten)]
     pub project: &'a prompt_store::ProjectContext,
     pub available_tools: Vec<SharedString>,
+    pub model_name: Option<String>,
 }
 
 impl Template for SystemPromptTemplate<'_> {
@@ -79,9 +80,11 @@ mod tests {
         let template = SystemPromptTemplate {
             project: &project,
             available_tools: vec!["echo".into()],
+            model_name: Some("test-model".to_string()),
         };
         let templates = Templates::new();
         let rendered = template.render(&templates).unwrap();
         assert!(rendered.contains("## Fixing Diagnostics"));
+        assert!(rendered.contains("test-model"));
     }
 }

crates/agent/src/templates/system_prompt.hbs 🔗

@@ -150,6 +150,12 @@ Otherwise, follow debugging best practices:
 Operating System: {{os}}
 Default Shell: {{shell}}
 
+{{#if model_name}}
+## Model Information
+
+You are powered by the model named {{model_name}}.
+
+{{/if}}
 {{#if (or has_rules has_user_rules)}}
 ## User's Custom Instructions
 

crates/agent/src/thread.rs 🔗

@@ -1928,6 +1928,7 @@ impl Thread {
         let system_prompt = SystemPromptTemplate {
             project: self.project_context.read(cx),
             available_tools,
+            model_name: self.model.as_ref().map(|m| m.name().0.to_string()),
         }
         .render(&self.templates)
         .context("failed to build system prompt")