core: Preflight.show() crash on non-string outputs; estimate() drops legitimate 0.0 cost/time - #29
Open
ChrisW09 wants to merge 1 commit into
Open
core: Preflight.show() crash on non-string outputs; estimate() drops legitimate 0.0 cost/time#29ChrisW09 wants to merge 1 commit into
ChrisW09 wants to merge 1 commit into
Conversation
- Preflight.show() called .replace() on the raw output, crashing with AttributeError for any structured output (dict/list/int) even though system.py documents 'The output can be a plain value'. Render via str(). - estimate() used falsy checks, so a legitimate 0.0 mean cost/time (free, cached, or local model) was reported as None and shown as 'n/a (system reports no cost_usd)'. Check 'is not None' instead. Fixes #18 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #18.
Two small preflight-path fixes:
Preflight.show()called(o.output or o.error or "").replace(...)— anAttributeErrorfor any structured output (dict/list/int), whichsystem.pyexplicitly supports. Now rendered viastr(...), and falsy-but-real outputs (0,"") no longer fall through to the error string.estimate()used falsy checks (if mean_t/if mean_c), so a genuine 0.0 mean cost or time (free/cached/local model) came back asNone, andPreflight.show()printed "n/a (system reports no cost_usd)" even though the system did report a cost. Nowis not None.Regression tests added for both.
Test:
pytest packages/cafe-core/tests/test_execution.py— 9 passed.🤖 Generated with Claude Code