Anti-Patterns

Blocking Sync Calls in Agent Loop

Anti-pattern: run synchronous, blocking I/O inside the agent loop or HTTP handler, capping concurrency at the number of OS threads.

Problem

Throughput collapses past 10–20 concurrent requests because the runtime cannot release the thread while awaiting upstream I/O. Memory grows linearly with concurrency. Worse on Python ASGI servers when the agent loop blocks the event loop, freezing all in-flight requests. The failure mode is invisible in dev (one user) and only appears under realistic load.

Solution

Use async tool clients and async model SDKs throughout the agent loop. Move long-running agent execution off the request thread to a worker process or durable workflow runtime. Where sync is unavoidable, isolate it in a thread pool that does not share threads with the request handler. Pair with stateless-reducer-agent so the agent can be paused, persisted and resumed across workers.

When to use

  • Never. Cite when reviewing agent HTTP handlers.
  • Use async tool/model clients throughout.
  • Offload long-running plans to a worker pool with durable state.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related