Repository navigation
Paid commands stop early without API credentials - #111
Conversation
`run --model <real model>` and `estimate --counter api` now check that the SDK found credentials before doing any work, and stop with one line saying none were found and how to provide them, instead of dying on the SDK's bare TypeError at the first request (after `run` had already written its estimate). The check reads the client's auth headers and credentials provider, so nothing is sent. `best_counter` uses the same check in place of catching the TypeError. Closes #109 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review (fresh-context reviewer)Verdict: Correct. No P0–P2 defects, one possible P2 scope gap, two P3 defects, five refinements. Spec
Defects[P3] Could refuse a setup the SDK would accept. [P3] A broken profile shows a traceback. Refinements
|
Keep the message next to the check in grid.py and close the client built for it. Drop the test of the removed TypeError handler, update its neighbour's docstring, spell out the paid run's arguments in the new test, and rewrap the module docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-upFixed:
Declined:
|
Closes #109
Summary
Without Anthropic credentials,
run --model <real model>got past the estimate, wroteestimate.jsonfrom character counts, then died with the SDK's rawTypeError("Could not resolve authentication method") on the first request;estimate --counter apishowed the same error as a traceback. Both now stop before doing anything, with one line:Changes
estimate.has_credentials(client)checks what the SDK found without sending anything: the client's auth headers (from a key or token) or a credentials provider (anant auth loginprofile). That mirrors the SDK's own header validation, which is what raises theTypeError.grid.require_credentials()raises the existingRunError, so the commands print the usual<command>: error: …line and exit 1.runchecks right after parsing its spec, before the gates, the cases, the run directory or the estimate; fake runs skip it.estimatechecks only with--counter api.best_counteruses the same check instead of catching theTypeError, so the keyless fallback from estimate falls back to character counts without credentials #108 keeps its message.tests/test_code_rules.pyforbids the key variable's name in code; the README already names it.gates.HARNESS_FILESchanged.Verification
make readypasses.tests/test_run.pyandtests/test_estimate.pyalso pass with credentials hidden (noANTHROPIC_*variables, emptyHOME), as in CI. The three paid-run tests that fake the model now opt past the check with acredentials_foundfixture.no_credentialsfixture: a paidrunstops with only that line, creates nothing in the runs dir and never reaches the gates, cases or counter; a fake run still works keyless;estimate --counter apistops with only that line before loading anything;has_credentialsis false with nothing found and true for a token or a credentials provider.has_credentialsis true.Observations
memories --max-usdalso makes paid calls and has no such check. It's outside this issue's two commands.