fix: expose Assistant usage and account model catalog - #154
Conversation
📝 WalkthroughWalkthroughAssistant responses now expose token usage and upstream USD cost when supplied by Kagi. The ChangesAssistant API surfaces
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 10-16: Move the Added and Fixed entries from the Unreleased
section to the changelog heading matching the shared release version metadata,
using the exact ## [X.Y.Z] format. Remove or replace the ## [Unreleased] heading
for these entries while preserving their content.
In `@src/api.rs`:
- Around line 4875-4888: Preserve optional pricing throughout the assistant
model catalog: in src/api.rs lines 4875-4888, update CurrentAssistantModel and
its From conversion to deserialize and map the optional pricing field; in
src/types.rs lines 485-495, add the public optional pricing field configured to
be omitted when unavailable; in tests/integration-cli.rs lines 2073-2100, add
pricing to the catalog fixture and assert it appears in CLI JSON output; in
docs/reference/output-contract.mdx lines 205-217, document the optional pricing
field in the stable catalog response.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c807045-6fb5-48b6-81b1-195e60b62940
📒 Files selected for processing (9)
CHANGELOG.mddocs/commands/assistant.mdxdocs/reference/output-contract.mdxsrc/api.rssrc/cli.rssrc/main.rssrc/parser.rssrc/types.rstests/integration-cli.rs
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
what changed
kagi assistant modelsfrom the account-level Assistant catalog instead of the custom-assistant formwhy
the current Assistant adapter dropped usage data from both streaming and thread responses. model discovery also depended on having a saved custom assistant, so accounts without one got an empty catalog.
testing
cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo check --workspace --all-targets --lockedcargo test --workspace --all-targets --lockedFixes #153
Summary by CodeRabbit
kagi assistant modelsto list all base models available to your account, including the default model.Greptile Summary
The PR exposes Assistant token and cost accounting in completed stream and thread messages, and moves model discovery to the account-level Assistant initialization endpoint.
AssistantUsageoutput shape and maps streaming and persisted-message accounting into it./api/initJSON catalog, including the account default model.Confidence Score: 5/5
The PR appears safe to merge, with no concrete changed-code failure established.
The new account model endpoint, stream accounting conversion, and thread accounting conversion are consistently represented in the public types, command output, documentation, and integration fixtures.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Assistant API] -->|SSE final frame| B[Stream frame parser] A -->|Conversation messages| C[Thread message converter] B --> D[AssistantUsage] C --> D D --> E[CLI and MCP JSON output] F[Account /api/init] --> G[Model catalog converter] G --> H[assistant models output]Reviews (1): Last reviewed commit: "fix: expose Assistant usage and account ..." | Re-trigger Greptile