← Back to Pull requests

fix(latency-reporter): declare TokenizedPromptDataKey consumer for promptBuckets #4032

Closed
unknown closed this pull request without merging on Nov 07, 2026 21:53 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 01:54 UTC
Author

What type of PR is this?
/kind bug

What this PR does / why we need it:
latency-reporter falls back to request.Body.TokenizedRequest.TokenCount() in promptTokens() when response.Usage.PromptTokens is zero (such as cancelled, evicted, or failed streams, or streaming requests without stream_options.include_usage). Because latencyreporter.Plugin did not implement plugin.ConsumerPlugin, datalayer.CreateMissingDataProducers did not automatically instantiate the default token-producer when latency-reporter was the only plugin needing tokenized prompts, leaving request.Body.TokenizedRequest nil and placing those requests into the lowest prompt bucket (le<first bound>).

This change implements Consumes() on latencyreporter.Plugin:

  • When promptBuckets is empty (len(p.buckets) == 0), Consumes() returns an empty plugin.DataDependencies{} because every request is labeled "all".

  • When promptBuckets is configured (len(p.buckets) > 0), Consumes() declares tokenizer.TokenizedPromptDataKey (fwkrequest.TokenizedRequest{}) as a required dependency so the framework instantiates the default token-producer.
  • The review playbook (docs/review/) caught this bug on PR #3715.

    Test plan:

  • Verified that latency-reporter without promptBuckets declares no data dependencies and does not trigger default token-producer creation.

  • Verified that latency-reporter with promptBuckets declares TokenizedPromptDataKey, triggers datalayer.CreateMissingDataProducers to instantiate token-producer, passes datalayer.ValidateAndOrderDataDependencies, and buckets a cancelled stream using the tokenized prompt count when response.Usage.PromptTokens is zero.
  • Which issue(s) this PR fixes:
    N/A

    Release note _(write NONE if no user-facing change)_:
    ``release-note
    Automatically enable the default
    token-producer when latency-reporter is configured with promptBuckets so responses without usage token counts are bucketed by estimated prompt length.
    ``

    Diff: 255 lines (+191 / -64) across 3 files Reviewer: ahg-g Review duration: 2639m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.62) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.62 · 255 lines diff across 3 files
    0.62
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.332
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.062
    Real PR Conversation Timeline
    1 comments
    "Review active on #4032"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 62.3% (MEDIUM) · Higher = larger blast radius
    62.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.9% · Safe to merge
    26.9%