From c7afd1ea752aeff0310ac7c6b78d091ac360c760 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 15:38:57 +0100 Subject: 0.4.3: kill process groups, bound bash output, keep the key out of tool env - setsid-style process group kill on timeout and on Ctrl-C - 64 MiB RLIMIT_FSIZE so a runaway command cannot fill /tmp - OPENCODE_API_KEY removed from child environment - sessions 0600/0700, history 0600 and trimmed --- src/agent.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/agent.rs') diff --git a/src/agent.rs b/src/agent.rs index 46da069..9e2a431 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -159,6 +159,7 @@ pub fn run_turn( let mut last: Option = None; let mut aborted = false; let mut denied = 0usize; + let mut truncated: Option = None; loop { if cancel.load(std::sync::atomic::Ordering::Relaxed) { @@ -184,6 +185,9 @@ pub fn run_turn( } } + if outcome.finish.as_deref() == Some("length") { + 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())); @@ -204,7 +208,7 @@ pub fn run_turn( let result = if aborted { ToolOutcome::Failed("aborted by the user before this call ran".into()) } else { - execute(&call, approver) + execute(&call, approver, cancel) }; if result.denied() { denied += 1; @@ -226,6 +230,9 @@ pub fn run_turn( if aborted { eprintln!("aborted"); } + if let Some(note) = truncated { + eprintln!("agent686: {note}"); + } if let Some(outcome) = last { ui::status(steps, started.elapsed(), &outcome); } @@ -281,12 +288,16 @@ fn repair_tool_results(session: &mut Session, history: &mut Vec) { } } -fn execute(call: &provider::ToolCall, approver: &mut Approver) -> ToolOutcome { +fn execute( + call: &provider::ToolCall, + approver: &mut Approver, + cancel: &AtomicBool, +) -> ToolOutcome { let args: Value = serde_json::from_str(&call.arguments).unwrap_or_else(|_| json!({})); ui::tool_line(&call.name, &args); match tools::approval(&call.name) { - Approval::Never => match tools::run(&call.name, &args) { + Approval::Never => match tools::run(&call.name, &args, cancel) { Ok(output) => ToolOutcome::Ok(output), Err(error) => ToolOutcome::Failed(error), }, @@ -306,7 +317,7 @@ fn execute(call: &provider::ToolCall, approver: &mut Approver) -> ToolOutcome { Approval::EveryCall => { let cmd = args.get("cmd").and_then(|v| v.as_str()).unwrap_or(""); if approver.allow_bash(cmd) { - match tools::run(&call.name, &args) { + match tools::run(&call.name, &args, cancel) { Ok(output) => ToolOutcome::Ok(output), Err(error) => ToolOutcome::Failed(error), } -- cgit v1.2.3