fix(loop): document subagent-followup persistence and guard empty content

- Add inline rationale for persisting before ContextBuilder and for
  passing current_message="" on subagent follow-ups (avoids
  double-projection after merge).
- Skip persistence for empty subagent content (no-op messages should
  not pollute history).
- Add regression test covering the empty-content guard.

Made-with: Cursor
This commit is contained in:
Xubin Ren
2026-04-18 13:30:22 +08:00
committed by Xubin Ren
parent 1c939e8a5f
commit c8d834a504
2 changed files with 34 additions and 4 deletions
+15
View File
@@ -561,3 +561,18 @@ def test_subagent_followup_dedupes_by_task_id() -> None:
assert loop._persist_subagent_followup(session, msg) is True
assert loop._persist_subagent_followup(session, msg) is False
assert len(session.messages) == 1
def test_subagent_followup_skips_empty_content() -> None:
loop = _mk_loop()
session = Session(key="cli:empty")
msg = InboundMessage(
channel="system",
sender_id="subagent",
chat_id="cli:empty",
content="",
metadata={"subagent_task_id": "sub-empty"},
)
assert loop._persist_subagent_followup(session, msg) is False
assert session.messages == []