fix(goal): quiet waits and unify fleet NG ownership (#56, #57, #58)

This commit is contained in:
Dewey
2026-09-06 04:07:09 -05:00
parent 7345f330fc
commit 9a5fbdbda7
14 changed files with 892 additions and 26 deletions
+6 -1
View File
@@ -5,6 +5,11 @@ import { checkLimitReached, type GoalState } from "./state.ts";
export type SettleDecision = { action: "inject" } | { action: "wait" } | { action: "pause"; reason: string };
/** An untimed wait never spends model tokens on automatic reconciliation. */
export function hasUnresolvedWait(state: GoalState): boolean {
return !!state.activeWait && (!state.waitTimeoutSeconds || !state.activeWait.wakeSent);
}
/**
* Decide what the loop does when the agent settles while a goal is active.
* stopReason comes from the last assistant message ("stop", "toolUse",
@@ -17,7 +22,7 @@ export function decideSettle(state: GoalState, stopReason: string | undefined):
if (stopReason === "error") {
return { action: "pause", reason: "paused: run error" };
}
if (state.waitTimeoutSeconds && state.activeWait && !state.activeWait.wakeSent) {
if (hasUnresolvedWait(state)) {
return { action: "wait" };
}
if (checkLimitReached(state)) {