Skip to content

Route factory session Steps proactively and reactively across configured Plan usage routes #2183

Closed

Description

@JacobStephens2

Parent

#583

What to build

Route factory Commands that use User config defaults across [harness] routes and [security] routes per session Step according to machine-local Plan usage, acting both proactively before a Step starts and reactively when a session stops on structured provider Plan-usage evidence, with clean mid-Step worktree resets and exponential cooldown revalidation.

Specifically:

  • Before starting each session Step on a factory Command whose Harness comes from User config defaults, select the first available route from harness.routes (or harness.default when routes is empty), and for Security reviews and Security runs walk security.routes when set or fall back from plan-limited / pre-first-turn-failed security.harness through harness.routes (harness.default when unset).
  • Keep routing strictly machine-local (zero Fleet HTTP calls during Pass or Step admission), refreshing candidate codex / muse non-billed probes only when a candidate's local snapshot is missing, past resets_at, or older than ~5 minutes.
  • Proactively skip routes in cooldown or whose included Plan window utilization is at/above the route's or [harness]'s max_utilization (or 100% / ordinaryUsageAllowed == false / spendControlReached == true), routing away before spending Codex credit balances unless allow_credits = true.
  • Keep explicit CLI harness/model flags, explicit Custom-process Step harness pins, Experiments and Scoring runs pinned; never route away from a cybersecurity SafeguardRefusal (which still holds Self-merge, ADR 0021).
  • Reactively reroute a Step onto the next configured route (trying each route at most once per Step, always as a fresh session and never a cross-Harness Resume) when a session fails on structured Harness wire-frame Plan-usage evidence—never on bare HTTP 429 transient throttling and never on agent-writable assistant or tool text (ADR 0030, ADR 0031).
  • When a mid-Step limit hits after work began (before_first_turn == false), keep local commits, discard uncommitted worktree edits (git reset --hard HEAD and git clean -fd, preserving .git/info/exclude factory handover files; on merge-conflict Repair, git merge --abort and re-merge the pinned conflict commit), switch Implement from fresh to the existing continuation prompt once commits or an open pull request exist on the branch, add zero quota-warning text to any Session prompt, and link every configured route's Factory skills into the worktree.
  • Hold exhaustion cooldowns until resets_at when reported, or use exponential revalidation backoff (1h → 2h → 4h → 6h cap) when resets_at is absent or a spend cap still rejects before_first_turn after a window reset.
  • Keep pull-request and notification Built with as the single parseable primary tuple while recording every Step's actual Harness and Model in the Command log, .models.json, Command record and Run notification Session models list.

Acceptance criteria

  • Factory Commands using User config defaults route per session Step across harness.routes (and security.routes / harness.routes for Security reviews and Security runs) while keeping finished Steps and landed Spec Tickets intact.
  • Proactive selection honors max_utilization, allow_credits (routing away before burning Codex credits or agy Google AI credits by default), ~5-minute / post-resets_at local probe refresh, and strictly machine-local state.
  • Explicit CLI harness/model flags, explicit Step harness pins, Experiments and Scoring runs stay pinned, and cybersecurity SafeguardRefusal never routes and still holds Self-merge.
  • Reactive fallback triggers only on structured Harness wire-frame Plan-usage rejections (never bare HTTP 429 or agent-writable prose), tries each configured route at most once per Step as a fresh session with all configured routes' Factory skills linked, and resets uncommitted mid-Step edits cleanly (switching Implement to continuation once commits/PR exist and resetting pinned conflict merges on conflict Repair) with zero prompt changes.
  • Expired or timestamp-less cooldowns revalidate with 1h → 2h → 4h → 6h backoff when before_first_turn rejections persist (such as a monthly spend cap outliving a weekly reset), and Built with remains a single Scoring-compatible tuple while per-Step attribution records what actually ran.
  • Integration tests verify proactive reserve routing, security.routes / harness.routes fallback, mid-Step commit preservation + uncommitted discard + Implement continuation + conflict-Repair merge reset, pin/Eval/safeguard invariants, and exponential revalidation.

Blocked by

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions