turn loop: --continue, disable claude auto-compact, /compact on overflow
This commit is contained in:
parent
409263f1c9
commit
70af56e050
3 changed files with 183 additions and 49 deletions
|
|
@ -175,24 +175,8 @@ async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> {
|
|||
});
|
||||
let prompt = format_wake_prompt(&label, &from, &body);
|
||||
let outcome =
|
||||
turn::run_turn(&prompt, &mcp_config, &bus, mcp::Flavor::Manager).await;
|
||||
match outcome {
|
||||
Ok(()) => {
|
||||
bus.emit(LiveEvent::TurnEnd {
|
||||
ok: true,
|
||||
note: None,
|
||||
});
|
||||
tracing::info!("manager turn finished");
|
||||
}
|
||||
Err(e) => {
|
||||
let note = format!("{e:#}");
|
||||
bus.emit(LiveEvent::TurnEnd {
|
||||
ok: false,
|
||||
note: Some(note.clone()),
|
||||
});
|
||||
tracing::warn!(error = %note, "manager turn failed");
|
||||
}
|
||||
}
|
||||
drive_turn(&prompt, &mcp_config, &bus, mcp::Flavor::Manager).await;
|
||||
emit_turn_end(&bus, &outcome);
|
||||
}
|
||||
Ok(ManagerResponse::Empty) => {}
|
||||
Ok(ManagerResponse::Ok | ManagerResponse::Status { .. }) => {
|
||||
|
|
@ -209,6 +193,46 @@ async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Drive one manager turn end-to-end with the same overflow-then-compact
|
||||
/// retry as sub-agents.
|
||||
async fn drive_turn(
|
||||
prompt: &str,
|
||||
mcp_config: &Path,
|
||||
bus: &Bus,
|
||||
flavor: mcp::Flavor,
|
||||
) -> turn::TurnOutcome {
|
||||
match turn::run_turn(prompt, mcp_config, bus, flavor).await {
|
||||
turn::TurnOutcome::PromptTooLong => {
|
||||
if let Err(e) = turn::compact_session(bus).await {
|
||||
tracing::warn!(error = %format!("{e:#}"), "compact failed");
|
||||
return turn::TurnOutcome::Failed(e);
|
||||
}
|
||||
turn::run_turn(prompt, mcp_config, bus, flavor).await
|
||||
}
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_turn_end(bus: &Bus, outcome: &turn::TurnOutcome) {
|
||||
match outcome {
|
||||
turn::TurnOutcome::Ok | turn::TurnOutcome::PromptTooLong => {
|
||||
bus.emit(LiveEvent::TurnEnd {
|
||||
ok: true,
|
||||
note: None,
|
||||
});
|
||||
tracing::info!("manager turn finished");
|
||||
}
|
||||
turn::TurnOutcome::Failed(e) => {
|
||||
let note = format!("{e:#}");
|
||||
bus.emit(LiveEvent::TurnEnd {
|
||||
ok: false,
|
||||
note: Some(note.clone()),
|
||||
});
|
||||
tracing::warn!(error = %note, "manager turn failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Manager-flavored wake prompt. Mentions the privileged tools the sub-agent
|
||||
/// prompt doesn't have access to, and points the manager at its own
|
||||
/// editable config repo for self-modification.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue