Improve provider reliability and usage visibility

This commit is contained in:
2026-08-21 19:12:14 -05:00
parent 19b2c5f687
commit be1dbb600a
28 changed files with 1070 additions and 592 deletions
+10 -1
View File
@@ -651,6 +651,7 @@ fn build_system_prompt(
);
let contexts = inputs.iter().filter_map(AIAgentInput::context).flatten();
let mut environment = Vec::new();
let mut request_time = None;
let mut project_rules = Vec::new();
let mut available_skills = Vec::new();
let mut attached_context = Vec::new();
@@ -724,7 +725,7 @@ fn build_system_prompt(
attached_context.push(("Selected text".to_string(), text.clone()));
}
AIAgentContext::CurrentTime { current_time } => {
environment.push(format!("Current time: {current_time}"));
request_time = Some(*current_time);
}
AIAgentContext::Codebase { path, name } => {
environment.push(format!("Indexed codebase: {name} ({path})"));
@@ -851,6 +852,14 @@ fn build_system_prompt(
);
}
}
// Keep volatile request data at the end of the system prompt. Provider
// prompt caches match the longest exact prefix, so putting the current
// timestamp ahead of rules and tool instructions invalidates that stable
// prefix on every model call.
if let Some(request_time) = request_time {
prompt.push_str("\n## Request Time\n");
prompt.push_str(&format!("- Current time: {request_time}\n"));
}
prompt
}