← Back to Pull requests

fix(llm): tolerate trailing prose after compaction JSON #855

Merged
CJstate merged 2 files (23 lines) on Nov 23, 2026 09:17 UTC
View on GitHub
CJstate CJstate commented on Nov 19, 2026 09:18 UTC
Author

_extract_json fell back to text.find("{") + text.rfind("}") when the whole
reply was not bare JSON. If the model appended a note containing braces after
the object (e.g. {old}), rfind picked that later brace and json.loads
raised JSONDecodeError: Extra data, so history compaction failed.

Use JSONDecoder().raw_decode from the first {: it consumes exactly one
complete JSON object and ignores whatever follows, which is what the fenced
block path already effectively does.

Validation:

  • pytest tests/test_compaction_json_extraction.py — 2 passed

  • no-object input still raises ValueError

  • broader LLM suite failures are pre-existing environment issues (baseline confirms)
  • Diff: 23 lines (+20 / -3) across 2 files Reviewer: andimarafioti Review duration: 5759m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.28) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.28 · 23 lines diff across 2 files
    0.28
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 1 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    67%
    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.190
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    2 items
    andimarafioti andimarafioti approved these changes on Nov 23, 2026 09:17 UTC
    Approved Reviewer

    Good find! I haven't looked at compaction in a while :)

    <img src="https://static.klipy.com/ii/35ccce3d852f7995dd2da910f2abd795/bd/ac/Q0FDn1uo.gif"/>

    Reviewers
    Assignees
    CJstate CJstate
    Labels
    risk: low confidence: 67.5% reviewed
    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: 28.5% (LOW) · Higher = larger blast radius
    28.5%
    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: 67.5% · Lower = rushed or shallow review
    67.5%
    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: 9.2% · Safe to merge
    9.2%