Back to blog
EngineeringJan 9, 2025· min read

When Your Telemetry Has Been Silent Since Launch

We shipped migration 044 to production last night. It touched 4,020 rows in agent_memory. Every single one had an access_count of zero. The RPC that was supposed to increment those counters? It had been failing silently since the day we launched the feature.

We shipped migration 044 to production last night. It touched 4,020 rows in agent_memory. Every single one had an access_count of zero. The RPC that was supposed to increment those counters? It had been failing silently since the day we launched the feature.

This is not a story about a catastrophic failure. The memory system worked fine—agents could read and write memories without issue. This is a story about telemetry you thought you had, infrastructure assumptions that turned out to be wrong, and what happens when you finally look at the data and realize it's been quiet the whole time.

The Missing Increment

Agent memory is fundamental to how Strug Works operates. When an agent completes a task, it writes what it learned to memory. When it starts a new task, it reads relevant context back. We track two counters on every memory entry: write_count (how many times this memory has been updated) and access_count (how many times it's been read).

The write_count worked perfectly—hundreds of entries showed 2, 3, 5 writes as agents refined their understanding. But access_count? Zero across the board. Four thousand twenty rows. Zero reads.

Except we knew agents were reading memories. We could see it in the logs. The memory_read calls were happening, returning the right data, working as intended. The problem was the increment—the stored procedure that was supposed to bump those counters after every read.

Five Things We Hardened

PR #243 fixed the missing increment and hardened the entire flow. Here's what changed:

1. SECURITY INVOKER — The original RPC ran with SECURITY DEFINER, which meant it executed with the permissions of whoever defined it, not whoever called it. That's fine for some operations, but it meant permission errors were masked. We switched to SECURITY INVOKER so the RPC runs with the caller's permissions. If there's a permission problem, we find out immediately.

2. valid_to IS NULL filter — Agent memory is append-only with temporal versioning. When you update a memory, the old row gets a valid_to timestamp and a new row gets created with valid_to = NULL. The increment RPC wasn't filtering for valid_to IS NULL, which meant it could theoretically increment counters on stale rows. That never happened in practice, but the lack of the filter meant the query plan was suboptimal.

3. 100-ID batch limit — The RPC accepts an array of memory IDs to increment. We added a check: if you pass more than 100 IDs, the function rejects the call. This prevents accidental bulk operations from locking the table or timing out. If you need to increment more than 100 counters in one operation, you're probably doing something wrong.

4. Preserved updated_at for counter-only updates — When we increment access_count, we're not changing the content of the memory—just the telemetry. The original RPC would update the updated_at timestamp, which made it look like the memory had been modified when it hadn't. Now we preserve the original updated_at for counter-only operations. The last_accessed_at timestamp tracks read activity separately.

5. Logged RPC failures — The Python service layer now logs when increment_memory_access fails. We don't halt execution—the read operation already succeeded, and incrementing the counter is telemetry, not critical path. But we log it at WARNING level so we know when things go wrong.

Migration 044: Backfilling the Silence

The hardened RPC fixed the problem going forward. But we still had 4,020 rows with access_count = 0 that should have been higher. We couldn't reconstruct the true access counts—the increments had failed silently, so there was no log to replay. But we could fix the data model.

Migration 044 did one thing: it found every row in agent_memory where access_count = 0 AND last_accessed_at IS NOT NULL. That combination is impossible under the new logic—if last_accessed_at has a value, access_count should be at least 1. The migration set access_count = 1 for those rows.

It's not perfect. Some of those memories were probably accessed dozens of times. But 1 is more correct than 0, and it brings the data into consistency with the new invariant: if you've been accessed, your counter reflects that.

What This Actually Means

The agent memory system worked the entire time. Agents could always read and write. The feature itself was never broken. But the telemetry that was supposed to tell us how the feature was being used? That was silent from day one.

This is the kind of issue you don't catch in development. You write the increment function, you test it in isolation, it works. You ship the feature, users (agents, in our case) start using it, everything looks fine. The silent failure only shows up when you finally look at the aggregate data and ask: why are all these counters zero?

We caught it because we're dogfooding our own platform. Strug Works agents use agent memory constantly. When I looked at the memory dashboard and saw 4,020 rows with zero access counts, I knew something was wrong—not because a customer complained, but because I could see the data didn't match reality.

What's Next

The hardened RPC is in production now. New memory reads increment correctly. The migration brought the historical data into consistency. But we're not done.

Next up: telemetry validation checks that run automatically after every deploy. If a counter that should be incrementing stays at zero, we want to know within hours, not months. We're building that into the platform health dashboard now.

Because the hardest bugs to catch aren't the ones that break your app. They're the ones that fail silently and train you to trust data that's quietly lying to you.