memory: add temperature support to agent defs, update reflect prompt

Thread temperature parameter from agent def header through the API
call chain. Agents can now specify {"temperature": 1.2} in their
JSON header to override the default 0.6.

Also includes Kent's reflect agent prompt iterations.
This commit is contained in:
ProofOfConcept 2026-03-24 20:29:17 -04:00
parent e88df06cd4
commit f086815eaa
7 changed files with 97 additions and 136 deletions

View file

@ -31,6 +31,7 @@ fn get_client() -> Result<&'static ApiClient, String> {
pub async fn call_api_with_tools(
agent: &str,
prompt: &str,
temperature: Option<f32>,
log: &dyn Fn(&str),
) -> Result<String, String> {
let client = get_client()?;
@ -53,12 +54,13 @@ pub async fn call_api_with_tools(
for turn in 0..max_turns {
log(&format!("\n=== TURN {} ({} messages) ===\n", turn, messages.len()));
let (msg, usage) = client.chat_completion_stream(
let (msg, usage) = client.chat_completion_stream_temp(
&messages,
Some(&tool_defs),
&ui_tx,
StreamTarget::Autonomous,
&reasoning,
temperature,
).await.map_err(|e| {
let msg_bytes: usize = messages.iter()
.map(|m| m.content_text().len())
@ -171,6 +173,7 @@ pub async fn call_api_with_tools(
pub fn call_api_with_tools_sync(
agent: &str,
prompt: &str,
temperature: Option<f32>,
log: &(dyn Fn(&str) + Sync),
) -> Result<String, String> {
std::thread::scope(|s| {
@ -182,7 +185,7 @@ pub fn call_api_with_tools_sync(
let prov = format!("agent:{}", agent);
rt.block_on(
crate::store::TASK_PROVENANCE.scope(prov,
call_api_with_tools(agent, prompt, log))
call_api_with_tools(agent, prompt, temperature, log))
)
}).join().unwrap()
})