redis_openai_agents.RedisAgentRunner#
- class RedisAgentRunner(cache=None, metrics=None, session=None)[source]#
Integrated runner with automatic caching, metrics, and session management.
This class provides a unified interface that combines: - SemanticCache: Check/store LLM responses - AgentMetrics: Record latency, tokens, cache hits - AgentSession: Store conversation history
Example
>>> from redis_openai_agents import ( ... RedisAgentRunner, SemanticCache, AgentMetrics, AgentSession ... ) >>> >>> runner = RedisAgentRunner( ... cache=SemanticCache(redis_url="redis://localhost:6379"), ... metrics=AgentMetrics(name="my_agent"), ... session=AgentSession(user_id="user_123"), ... ) >>> >>> result = runner.run(agent, "What is Redis?") >>> # Cache checked, metrics recorded, session updated automatically
- Parameters:
cache (SemanticCache | None) – Optional SemanticCache for response caching
metrics (AgentMetrics | None) – Optional AgentMetrics for observability
session (AgentSession | None) – Optional AgentSession for conversation history
Initialize the runner with Redis components.
- Parameters:
cache (SemanticCache | None) – Optional SemanticCache for response caching
metrics (AgentMetrics | None) – Optional AgentMetrics for observability
session (AgentSession | None) – Optional AgentSession for conversation history
- __init__(cache=None, metrics=None, session=None)[source]#
Initialize the runner with Redis components.
- Parameters:
cache (SemanticCache | None) – Optional SemanticCache for response caching
metrics (AgentMetrics | None) – Optional AgentMetrics for observability
session (AgentSession | None) – Optional AgentSession for conversation history
- Return type:
None
Methods
__init__([cache, metrics, session])Initialize the runner with Redis components.
arun(agent, input, **kwargs)Async version of run() - run agent with automatic caching and metrics.
run(agent, input, **kwargs)Run an agent with automatic caching and metrics.
run_streamed(agent, input, **kwargs)Run an agent with streaming (no caching for streamed responses).