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
|
|
@ -186,18 +186,12 @@ pub(crate) fn call_haiku(agent: &str, prompt: &str) -> Result<String, String> {
|
|||
/// Call a model using an agent definition's model and tool configuration.
|
||||
/// Uses the direct API backend when api_base_url is configured,
|
||||
/// otherwise falls back to claude CLI subprocess.
|
||||
pub(crate) fn call_for_def(def: &super::defs::AgentDef, prompt: &str) -> Result<String, String> {
|
||||
let config = crate::config::get();
|
||||
if config.api_base_url.is_some() {
|
||||
super::daemon::log_verbose(&def.agent, "llm-backend",
|
||||
&format!("API: {}", config.api_base_url.as_deref().unwrap_or("?")));
|
||||
let log = |msg: &str| eprintln!("[{}] {}", def.agent, msg);
|
||||
super::api::call_api_with_tools_sync(&def.agent, prompt, &log)
|
||||
} else {
|
||||
super::daemon::log_verbose(&def.agent, "llm-backend",
|
||||
&format!("claude -p (model={}, tools={})", def.model, def.tools.len()));
|
||||
call_model_with_tools(&def.agent, &def.model, prompt, &def.tools)
|
||||
}
|
||||
pub(crate) fn call_for_def(
|
||||
def: &super::defs::AgentDef,
|
||||
prompt: &str,
|
||||
log: &(dyn Fn(&str) + Sync),
|
||||
) -> Result<String, String> {
|
||||
super::api::call_api_with_tools_sync(&def.agent, prompt, log)
|
||||
}
|
||||
|
||||
/// Parse a JSON response, handling markdown fences.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue