MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / shouldCacheResponse

Function shouldCacheResponse

internal/agent/idempotency_guard.go:131–136  ·  view source on GitHub ↗

shouldCacheResponse decides whether finalize should Complete (cache the response) or Release the claim. Pulled out as a pure function so the policy can be unit-tested without standing up the full HTTP + DB stack. Rule: cache on 2xx/3xx always; cache on 4xx/5xx ONLY if the handler signalled that an

(statusCode int, sideEffectCommitted bool)

Source from the content-addressed store, hash-verified

129// upstream send accepted, or the loopback DB rows landed). Otherwise
130// Release so the caller can retry with the same key.
131func shouldCacheResponse(statusCode int, sideEffectCommitted bool) bool {
132 if statusCode < 400 {
133 return true
134 }
135 return sideEffectCommitted
136}
137
138// markSideEffectCommitted is called by handlers immediately after an
139// irreversible action succeeds (an upstream SMTP/SES accept, a

Callers 2

TestShouldCacheResponseFunction · 0.85
idempotencyGuardMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestShouldCacheResponseFunction · 0.68