Middleware chain (outer → inner)
LoggingMiddleware RetryMiddleware(max_retries=2) FaultInjector HistoryLimiter(max_events=4)
FaultInjector is a clearly-labelled, demo-only middleware — it fails the first 2 LLM attempts so RetryMiddleware has something to recover from.
A single Beta Agent runs a 5-turn memory test. Turn 1's first two LLM calls fail and RetryMiddleware recovers. The launch code is given in turn 2, but as history grows HistoryLimiter trims the oldest events — so by the final turn the code has been dropped and the agent can't recall it, even though it still remembers the name from the always-kept first message. LoggingMiddleware narrates every turn below.