Repository navigation
feat(save-more): flag a small model that rejects the free auto-mode check (#680) - #681
Conversation
…heck (#680) Add the check small-model-rejects-server-check to the "Settings that cost you money" card. - Fires when ANTHROPIC_SMALL_FAST_MODEL or ANTHROPIC_DEFAULT_HAIKU_MODEL names a Haiku older than 5.5, at its effective value. - The fix sets each such key to claude-haiku-5-5. Apply and revert keep one record per file and key. - The proxy prices classifier rows in sessions that also have a Haiku request with status 400. CostlyShape gets Status and SessionHas. Refs #680, #615. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 89740669b6d3 |
approve |
Verdict: approve
Findings
None. The PR adds a new costly settings check for small model versions that reject server-side checks. The implementation is correct and well-tested.
Non-blocking
- codex-marketplace/plugins/context-guru/scripts/costly.py:134 — The regex
_HAIKU_NEWuses(?!\d)negative lookahead twice. This is correct but dense. The comment helps. - codex-marketplace/plugins/context-guru/scripts/costly.py:366 —
_target()returnsfix["names"][0]as fallback whenlochas no"name". This assumesfix["names"]is non-empty forset_envfixes. The JSON schema guarantees this, but a defensive check would make the code more robust. - dash/costlysettings.go:122 — The
sessionHasWhere()function duplicates filter conditions from the outer query. This is correct for SQL semantics but creates maintenance coupling. A comment noting this would help future readers.
What I checked
- New check definition: The
small-model-rejects-server-checkcheck in both JSON files is identical and correctly structured. Thedetect.kindismodel_unsupported,fix.kindisset_env, and the price shape usessession_haswith a Haiku 400 status filter. - Haiku version parsing: The
haiku_version()function handles both new format (claude-haiku-4-5) and old format (claude-3-5-haiku-20241022) correctly. The regex patterns use proper negative lookaheads to avoid matching partial numbers. Test coverage includes edge cases likeclaude-haiku-5,claude-haiku-4.5, and non-Haiku models. - Detection logic: The
detect()function formodel_unsupportedcorrectly useseffective_value()to get the winning value across file precedence, then checks each file that sets an old Haiku. The logic handles process env, multiple files, and precedence correctly. - Apply/revert for multiple keys: The refactored
apply()andrevert()functions now group entries by file path, then process all keys in each file together. This creates one backup per file even when fixing multiple keys. Thetodolist inapply()deduplicates keys within a file. Therevert()validation checks each key before restoring any. - SQL query logic: The
sessionHasWhere()function builds an EXISTS subquery that correctly filters by session, tenant, time window, and the inner shape. TheshapeWhere()function now takes an alias parameter to support both outer and inner queries. The testTestCostlySmallModelCountsClassifiersOnlyInSessionsWithAHaiku400verifies the query logic with 16 test cases covering tenant isolation, time windows, status codes, and session matching. - Data dependence: The docs/data-dependence.md update correctly notes that the check now reads
ANTHROPIC_SMALL_FAST_MODELandANTHROPIC_DEFAULT_HAIKU_MODELin addition to the existing keys, and that one check uses upstream status (400). - Documentation: The docs/plugin/save-more.md table correctly describes the new check, its detection condition, fix, and cost measurement. The note about the double-count with the betas setting is clear.
- Test coverage: Python tests cover detection across all sources (user, project, project-local, managed, process env), file precedence, version parsing edge cases, apply/revert with multiple keys in one file, and the card rendering. Go tests verify the SQL query logic with comprehensive session/tenant/time/status combinations.
- Fail-open: This is a read-only check. It does not modify requests. The plugin reads only named keys from the user's own settings files and sends none to the proxy.
- JSON schema consistency: The Go test
TestCostlyChecksMatchThePluginListverifies that the GoCostlyChecksslice matches the plugin's JSON file. The test now handles the newStatusandSessionHasfields. - Edge cases: The code handles unset keys (not judged), non-Haiku models (no fire), version strings it cannot parse (no fire), and Haiku 5.5 or newer (no fire). The apply refuses when the setting is in managed settings or process env only.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 89740669b6d3 |
approve |
Verdict: approve
Findings
None.
Non-blocking
- codex-marketplace and context-guru-plugin costly.py duplication: The same costly.py file exists in two locations with identical changes. This is intentional for the two plugin distributions, but consider whether a shared import or symlink could reduce maintenance burden in future changes.
What I checked
-
New check logic: The
small-model-rejects-server-checkdetects Haiku models below 5.5 using regex patterns that handle both new (claude-haiku-4-5) and old (claude-3-5-haiku-20241022) naming conventions. Thehaiku_version()parser correctly extracts major and minor versions and returns None for non-Haiku models or unparseable versions. -
Multi-key fix handling: The new
set_envfix kind withnamesarray allows one fix to update multiple environment keys (ANTHROPIC_SMALL_FAST_MODELandANTHROPIC_DEFAULT_HAIKU_MODEL). The apply logic groups locations by file path, processes all keys in each file together, creates one backup per file, and records separate entries for each key. The revert logic correctly restores all keys in each file and validates that each key still holds the written value before reverting. -
SessionHas filter: The Go
sessionHasWhere()function builds an EXISTS subquery that filters rows by whether the same session has another row matching an inner shape. It correctly applies the same tenant and time window constraints to both the outer and inner queries. The conditionr.session_id <> ''ensures the filter only applies when the outer row has a non-empty session ID. -
Test coverage: Python tests cover detection across all sources (user, project, project-local, managed, process env), precedence rules, version parsing edge cases, apply/revert with multiple keys in one file and across files, and refusal when settings are not editable. Go test seeds 16 scenarios covering session matching, tenant isolation, time window boundaries, status code filtering, and the interaction between the outer classifier shape and inner Haiku 400 shape.
-
Metadata-only: Confirmed in
docs/data-dependence.mdline 226. The check uses only request columns (model, tools, max_tokens, stream, status) and session_id. No request text is read. The plugin reads only the named env keys from local settings files and sends none to the proxy. -
Fail-open: This is a settings check, not a request-path component. It does not affect request forwarding. The check fires independently of the betas setting and displays conditional text based on whether that setting is also on.
-
Sync between plugin files: The
costly_settings.jsonschema is the single source of truth. The Go testTestCostlyChecksMatchThePluginListcompares the GoCostlyChecksshapes against the JSON file, including the newstatusandsession_hasfields. Both plugin distributions (codex-marketplace and context-guru-plugin) have identical changes. -
Edge cases: The detect logic handles files that override each other (higher precedence wins), process env vs file settings (file wins), and keys set in multiple files (all editable files get the fix). The apply logic refuses when settings are managed-only or process-only. The revert logic refuses if any key was changed outside the apply. The backup naming includes a timestamp, so multiple applies create separate backups, but only the most recent apply is revertable (the record is overwritten).
-
Documentation:
docs/plugin/save-more.mdupdated to describe the new check, its detection logic, fix behavior, cost measurement (classifier requests in sessions with a Haiku 400), and the note that it fires with or without the betas setting.docs/data-dependence.mdupdated to list the new env keys the plugin reads.
…l back (#682) fix(review): say why a backend was skipped, and flag a round that fell back On #681 the whole round went to Bob, and the script said only "glm (not set up)". The real cause: the session started before the user added GLM_KEY_FILE to the shell profile, so it never saw the variable. The reviewer took "not set up" as a fact about the machine. - backend_ready may print a reason. glm's names the exact cause: no claude on PATH, GLM_KEY_FILE unset, set in the profile but not in this session, a file that is missing, or no gateway URL in it. - The "Tried first" line shows that reason. - When a reviewer did not use the first backend, the script ends with a Note line that says to tell the user before accepting the round. - SKILL.md: check GLM_KEY_FILE in this session before the run, and report the skip reason; do not read "not set up" as a fact about the machine. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]> fix(review): flag only a fallback in this round, and make the profile probe robust From both GLM reviewers of #682, round 1 (the same 2 findings each). - The Note fired on a normal round-2 resume of an earlier fallback backend, and pointed at "Tried first" lines that were never printed. run_reviewer now leaves a marker only when it fell back in this round, and the Note reads that marker. - The profile probe needed the shell's whole stdout to be "set", so a profile that prints a line read as "not set". It also used -ic, which skips .zprofile and .bash_profile. It now prints a CGPROBE: marker, matches it anywhere, and runs -lic. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
Resolve the conflicts with #681 by keeping both sides: main's new small-model check (its title, cost note and Note line, its Go shape and its docs row), plus this branch's "Saves:" line for the recap, which replaces only the Cost line for a check with price kind avoided_call. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
…0.2.5) Both plugins changed in this release, so installed plugins must update. - Claude Code plugin: 0.6.0 was set in #694. No change here. - Codex plugin: 0.2.4 to 0.2.5. The vendored cg.py and costly.py and one skill changed in #512, #681, #683, #691, #694 and #698. Assisted-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
…0.2.5) (#701) chore(plugin): bump the plugins for v0.6.0 (Claude Code 0.6.0, Codex 0.2.5) Both plugins changed in this release, so installed plugins must update. - Claude Code plugin: 0.6.0 was set in #694. No change here. - Codex plugin: 0.2.4 to 0.2.5. The vendored cg.py and costly.py and one skill changed in #512, #681, #683, #691, #694 and #698. Assisted-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Osher Elhadad <[email protected]>
Summary
small-model-rejects-server-check.400 invalid beta flagon Bedrock gateways. Claude Code can then send billed classifier requests.ANTHROPIC_SMALL_FAST_MODELandANTHROPIC_DEFAULT_HAIKU_MODELtoclaude-haiku-5-5, after a yes.Refs #680, #615.
What changed
model_unsupported. It reads the effective value of both keys (highest-precedence settings file, else the process env). It fires when a value names a Haiku below 5.5.haiku_version()readsclaude-haiku-4-5, dated ids,aws/andus.anthropic.prefixes,claude-3-5-haiku-...,claude-haiku-5-5[1m]. Non-Haiku, unset and unreadable ids never fire.set_env. It changes each key in each editable file that holds an old Haiku. One record per (file, key). Revert restores each key exactly and refuses after an outside change.CostlyShapegetsStatusandSessionHas. The check sums the classifier rows (Sonnet, 0 tools,max_tokens64, no stream) in sessions that also have a Haiku row with status 400. The cost line says "(also counted under the betas setting while it is on)".claude-haiku-5-5.docs/plugin/save-more.md,docs/data-dependence.md. The Codex copies ofcg.py,costly.pyandcostly_settings.jsonstay byte-identical.Data dependence
max_tokens, stream, session id, tenant and time columns. It stores nothing new.How it was tested
python3 -I context-guru-plugin/scripts/test_costly.py: 47 tests, OK.go test -race ./dash/...: ok (474 s).go test -race ./context-guru-plugin/...: only the 2 known box failures (TestInstallRefusesAnUnverifiedDownload,TestInstallReportsPATHFromTheSourceFallbackToo). A first run also failed one install test. It passed on the rerun.go vet,gofmt -l,go mod verify: clean.go.modandgo.sumunchanged.Open questions
claude-haiku-5-5? No cheap proxy endpoint lists models today.Technical notes
SessionHasrenders asEXISTS (SELECT 1 FROM requests x ...)on the same session. The inner row gets the same tenant, time and keep-alive scope as the outer row. All values are bound parameters. Column names are fixed.🤖 Generated with Claude Code