task: #3586455 Agent loop responses bypass responseInterceptor; deduplicate step-message wrapping
Summary
getAllMessages() bypasses responseInterceptor for all agent loop iterations after the first response. The root cause is duplicated logic. The step-message wrapping exists in both the interceptor (line 111, "Contacting agents..") and inline in getAllMessages() (line 309, "Calling agents.."). The getAllMessages() path uses a direct fetch() that never invokes the interceptor, so contributed modules cannot reliably extend response handling for agent-based assistants.
Proposed fix
- Extract the duplicated step-message wrapping into a shared
buildStepHtml()helper - Simplify the interceptor to delegate to the helper
- Call
responseInterceptoringetAllMessages()before processing
Net result: removes duplication, unifies the loading text, and makes the interceptor work consistently.
Environment
- Module version: 1.3.5
- Drupal version: 11.3.2