From c1dea842fff6ff20707fd570c5ec068b87103da4 Mon Sep 17 00:00:00 2001
From: versecafe <147033096+versecafe@users.noreply.github.com>
Date: Fri, 31 Oct 2025 09:12:46 -0700
Subject: [PATCH] agent: Model name context (#41490)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #41478
Release Notes:
- Fixed #41478
> 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
---
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(+)
diff --git a/crates/agent/src/edit_agent/evals.rs b/crates/agent/src/edit_agent/evals.rs
index 84cdd101f57546a0bfbc86a290bf1f453e69a979..2cc6a6b4242a07b688d1232cd39d13797c70b02b 100644
--- a/crates/agent/src/edit_agent/evals.rs
+++ b/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()
diff --git a/crates/agent/src/templates.rs b/crates/agent/src/templates.rs
index 72a8f6633cb7bb926580dbb4f9e65ec032162d93..db787d834e63746fdbea9e837f4fd0615f85c984 100644
--- a/crates/agent/src/templates.rs
+++ b/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,
+ pub model_name: Option,
}
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"));
}
}
diff --git a/crates/agent/src/templates/system_prompt.hbs b/crates/agent/src/templates/system_prompt.hbs
index ca324fad7acccb3e50f1140c8f99d52319d159d4..4620647135631fdb367b0dc2604e89770a938c07 100644
--- a/crates/agent/src/templates/system_prompt.hbs
+++ b/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
diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs
index 64e512690beeaebd4a343bc5f2df473c795aed3f..4c0fb00163744e66b5644a0fe76b1aa853fb8237 100644
--- a/crates/agent/src/thread.rs
+++ b/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")