Skip to content

Add opt-in proactive auto-switch policy#42

Open
txhno wants to merge 1 commit intoLoongphy:mainfrom
txhno:feat/auto-policy-perishable-capacity
Open

Add opt-in proactive auto-switch policy#42
txhno wants to merge 1 commit intoLoongphy:mainfrom
txhno:feat/auto-policy-perishable-capacity

Conversation

@txhno
Copy link
Copy Markdown

@txhno txhno commented Apr 1, 2026

Summary

  • add an opt-in auto policy to config auto while keeping threshold as the default
  • rank accounts by perishable safe capacity so healthy accounts with earlier reset pressure are burned first
  • document the new policy and cover proactive switching behavior with CLI, registry, and auto-switch tests

Testing

  • HOME=/tmp/codex-auth-verify-home zig build test
  • HOME=/tmp/codex-auth-verify-home zig build run -- config auto --policy auto --5h 12 --weekly 8

Closes #41

Note

Add opt-in auto policy for proactive account switching in codex-auth

  • Introduces a new AutoSwitchPolicy enum (threshold | auto) stored in the registry's AutoSwitchConfig, defaulting to threshold to preserve existing behavior.
  • Under the auto policy, candidate accounts are scored using remaining usage headroom, time-to-reset, and burn rate rather than simple threshold crossing; the best-scoring candidate is selected proactively.
  • Adds --policy <threshold|auto> to the config auto CLI command, with updated help, usage, and examples sections.
  • Both the daemon loop and foreground switch path in auto.zig branch on the configured policy, with auto-policy candidates refreshed and validated via dedicated upkeep functions before switching.
  • Status output now includes the active policy name alongside existing threshold values.

Macroscope summarized 29932a0.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

Open in StackBlitz

@loongphy/codex-auth-darwin-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-arm64@42

@loongphy/codex-auth-darwin-x64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-x64@42

@loongphy/codex-auth-linux-x64

npx https://pkg.pr.new/@loongphy/codex-auth-linux-x64@42

@loongphy/codex-auth-win32-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-arm64@42

@loongphy/codex-auth-win32-x64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-x64@42

@loongphy/codex-auth

npx https://pkg.pr.new/@loongphy/codex-auth@42

commit: 29932a0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add opt-in proactive auto-switch policy for perishable safe capacity

1 participant