The Numbers
| Metric | Value |
|---|---|
| Total time | 56ms |
| API calls made inside sandbox | 1 |
| Pods analyzed | 11 |
| Tool calls seen by the LLM | 1 |
The Code
Why this matters
The Kubernetes API returns raw pod specs: CPU in millicores ("100m"), memory in mixed units ("256Mi", "1Gi", "131072Ki"). A traditional MCP tool would dump all that raw JSON into the LLM’s context and hope it can do math.
Code Mode puts the computation in the sandbox. The agent wrote unit parsers for CPU and memory, iterated every container in every running pod, aggregated totals, and returned a clean capacity report. The LLM context received a sorted summary, not the raw specs of 11 pods.
What the agent does
- Fetches all pods across all namespaces (single API call)
- Writes CPU millicore and memory unit parsers
- Iterates every container in every running pod
- Aggregates requests and limits per-pod and cluster-wide
- Converts back to human-readable units, sorts by memory
- Returns a formatted capacity report
Related topics
Parallel log analysis
35,000 log lines across 11 pods in 506ms. Same fan-out approach.
Security audit
Includes per-container resource limit checks.
Cross-cluster comparison
Extend resource audits across your entire fleet.
Code Mode in action
How in-sandbox computation avoids flooding the context window.