redis_openai_agents.cached_run#

cached_run(query, run_fn, cache, response_extractor=None)[source]#

Execute run function with cache checking.

Checks the semantic cache before calling the run function. On cache miss, calls the function and caches the result.

Parameters:
  • query (str) – The query string for cache lookup

  • run_fn (Callable[[], T]) – Function to call on cache miss (e.g., lambda: Runner.run(…))

  • cache (SemanticCache) – SemanticCache instance

  • response_extractor (Callable[[T], str] | None) – Optional function to extract response from result

Returns:

CachedRunResult on cache hit, or the original result on miss

Return type:

CachedRunResult | T