logging: single output stream through caller's log closure
Pass the caller's log closure all the way through to api.rs instead of creating a separate eprintln closure in llm.rs. Everything goes through one stream — prompt, think blocks, tool calls with args, tool results with content, token counts, final response. CLI uses println (stdout), daemon uses its task log. No more split between stdout and stderr. Also removes the llm-log file creation from knowledge.rs — that's the daemon's concern, not the agent runner's. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e74d533748
commit
543e1bdc8a
4 changed files with 25 additions and 45 deletions
|
|
@ -51,7 +51,7 @@ pub async fn call_api_with_tools(
|
|||
|
||||
let max_turns = 50;
|
||||
for turn in 0..max_turns {
|
||||
log(&format!("API turn {} ({} messages)", turn, messages.len()));
|
||||
log(&format!("\n=== TURN {} ({} messages) ===\n", turn, messages.len()));
|
||||
|
||||
let (msg, usage) = client.chat_completion_stream(
|
||||
&messages,
|
||||
|
|
@ -101,7 +101,7 @@ pub async fn call_api_with_tools(
|
|||
|
||||
// Execute each tool call
|
||||
for call in msg.tool_calls.as_ref().unwrap() {
|
||||
log(&format!("tool: {}({})",
|
||||
log(&format!("\nTOOL CALL: {}({})",
|
||||
call.function.name,
|
||||
&call.function.arguments));
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ pub async fn call_api_with_tools(
|
|||
tools::dispatch(&call.function.name, &args, &tracker).await
|
||||
};
|
||||
|
||||
log(&format!("tool result: {} chars", output.text.len()));
|
||||
log(&format!("TOOL RESULT ({} chars):\n{}", output.text.len(), output.text));
|
||||
|
||||
messages.push(Message::tool_result(&call.id, &output.text));
|
||||
}
|
||||
|
|
@ -153,6 +153,7 @@ pub async fn call_api_with_tools(
|
|||
continue;
|
||||
}
|
||||
|
||||
log(&format!("\n=== RESPONSE ===\n\n{}", text));
|
||||
return Ok(text);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue