From aed559d1cf463f4a94b22846942e0cdc64a3d4ac Mon Sep 17 00:00:00 2001 From: matevip Date: Wed, 13 May 2026 09:05:17 +0800 Subject: [PATCH] docs(agent): update head-guard call-site comment to match the order-sensitive forward scan --- .../src/main/java/vip/mate/agent/BaseAgent.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mateclaw-server/src/main/java/vip/mate/agent/BaseAgent.java b/mateclaw-server/src/main/java/vip/mate/agent/BaseAgent.java index d36a6810..4fae2e5a 100644 --- a/mateclaw-server/src/main/java/vip/mate/agent/BaseAgent.java +++ b/mateclaw-server/src/main/java/vip/mate/agent/BaseAgent.java @@ -344,8 +344,12 @@ public abstract class BaseAgent { // // The boundary prepend earlier inserts a SystemMessage at the head; // the orphan, if present, sits at index 1 in that case. Skip leading - // SystemMessages and drop any ToolResponseMessage whose response ids - // are all unmatched by the AssistantMessages still in scope. + // SystemMessages and drop any leading ToolResponseMessage whose + // response ids are not all issued by a *preceding* AssistantMessage + // — i.e. one we have already walked past in this scan. Provider + // validity is order-sensitive; a later same-id assistant deeper in + // the window does NOT redeem an earlier orphan. See + // stripHeadOrphanToolResponses below for the forward-scan details. // // Dropping is correct rather than expanding backward to fetch the // missing assistant: if the AssistantMessage is outside the window,