Add per-run cost reports and hosted upload for summarize-pdf#66
Merged
Conversation
- Cost reports: every result-producing command prints a per-call cost report (pipe, model, tokens in->out, USD, total) to stderr via a new shared piper/usage.py. Unpriced calls (cost is None) are excluded from the total; token categories are never summed. Detached prints from wait/result (collection time), not the start-only demos. - summarize-pdf file upload (breaking): the document is uploaded to hosted storage up front with client.upload_file (inputs.upload_document_input) and the run carries only the returned pipelex-storage:// URI, replacing the inline base64 data: URL. build_document_input becomes the pure envelope builder; errors.py gains file-upload error hints. - Lifecycle helpers return (main_stuff, RunUsage) (breaking): execute_pipe, start_and_wait, and detached's attend_run now return usage alongside the main output so commands can print the cost report. - Docs: drop the stale-prone "shared modules" count (no-hardcoded-counts rule), keeping the structural "three execution modes" constant. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016xWB4B8DjEYbiffrjg3dsS
Greptile SummaryThis PR adds usage reporting and hosted PDF uploads to the CLI. The main changes are:
Confidence Score: 5/5This looks safe to merge. No blocking issues found in the changed code.
What T-Rex did
Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI
participant Upload as Upload API
participant Run as Run API
CLI->>Upload: Upload local PDF
Upload-->>CLI: Storage URI
CLI->>Run: Start run with Document URI
Run-->>CLI: Main output and usage
CLI-->>CLI: Print JSON to stdout
CLI-->>CLI: Print cost report to stderr
Reviews (1): Last reviewed commit: "Add per-run cost reports and hosted uplo..." | Re-trigger Greptile |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
piper/usage.pyreads per-call usage off the SDK result (usage_from_resultsfor the durable modes' typedRunResults.tokens_usages,usage_from_executefor blocking) and prints a per-call cost report (pipe, model, tokens in→out, USD, total) to stderr, after the JSON result on stdout. Unpriced calls (cost is None— mock / own-GPU / dry-run) are excluded from the total; token categories are never summed. Detached prints fromwait/result(collection time), not the start-only demos.summarize-pdf(breaking) — the document is uploaded up front withclient.upload_file(newinputs.upload_document_input) and the run request carries only the returnedpipelex-storage://URI, replacing the previous inline base64data:URL.build_document_input(path, uri)becomes the pure envelope builder;piper/errors.pygains hints for the file-upload error family.(main_stuff, RunUsage)(breaking) —execute_pipe,start_and_wait, and detached'sattend_runnow return the resolved main output and the run's usage so the commands can print the cost report.Verify
make agent-check— lint + type checksmake agent-test— offline suite (inference/API markers excluded)🤖 Generated with Claude Code
https://claude.ai/code/session_016xWB4B8DjEYbiffrjg3dsS