← Back to Pull requests

181 context window is added to user session #201

Closed
unknown closed this pull request without merging on Apr 25, 2026 11:03 UTC
View on GitHub
unknown unknown commented on Apr 24, 2026 20:39 UTC
Author

This PR introduces basic session context. By default the last 10 messages (total of both user and LLM) are stored in the cache. This can be changed in the config.
This PR also moves all environment variable calls into the config.py in the same way as is done in database-builder-scepa.

Implementation of caching


For the caching Redis has been set up. The key used is the session id. The RedisStore manages how many messages are stored per key. A limit was set on the context in order to not overwhelm the LLM.
An AbstractStore was used similar to database-builder-libs in order to allow for easy implementation of a persistent storage solution for chat history later on.

Langfuse traces that show how it works


For a trace that shows the context is added: https://scepadeploy.mads-han.src.surf-hosted.nl/project/cmn0f1gik000lph07z9kjmflt/traces?peek=ffb91f6cde117d92a9e18f78a0fecb48&timestamp=2026-04-24T20%3A20%3A09.568Z&observation=d8e40dfedcdaf559

A later trace after browser refresh shows that a new session does not get the old context: https://scepadeploy.mads-han.src.surf-hosted.nl/project/cmn0f1gik000lph07z9kjmflt/traces?peek=5fc3fcfc260e79784387bc738b0b3c44&timestamp=2026-04-24T20%3A27%3A25.490Z&observation=c99d815642071941

Identified Issues


Even when the LLM is asked to repeat it's previous answer and has the context of it, it will still call the MCP server. This add unnecessary waiting time to the response of the LLM and might cost extra tokens. The cause of this is the root_question_prompt as it says to use the MCP tool, but it does not specify when it should be used.

Diff: 202 lines (+151 / -51) across 2 files Reviewer: Hoog-V Review duration: 864m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.41) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.41 · 202 lines diff across 2 files
0.41
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%
60%
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.318
Shallow Review Depth shallow_review_depth
0.289
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #201"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.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: 41.2% (MEDIUM) · Higher = larger blast radius
41.2%
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: 60.5% · Lower = rushed or shallow review
60.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: 16.3% · Safe to merge
16.3%