diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-01 04:29:51 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-01 04:29:51 -0500 |
| commit | 3945b6fad4f1620612beb259e8601d165b9f4f12 (patch) | |
| tree | 04958c178b59e92022c44567ebef071e13998199 /Omni/Dev/Lithium/Networking.nix | |
| parent | 7df031715fabd6eb84ef315e8fe78dc7d0b7344d (diff) | |
Fix cost reporting - parse actual cost from OpenRouter API response
I have successfully completed task t-197.8 to fix cost reporting
by pars
**Omni/Agent/Engine.hs:** 1. Added `usageCost :: Maybe Double`
field to the `Usage` type to captur 2. Updated `FromJSON` instance to
parse the optional `"cost"` field 3. Modified `ChatCompletionRequest`
ToJSON instance to include `"usage": 4. Changed cost types from `Int`
to `Double` throughout (engineOnCost ca 5. Updated `estimateCost`
to use floating-point division instead of inte 6. Modified `runAgent`
to use actual cost from API when available, conve 7. Added new test
case for parsing usage with cost field
**Omni/Agent/Worker.hs:** 1. Updated `runWithEngine` signature to
return `Double` for cost 2. Changed `totalCostRef` from `IORef Int`
to `IORef Double` 3. Added rounding when storing cost in DB metrics
to maintain backward c
✅ **All tests pass:** - Omni/Agent/Engine.hs - 16 unit tests pass
- Omni/Agent/Worker.hs - Builds successfully - Omni/Agent.hs - All
integration tests pass - Omni/Jr.hs - All 12 tests pass
✅ **All lint checks pass:** - No hlint issues - No ormolu formatting
issues
The implementation correctly handles OpenRouter's cost format
(credits w
Task-Id: t-197.8
Diffstat (limited to 'Omni/Dev/Lithium/Networking.nix')
0 files changed, 0 insertions, 0 deletions
