feat: include active bash tasks in get_loose_ends output

This commit is contained in:
damocles 2026-06-01 13:46:31 +02:00 committed by mara
commit 3c853c2b58
2 changed files with 46 additions and 7 deletions

View file

@ -654,17 +654,30 @@ impl AgentServer {
description = "List loose ends pending against this agent: unanswered questions \
where you are the asker (waiting on someone) or the target (someone's waiting on \
you), pending reminders you scheduled, plus for the manager only pending \
approvals you submitted that the operator hasn't acted on yet. Cheap server-side \
sweep, no args. Useful at turn start to remember what you owe / what's owed to \
you without scrolling inbox history. Output is a short bulleted list with ids, \
ages in seconds, and the relevant context. Each `question` or `reminder` row \
can be cancelled by passing its id + kind to `cancel_loose_end`. Empty result \
is reported clearly."
approvals you submitted that the operator hasn't acted on yet. Also lists any \
local bash tasks still in pending or running state. Cheap sweep, no args. Useful \
at turn start to remember what you owe / what's owed to you without scrolling \
inbox history. Output is a short bulleted list with ids, ages in seconds, and \
the relevant context. Each `question` or `reminder` row can be cancelled by \
passing its id + kind to `cancel_loose_end`. Empty result is reported clearly."
)]
async fn get_loose_ends(&self) -> String {
run_tool_envelope("get_loose_ends", String::new(), async move {
let (resp, retries) = self.dispatch(hive_sh4re::AgentRequest::GetLooseEnds { agent: None }).await;
annotate_retries(format_loose_ends(resp), retries)
let mut out = annotate_retries(format_loose_ends(resp), retries);
// Append any local bash tasks still in pending/running state so
// the agent sees all outstanding work in one call.
let active = crate::bash_runner::active_tasks();
if !active.is_empty() {
use std::fmt::Write as _;
let _ = write!(out, "\n\n{} active bash task(s):", active.len());
for task in &active {
let age = crate::serve_common::now_unix() - task.created_at;
let _ = write!(out, "\n- `{}` status={:?}, cmd: `{}`, age {}s",
task.id, task.status, task.cmd, age);
}
}
out
})
.await
}