From e803aa488c3a95193d3e3ae358b640c299f8f121 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 23 Nov 2026 20:36:22 +0100 Subject: License --- src/agent.rs | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'src/agent.rs') diff --git a/src/agent.rs b/src/agent.rs index f575908..b30c876 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -1,3 +1,10 @@ +/* + * This file is part of agent686 + * Copyright (C) 2026 Salmonik + * SPDX-License-Identifier: GPL-3.0-or-later + * https://git.2137697.xyz/agent686 + */ + use std::path::PathBuf; use std::process::Command; use std::sync::atomic::AtomicBool; @@ -201,27 +208,23 @@ pub fn run_turn( steps += 1; let mut renderer = Renderer::new(); - let mut outcome = match provider::chat_with( - &client, - cfg, - history, - &schemas, - cancel, - &mut renderer, - ) { - Ok(outcome) => outcome, - Err(Error::Aborted) => { - aborted = true; - break; - } - Err(error) => return Err(error), - }; + let mut outcome = + match provider::chat_with(&client, cfg, history, &schemas, cancel, &mut renderer) { + Ok(outcome) => outcome, + Err(Error::Aborted) => { + aborted = true; + break; + } + Err(error) => return Err(error), + }; // A call with no name cannot be replayed to the provider at all, so it // is dropped. A *named* call with no arguments is kept: the model is told // what arrived and can retry, which is better than silence. let before = outcome.tool_calls.len(); - outcome.tool_calls.retain(|call| !call.name.trim().is_empty()); + outcome + .tool_calls + .retain(|call| !call.name.trim().is_empty()); if outcome.tool_calls.len() < before { eprintln!( "agent686: ignored {} tool call(s) with no name", @@ -240,7 +243,12 @@ pub fn run_turn( truncated = Some("the model hit its output limit; the answer is cut off".into()); } let assistant = assistant_message(&outcome); - push(session, history, assistant, Some(outcome.reasoning.as_str())); + push( + session, + history, + assistant, + Some(outcome.reasoning.as_str()), + ); if outcome.tool_calls.is_empty() { last = Some(outcome); @@ -389,8 +397,8 @@ fn execute( args }; // The bash approval prompt prints the command; do not print it here too. - let repeat_detail = !(tools::approval(&call.name) == Approval::EveryCall - && approver.will_prompt_bash()); + let repeat_detail = + !(tools::approval(&call.name) == Approval::EveryCall && approver.will_prompt_bash()); ui::tool_line(label, &call.name, &args, repeat_detail); if let Err(error) = tools::validate(&call.name, &args) { return ToolOutcome::Failed(format!("{error}; the call was not run")); -- cgit v1.2.3