The drain pattern

Background tasks complete asynchronously. How does the agent learn about results? A notification queue. Background threads push completion events to a thread-safe list. Before each LLM call, the agent drains the queue and injects results as context. This is the drain pattern: collect, inject, clear.

Fill in the blanks: Drain notifications

Loading practice…