Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions crates/buzz-acp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,19 @@ fn handle_prompt_result(
PromptOutcome::Cancelled => "cancelled",
};
let agent_index = result.agent.index;
// Capture the spawn-time configured model and our PID before the agent is
// moved into match arms below. `desired_model` reflects the config/persona
// model at spawn time — it does NOT reflect `session/set_model` overrides,
// which live in buzz-agent's session state and are what `llm: (model) …`
// errors carry. The two can legitimately differ; `configured_model=` is
// still valuable for identifying a stale orphan running an old model.
let harness_configured_model = result
.agent
.desired_model
.as_deref()
.unwrap_or("<none>")
.to_string();
let harness_pid = std::process::id();

let channel_id = match &result.source {
PromptSource::Channel(ch) => Some(*ch),
Expand Down Expand Up @@ -2798,6 +2811,8 @@ fn handle_prompt_result(
tracing::warn!(
agent = agent_index,
outcome = outcome_label,
configured_model = %harness_configured_model,
pid = harness_pid,
"agent_returned — respawning"
);
let death_message = match outcome_label {
Expand Down Expand Up @@ -2842,6 +2857,8 @@ fn handle_prompt_result(
tracing::debug!(
agent = agent_index,
outcome = outcome_label,
configured_model = %harness_configured_model,
pid = harness_pid,
"agent_returned (cancelled)"
);
pool.return_agent(result.agent);
Expand All @@ -2858,6 +2875,8 @@ fn handle_prompt_result(
tracing::warn!(
agent = agent_index,
outcome = outcome_label,
configured_model = %harness_configured_model,
pid = harness_pid,
error = %e,
"transport/protocol error — respawning agent"
);
Expand All @@ -2882,6 +2901,8 @@ fn handle_prompt_result(
tracing::warn!(
agent = agent_index,
outcome = outcome_label,
configured_model = %harness_configured_model,
pid = harness_pid,
error = %e,
"agent_returned (application error — pipe intact)"
);
Expand Down
14 changes: 12 additions & 2 deletions crates/buzz-agent/src/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Llm {
effective_model: &str,
) -> Result<LlmResponse, AgentError> {
let effort = cfg.thinking_effort;
match cfg.provider {
let result = match cfg.provider {
Provider::Anthropic => {
let v = self
.post_anthropic(
Expand Down Expand Up @@ -140,7 +140,17 @@ impl Llm {
})
.await
}
}
};
// Stamp the effective model into Llm errors so log lines carry
// `llm: (model-name) 404 Not Found: …` instead of the bare status.
// The `llm: ` prefix comes from `Display for AgentError::Llm`; the
// map_err here prepends `(model-name) ` to the inner string only.
// This is the single place all provider paths converge, so the mapping
// is centralized and never needs to be repeated in each provider arm.
result.map_err(|e| match e {
AgentError::Llm(s) => AgentError::Llm(format!("({effective_model}) {s}")),
other => other,
})
}

pub async fn summarize(
Expand Down
11 changes: 11 additions & 0 deletions desktop/src-tauri/src/managed_agents/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ pub async fn restore_managed_agents_on_launch(
// whose desktop process is no longer running and reap them.
super::reap_dead_instance_agents(&super::current_instance_id(app), &tracked_pids);

// Exact-path sweep: kill any buzz-acp process whose executable path
// matches this bundle's harness binary but is not in the tracked set.
// Complements the env-var sweep above — catches orphans that predate
// BUZZ_MANAGED_AGENT injection or lost their PID-file receipt.
//
// TODO: the three sweeps above each walk the PID table independently.
// A future consolidation should collect a single shared process snapshot
// at the top of this block and thread it through all sweep functions,
// replacing the three separate kernel enumerations.
super::sweep_untracked_bundle_harnesses(&tracked_pids);

let candidates: Vec<String> = records
.iter()
.filter(|record| record.start_on_app_launch && record.backend == BackendKind::Local)
Expand Down
Loading
Loading