Path: redb-route/redb.Route.Llm/Tools/AgentRunToolCache.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Tools/AgentRunToolCache.cs
----
namespace redb.Route.Llm.Tools;
///
/// Run-scoped memo store for ToolCachingPolicy.Memoize. Created when an agent run starts and
/// dropped when it returns, which is the whole of the promise: "memoised for the lifetime of the
/// agent run". No TTL, no eviction, no database row — entries cannot outlive the run that wrote
/// them, so there is nothing left over to purge.
///
/// The run loop dispatches tools sequentially, so a plain dictionary is safe; it is not shared
/// between runs.
///
///
internal sealed class AgentRunToolCache
{
private readonly Dictionary _entries = new(StringComparer.Ordinal);
/// Returns the memoised output for , or null.
public string? Get(string key) => _entries.TryGetValue(key, out var value) ? value : null;
/// Memoises under .
public void Set(string key, string outputJson) => _entries[key] = outputJson;
}