Skip to content

fix(agent): fallback profile の table 検証と ADR-0018 の課金上限記述を修正 (#152) - #153

Closed
rebuildup wants to merge 1 commit into
mainfrom
152
Closed

rebuildup wants to merge 1 commit into
mainfrom
152

Conversation

@rebuildup

Copy link
Copy Markdown
Owner

Closes #152

Two review findings that #150 merged unresolved (neither opens a paid path for
the three committed global_max_spend = 0 profiles, so they were safe to defer;
both are now fixed).

1. agent check now rejects a profile whose value is not a table

parseFallbackProfile returned null for a present-but-non-table profile, and
cmdCheck iterates listFallbackProfiles — which deliberately skips exactly
those keys. Result: a config that agent fallback cannot even find reported
config OK.

Reproduced before:

[fallback_profile]
good = "this-should-be-a-table"
$ agent check          -> config OK: ... (…, 1 fallback profiles)   exit 0
$ agent fallback good  -> agent: fallback profile not found: good   exit 2

Now:

  • A present value that is not a table throws
    fallback_profile.good: table expected (the profile is defined but is not a table); a genuinely absent id still returns null.
  • cmdCheck iterates every key under [fallback_profile] instead of the
    skipping helper, so the reported profile count reflects profiles actually
    validated.
$ agent check -> agent: fallback_profile.good: table expected (…)   exit 2

Existing malformed profiles (bad primary_route, non-table candidates entry,
wrong-typed expires_at) already failed validation and still do.

2. ADR-0018 no longer overstates the spend ceiling

For a positive budget, max_spend is a pre-execution admission check, not
an enforced billing ceiling
: the launcher never observes provider spend, cannot
attribute cost after a candidate is handed to a harness, and cannot see a
provider-side reprice or a model that becomes paid mid-run. Only
global_max_spend = 0 is a hard stop, because it admits only candidates that
cannot bill at all.

ADR-0018 and docs/agent-launcher.md now state this plainly, and re-state that
an account-side hard stop (a spend limit that rejects requests, or
pay-as-you-go off) remains the only guaranteed ceiling — consistent with the
existing openrouter-free caveat. No behavior change.

Verification

  • bun test script/agent.*.test.ts script/agent/*.test.ts → 745 pass, 17 skip, 0 fail
  • bun script/agent.ts check → 12 providers, 5 harnesses, 26 routes, 4 fallback profiles
  • bash evals/agent-router/controls.sh → controls OK: grader discriminates
  • ./script/test, ./script/check, ./script/check-secrets, ./script/secrets-doctor, ./script/test-workflow → all pass
  • The new non-table test is mutation-verified (reverting the guard fails it)

Out of scope

ModelScope / SenseNova / SiliconFlow recovery remains separate and blocked on
account-owner authentication
(docs/research/blocked-provider-investigation-2026-11-13.md).

…pend ceiling (#152)

Two review findings merged unresolved with #150.

1. `agent check` accepted a profile whose value is not a table.
   `parseFallbackProfile` returned null for a present-but-non-table profile, and
   `cmdCheck` iterated `listFallbackProfiles` (which skips exactly those keys),
   so a config that `agent fallback` cannot even find reported "config OK".
   Now a present value that is not a table throws a schema error naming the
   profile; a genuinely absent id still returns null. `cmdCheck` iterates every
   key under `[fallback_profile]` instead of the skipping helper, so the
   reported profile count reflects profiles actually validated. `agent
   fallback` on such an id already rejected it; the two paths now agree.

   Reproduced before the fix:
     [fallback_profile] / good = "this-should-be-a-table"
     agent check   -> config OK (exit 0)
     agent fallback good -> agent: fallback profile not found: good (exit 2)

2. ADR-0018 overstated what a positive `max_spend` guarantees.
   For a positive budget, `max_spend` is a pre-execution admission check, not an
   enforced billing ceiling: the launcher never observes provider spend, cannot
   attribute cost after a candidate is handed to a harness, and cannot see a
   provider-side reprice. Only `global_max_spend = 0` is a hard stop (it admits
   only candidates that cannot bill at all). ADR-0018 and
   docs/agent-launcher.md now say this plainly and re-state that an account-side
   hard stop remains the only guaranteed ceiling.

Tests: 745 pass. The non-table case is mutation-verified (reverting the guard
fails the new test). All gates green.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 06:33
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 90eacfa and 385949a.

Files selected for processing: 5

  • docs/adr/ADR-0018.md
  • docs/agent-launcher.md
  • script/agent.test.ts
  • script/agent.ts
  • script/agent/fallback.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@rebuildup

Copy link
Copy Markdown
Owner Author

Superseded by #235, which applies the still-needed parser/check fix and billing-wording correction to the current release branch without reviving the stale head.

@rebuildup rebuildup closed this Nov 23, 2026
@rebuildup
rebuildup deleted the 152 branch November 23, 2026 15:03
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.

fix(agent): fallback profile table validation と ADR-0018 の課金上限記述を修正する(#149 後続)

2 participants