#2118·Pulse

AI Patrol: prompt caching may not be reducing cost for the default scheduled call pattern

Author: BraedachCreated Sep 18, 2026Updated Sep 22, 2026

Hi — first off, thanks for Pulse, it's been genuinely useful running on our homelab. This issue is a "thought you'd want to know" rather than a complaint — we noticed AI Patrol using more tokens than we expected, dug into it a bit, and wanted to share what we found in case any of it's useful. Very possibly some of this is already understood or already being addressed, in which case feel free to close.

Disclosure: this was investigated with AI assistance (Claude, via Claude Code) reading our own production logs (Pulse 6.4.1) and the current main branch source — not a byte-exact diff against the 6.4.1 tag, so a few specifics may have shifted since. Take the details as a starting point to verify rather than a precise bug report.

What we measured (from production logs, Info level):

A single "quiet" Patrol triage turn costs ~6,400–6,500 input tokens, while Pulse's own seed_context_estimated_tokens metric for that same run reports only ~520–635 tokens. So roughly 90% of a triage call's input tokens appear to be fixed overhead (system prompt + tool schemas), not the actual monitoring signal being analyzed.

What we found reading the source (happy to be corrected on any of this):

Prompt caching is already implemented — internal/ai/providers/anthropic.go marks the last tool with cache_control: {type: "ephemeral"}, which is great to see. But a few things suggest it may not be paying off for Patrol's actual call pattern:

  1. The system prompt itself doesn't carry a cache_control marker. agentic_prompt.go notes that the base prompt is frozen at service start with only mode/current-time appended per call — that sounds like an ideal caching candidate, but req.System is sent as a plain string, and Anthropic's caching for system requires it to be a content-block array with its own breakpoint.
  2. The default Patrol interval (6h) is longer than Anthropic's cache TTL (5 min standard; we didn't see the extended-cache-ttl beta header anywhere, which would allow 1h). A cache written by one scheduled run would have expired long before the next one reads it — and cache writes carry a premium over a plain input token, so the scheduled-only path may currently pay slightly more than an uncached call would, for no benefit.
  3. The triage pass (14 tools) and the follow-up eval pass (1 tool), fired seconds apart in the same run, use different tool arrays — so they don't share a cache prefix even though they're well within the TTL window of each other.
  4. The one place this seems like it'd matter most: a full investigation can run up to 17 turns (per docs/AI.md), and consecutive turns there are seconds/minutes apart — comfortably inside the cache TTL. If the tool list and system-prompt base are stable turn-to-turn, fixing #1 should meaningfully cut the cost of exactly the most expensive scenario (a real multi-turn investigation), with no change to what the model actually sees.

One observability note: anthropic.go already parses cache_creation_input_tokens/cache_read_input_tokens back from the API response, but logs them at Debug level — invisible in a normal production deployment. Promoting that to Info (or feeding it into the existing ai_patrol_cost_preview/telemetry machinery) would make it possible to actually verify any of the above from a real deployment, rather than guessing.

Smaller/secondary observations, lower confidence, purely FYI:

  • The 14 tool schemas sent look like they cover all supported resource types (Kubernetes, vSphere, TrueNAS, etc.) regardless of what's actually configured — scoping to configured integrations only would shrink the block being resent/cached.
  • seed_context_estimated_tokens (shown in logs, and presumably surfaced via the cost-preview UI) appears to undercount actual billed input tokens by roughly 10x based on what we measured — might be worth a look if it's used anywhere to help users estimate cost.

Happy to help verify any of this further, and happy to send a PR for the system-prompt caching piece if that'd be useful — just didn't want to open one blind without checking it matches your intent for how the AgenticLoop is meant to work.

Thanks again for the project!