redis_openai_agents.AgentMiddleware#

class AgentMiddleware(*args, **kwargs)[source]#

Protocol for around-style middleware in the OpenAI Agents SDK.

An implementation receives the request and a handler. It may:

  • Inspect the request, then call await handler(request) to delegate.

  • Short-circuit by returning a response without calling the handler.

  • Mutate the response produced by the handler before returning it.

  • Swap the request (e.g. inject context) before calling the handler.

Implementations should be idempotent with respect to repeated calls and must not raise for cache or infrastructure errors unless the middleware is explicitly configured to fail closed.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

awrap_model_call(request, handler)

Wrap a model call.