XNews

5 design patterns for long-running agent harnesses from Google Cloud

5 design patterns for long-running agent harnesses from Google Cloud

Five real-world failures in long-running agent harnesses are addressed with design patterns: (1) Stable prefix—freeze layers of the system prompt by change rate so 95% of prompts hit the cache; if cached tokens are zero, the prefix is moving. (2) Background learning—switch memory extraction from inline to async write-behind, with a strong task reference, isolated sub-agent, and 120-second debounce to prevent slowdown. (3) Persistent workspace—divide workspace by user, not session, so deployments do not wipe installed tools; avoid using a shared status code like 502 to judge liveness. (4) Explicit failure—name each termination state (timeout, step exhaustion, pending approval, completion) and rewrite the summary with 'INCOMPLETE: do not report as completed'; enforce hard limits of 200 tool calls per round and 50 rounds per session. (5) Guard chain—normalize inputs before comparison, short-circuit by cost: egress guard (hard block), policy guard (allow/ask/deny), human confirmation (most expensive). No model is involved in the guard chain; credentials are designed under the assumption that guards will be breached, using environment injection and placeholder tokens.

Source posts