Files
analysis_claude_code/agents/s08_background_tasks.py
huanghuang358 757e84482f fix(s08): avoid consecutive user messages when draining background notifications
The previous implementation always appended a new user message for background
results regardless of the trailing message's role. After a tool round-trip
(or right after the user query), the messages list could end up with two
adjacent user messages, which is messy for prompt caching, token accounting
and stricter API gateways.

Now we merge the background-results block into the trailing user message
when its role is already user, and only append a fresh user message
otherwise. tool_result blocks still immediately follow their tool_use, so
the protocol contract is preserved.
2026-04-19 12:59:10 +08:00

9.8 KiB