TokenUsageTask returns early if info is present - #408
Conversation
|
Warning Review limit reached
Next review available in: 30 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesToken usage processing
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/kuadrant-filter/src/kuadrant/pipeline/tasks/token_usage.rs (1)
47-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the early-exit path.
Pre-populate all expected response fields and assert
TaskOutcome::Done; also cover the partial-field case to verify extraction still proceeds.🤖 Prompt for 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. In `@crates/kuadrant-filter/src/kuadrant/pipeline/tasks/token_usage.rs` around lines 47 - 54, Add regression tests for the early return in the token-usage task: pre-populate every field listed in expected_response_fields and assert execution returns TaskOutcome::Done, then add a partial-field case that confirms extraction continues rather than exiting early.
🤖 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.
Nitpick comments:
In `@crates/kuadrant-filter/src/kuadrant/pipeline/tasks/token_usage.rs`:
- Around line 47-54: Add regression tests for the early return in the
token-usage task: pre-populate every field listed in expected_response_fields
and assert execution returns TaskOutcome::Done, then add a partial-field case
that confirms extraction continues rather than exiting early.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d62d4e3c-d6cd-490b-b133-674c1bc46aa8
📒 Files selected for processing (1)
crates/kuadrant-filter/src/kuadrant/pipeline/tasks/token_usage.rs
| @@ -44,6 +44,16 @@ impl Task for TokenUsageTask { | |||
| fn apply(self: Box<Self>, ctx: &mut ReqRespCtx) -> TaskOutcome { | |||
There was a problem hiding this comment.
It's worth noting this task is legacy and (very) soon to be removed in favour of the StoreTask
There was a problem hiding this comment.
nice! yup, I reckon this would be just for a PoC I'm working on... Do you reckon that the resulting config from a TokenRateLimit Policy will change the configuration that will result building the Pipeline with the StoreTask or would it be the same?
There was a problem hiding this comment.
Yeah, so all the bits will be extracted from the responseBodyJson vars and added to a StoreTask. So any task leveraging them will wait Pending until the StoreTask resolves for them
* If response body fields are present. * Avoids doing the work twice. Signed-off-by: dd <4183971+didierofrivia@users.noreply.github.com>
8ccf948 to
ab50334
Compare
|
Closing this since task will be deprecated soon |
This PR introduces an early check for fields present in order to avoid doing the hard work. It's also useful when external proceses can inject these type of fields and the wasm-shim can be alleviated from doing the body parsing.
Summary by CodeRabbit
Bug Fixes
Performance