← Back to Pull requests

fix(agent): pass interceptor-set system message to model requests (issue #270) #339

Closed
unknown closed this pull request without merging on Nov 01, 2026 07:26 UTC
View on GitHub
unknown unknown commented on Oct 31, 2026 03:04 UTC
Author

Describe what this PR does / why we need it

Fixes #270: the standalone ReAct agent's invokeModel built the ChatRequest from request.getMessages() only, silently dropping ModelRequest.getSystemMessage() — so the four framework interceptors that inject system prompts through that field (Skills, Filesystem, SubAgent, TodoList, all using the null-then-appendText merge pattern) lost their injection entirely on the standalone ReAct path ("system message sent=false" in the issue's repro).

Does this pull request fix one issue?

Fixes #270

Describe how you did it

A single composition point in invokeModel builds the outgoing message list: when an interceptor set a system message, it becomes the single SYSTEM entry at the head of the request and replaces any SYSTEM messages already present in the conversation list (two SYSTEM entries would be transmitted verbatim by the Spring/LangChain4j adapters and concatenated by the Google ADK adapter, so the explicit field wins); all non-SYSTEM messages keep their order. With no interceptor-set system message the incoming list is passed through unchanged.

The composition is a local copy for this call only — the run-level message list is never written back, so nothing accumulates across tool-call turns. Streaming and non-streaming share the same construction point, so both paths behave identically. No public API, event, or configuration changes; ModelRequest's existing SYSTEM role validation already guarantees plain messages are never promoted.

Describe how to verify it

ReActAgentTest (+6 cases, all offline via the existing ScriptedClient pattern): the issue's repro (interceptor sets "required-policy", the recorded request starts with that SYSTEM entry); an existing user-provided SYSTEM message is replaced with exactly one SYSTEM entry transmitted; without an interceptor system message the conversation is passed through byte-for-byte (user SYSTEM preserved); system message count stays exactly 1 across tool-call turns (no accumulation); the streaming path receives the same system message; non-SYSTEM messages keep their order around the injected entry.

Red before the fix: system-message assertions fail (sent.get(0) has no SYSTEM role). Green after: ReActAgentTest 22/22, argi-agent-core full module 133/133 (with upstream reactor), checkstyle clean, studio compiles.

Special notes for reviews

The replace rule (interceptor system message wins over conversation SYSTEM entries) follows the interceptors' own merge convention: they treat the systemMessage field as the single system-prompt carrier (null-then-appendText), so no second protocol is introduced. If a stricter merge (e.g. appending the interceptor prompt to the conversation's existing SYSTEM text) is preferred, the change is confined to the single composition method.

Diff: 356 lines (+267 / -89) across 4 files Reviewer: yuluo-yx Review duration: 1701m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 356 lines diff across 4 files
0.43
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.352
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #339"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% 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: 42.5% (MEDIUM) · Higher = larger blast radius
42.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: 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: 18.4% · Safe to merge
18.4%