[codex] collect kimi usage events#28
Conversation
There was a problem hiding this comment.
Pull request overview
Adds native usage-event collection to the Kimi provider so downstream event-based aggregation can attribute token deltas to the correct status-update timestamps, while keeping existing session parsing behavior intact and documenting the EBTA-005 task artifacts/specs.
Changes:
- Implement
Provider.CollectUsageEventsfor Kimi and add wire.jsonl parsing that emits oneprovider.UsageEventperStatusUpdate.token_usage, including stableEventID. - Add focused unit tests covering incremental per-status token deltas, cross-day timestamps, and model fallback priority (metadata > wire payload > log fallback).
- Add EBTA-005 workspace artifacts and an OpenSpec change documenting requirements/design/tasks, plus mark EBTA-005 done in the plan.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| workspace/EBTA-005/test_strategy.md | Test plan for new Kimi usage-event parsing/collection and repo gates. |
| workspace/EBTA-005/review.md | Captures review notes and post-review verification commands. |
| workspace/EBTA-005/original_impl.md | Documents prior Kimi behavior (session-level aggregation only). |
| workspace/EBTA-005/new_impl.md | Candidate approach for adding Kimi event collection. |
| workspace/EBTA-005/final_impl_v1.md | Finalized behavioral requirements for Kimi native events. |
| workspace/EBTA-005/final_impl.md | Final implementation summary + OpenSpec change name. |
| provider/kimi/parser.go | Implements CollectUsageEvents, usage-event parsing, token usage extraction helper, and stable EventID generation. |
| provider/kimi/parser_test.go | Adds tests for per-status events, timestamps, EventID (message_id path), and model fallback priority. |
| openspec/changes/event-based-token-aggregation-kimi-events/tasks.md | Tracks completed implementation/testing tasks for the OpenSpec change. |
| openspec/changes/event-based-token-aggregation-kimi-events/specs/kimi-native-usage-events/spec.md | Specifies requirements/scenarios for Kimi native usage events. |
| openspec/changes/event-based-token-aggregation-kimi-events/proposal.md | Rationale and scope for adding Kimi native events. |
| openspec/changes/event-based-token-aggregation-kimi-events/design.md | Design decisions for event collection/parsing and metadata/model priority. |
| openspec/changes/event-based-token-aggregation-kimi-events/.openspec.yaml | Registers the OpenSpec change with schema + created date. |
| docs/plans/2026-04-16-event-based-token-aggregation-task.md | Marks EBTA-005 as done and records verification/review notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b2b1f70ff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
1c8a335 to
782f7cf
Compare
- add native Kimi UsageEvent collection from StatusUpdate token usage records - preserve metadata, payload, and log model fallback behavior with focused tests - close EBTA-005 task artifacts and OpenSpec change notes
- cover EventID line-number fallback and clarify token_usage event docs - make ParseParallel generic and use it for Kimi event collection
782f7cf to
718a785
Compare
Summary
CollectUsageEventssupport that emits oneUsageEventperStatusUpdate.token_usagerecord.Validation
go test ./provider/kimi -run 'Test(ParseKimiUsageEvents|CollectKimiUsageEvents)'go test ./provider/kimimake fmtmake testmake vetmake buildmake lintNotes
Kimi
StatusUpdate.token_usageis intentionally treated as incremental for this task, matching the existing parser tests and EBTA plan. If future real logs prove cumulative semantics, that should be handled by a separate fixture-backed task.