feat(agents): implement state-aware failover and lane suspension

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
This commit is contained in:
Mert Başar
2026-05-08 02:34:05 +03:00
committed by GitHub
parent e29f4ff6b8
commit 029ca8c268
24 changed files with 817 additions and 26 deletions

View File

@@ -311,8 +311,12 @@ export function markGatewayDraining(): void {
export function setCommandLaneConcurrency(lane: string, maxConcurrent: number) {
const cleaned = normalizeLane(lane);
const state = getLaneState(cleaned);
state.maxConcurrent = Math.max(1, Math.floor(maxConcurrent));
drainLane(cleaned);
const isProbeLane = cleaned.startsWith("auth-probe:") || cleaned.startsWith("session:probe-");
const minConcurrent = isProbeLane ? 1 : 0;
state.maxConcurrent = Math.max(minConcurrent, Math.floor(maxConcurrent));
if (state.maxConcurrent > 0) {
drainLane(cleaned);
}
}
export function enqueueCommandInLane<T>(