mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-15 10:30:43 +00:00
Summary:
- Persist quota-suspension state transitions and reload fresh suspension state before failover handoff injection.
- Restore suspended lanes to configured concurrency and share failover-to-suspension reason mapping across fallback and embedded runner paths.
- Export model.failover diagnostics via OTLP and cover queueing/resume behavior with regressions.
Verification:
- pnpm test src/config/sessions/store.pruning.integration.test.ts src/process/command-queue.test.ts src/agents/session-suspension.test.ts src/agents/model-fallback.test.ts extensions/diagnostics-otel/src/service.test.ts
- git diff --check
- pnpm exec oxfmt --check --threads=1 on changed TypeScript files
- GitHub checks: 92 successful, 0 pending, 0 failed on head 962146be88
- Review threads: none unresolved
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
|
|
|
export interface HandoffSnapshot {
|
|
summary: string;
|
|
activeSubagents: Array<{
|
|
sessionId: string;
|
|
role?: string;
|
|
lastStatus?: string;
|
|
}>;
|
|
}
|
|
|
|
/**
|
|
* Builds the recovery briefing injected as the first user-side turn after a
|
|
* model failover. The user role is used (not assistant) so the new model
|
|
* treats the content as input rather than its own prior output.
|
|
*/
|
|
export function buildHierarchyReinforcementMessage(snapshot: HandoffSnapshot): AgentMessage {
|
|
const subagentReport = snapshot.activeSubagents
|
|
.map((s) => `- Subagent ${s.sessionId} (${s.role ?? "leaf"}): ${s.lastStatus ?? "running"}`)
|
|
.join("\n");
|
|
|
|
const content = [
|
|
"[SYSTEM HANDOFF] The previous model is no longer active and a fallback model is now active.",
|
|
"You are the new LEADER (Orchestrator). Do not perform tasks already delegated to subordinates.",
|
|
"",
|
|
"ACTIVE SUBORDINATE UNITS:",
|
|
subagentReport || "None active.",
|
|
"",
|
|
"CURRENT STATE SUMMARY:",
|
|
snapshot.summary,
|
|
"",
|
|
"INSTRUCTIONS:",
|
|
"1. Review the state and subordinate reports.",
|
|
"2. Provide strategic guidance and commands to subordinates.",
|
|
"3. Do not repeat work already performed by subordinates.",
|
|
].join("\n");
|
|
|
|
return {
|
|
role: "user",
|
|
content,
|
|
timestamp: Date.now(),
|
|
};
|
|
}
|