MCPcopy Index your code
hub / github.com/docker/docker-agent / applyCacheDefault

Function applyCacheDefault

pkg/runtime/cache.go:29–41  ·  view source on GitHub ↗

applyCacheDefault appends the cache_response stop hook to cfg when a has a configured response cache, mirroring the role of [builtins.ApplyAgentDefaults] for the runtime-private cache builtin. The helper accepts (and may return) a nil cfg so callers can chain it after [builtins.ApplyAgentDefaults]

(cfg *hooks.Config, a *agent.Agent)

Source from the content-addressed store, hash-verified

27// The helper accepts (and may return) a nil cfg so callers can chain
28// it after [builtins.ApplyAgentDefaults] without an extra branch.
29func applyCacheDefault(cfg *hooks.Config, a *agent.Agent) *hooks.Config {
30 if a.Cache() == nil {
31 return cfg
32 }
33 if cfg == nil {
34 cfg = &hooks.Config{}
35 }
36 cfg.Stop = append(cfg.Stop, hooks.Hook{
37 Type: hooks.HookTypeBuiltin,
38 Command: BuiltinCacheResponse,
39 })
40 return cfg
41}
42
43// tryReplayCachedResponse looks up the latest user message in the agent's
44// response cache. On a hit it replays the cached answer as the assistant

Callers 1

buildHooksExecutorsMethod · 0.85

Calls 1

CacheMethod · 0.80

Tested by

no test coverage detected