Skip to content

core: Preflight.show() crash on non-string outputs; estimate() drops legitimate 0.0 cost/time - #29

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/preflight-estimate
Open

core: Preflight.show() crash on non-string outputs; estimate() drops legitimate 0.0 cost/time#29
ChrisW09 wants to merge 1 commit into
mainfrom
fix/preflight-estimate

Conversation

@ChrisW09

Copy link
Copy Markdown
Collaborator

Fixes #18.

Two small preflight-path fixes:

  1. Preflight.show() called (o.output or o.error or "").replace(...) — an AttributeError for any structured output (dict/list/int), which system.py explicitly supports. Now rendered via str(...), and falsy-but-real outputs (0, "") no longer fall through to the error string.
  2. 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 as None, and Preflight.show() printed "n/a (system reports no cost_usd)" even though the system did report a cost. Now is not None.

Regression tests added for both.

Test: pytest packages/cafe-core/tests/test_execution.py — 9 passed.

🤖 Generated with Claude Code

- 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>
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.

core: Preflight.show() crashes on non-string outputs; estimate() treats 0.0 mean cost/time as unavailable

1 participant