Repository navigation
fix: don't report unpriced AI spend as $0, give the api agent its own no-key status - #30
Merged
Merged
Conversation
… no-key status SECFOO-34: cost_summary() wrapped every SUM() in COALESCE(...,0), so a group (or the secfoo cost command's Total row) where no run reports cost/tokens rendered as 0 instead of "-". SQLite's SUM() already returns NULL exactly when every value in the group is NULL -- that's the "unknown" signal, and the COALESCE was throwing it away. Dropped it, made CostRow's numeric fields Optional, and added cost.sum_optional() for the CLI Total row, which had the same bug one level up. SECFOO-35: the api agent has no CLI binary -- is_available() checks for an API key, not a binary on PATH -- but reused the base adapter's binary_not_found status on failure, which means "the CLI isn't installed." Added a distinct not_configured status instead, wired into the CLI and dashboard status->style maps. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019mBtLHW8WjEnRgDGAbzXLF
4 tasks done
4 tasks done
vsn411
pushed a commit
that referenced
this pull request
Oct 31, 2026
Since cost_summary() stopped collapsing unknown cost to $0 (PR #30), an agent whose runs are all unpriced (devin, droid, cursor, agy) comes back with cost_usd=None. The overview page added every agent's cost with a plain sum(), so one priced run plus one unpriced agent raised TypeError and "/" returned 500. Use sum_optional(), as the `secfoo cost` Total row already does. The "AI spend by agent" table had the same problem with tokens: a run can have a cost but no token counts, and the template added None + None. Show "-" when no token count is known. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SECFOO-34 and SECFOO-35.
SECFOO-34 —
secfoo costshowed unknown tokens/cost as 0 / $0.00cost_summary()'s SQL wrapped everySUM()inCOALESCE(...,0), so a group (or the CLI's Total row) where no run reports cost/tokens rendered as0instead of-. SQLite'sSUM()already returnsNULLexactly when every value in the group isNULL-- that's the "unknown" signal, and theCOALESCEwas throwing it away.COALESCEinrepository.py'scost_summary().CostRow.input_tokens/output_tokens/cost_usdare nowint | None/float | None.cost.sum_optional()for the CLIcostcommand's Total row, which had the same bug one level up.web/routes/overview.py's dashboard template already guarded this correctly per-row (priced = row.unpriced_runs < row.runs), so no change needed there.SECFOO-35 —
apiagent with no key reportedbinary_not_foundThe
apiagent has no CLI binary --is_available()checks for an API key, not a binary on PATH -- but on failure it reused the base adapter'sbinary_not_foundstatus, which means "the CLI isn't installed." That's not what's wrong here.not_configuredstatus toagents/base.py'sStatusliteral.api.pynow returnsnot_configured(same stderr message) instead ofbinary_not_found._STATUS_STYLEand the dashboard's_STATUS_BADGE_CLASSmaps.Testing
Added
test_cost_command_total_is_dash_when_every_run_is_unpriced, updated the existing unpriced-group assertion andtest_run_without_a_key_explains_what_to_set. Full suite: 808 passed (only the 4 pre-existing mermaid-vendor failures noted on SECFOO-5, unrelated to this change -- local env has no~/.secfoo/vendor/mermaid.min.js).