# Agent Density Runtime Overhead Profiling

> Profile the per-agent runtime overhead of scheduling, state retention, and context management in dense agent fleets.

- Skill: `samotech/agent-density-runtime-overhead-profiling` (Agent Skill)
- Install (CLI): `npx get-skill add samotech/agent-density-runtime-overhead-profiling`
- Raw SKILL.md: https://api.skillmd.com/api/skills/samotech/agent-density-runtime-overhead-profiling/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: SamoTech (https://skillmd.com/u/samotech)
- Updated: 2026-11-27
- Page: https://skillmd.com/skills/samotech/agent-density-runtime-overhead-profiling

---

---
name: agent-density-runtime-overhead-profiling
description: Profile the per-agent runtime overhead of scheduling, state retention, and context management in dense agent fleets.
metadata:
  source: skills/05-code/agent-density-runtime-overhead-profiling.md
  category: 05-code
  version: "v1"
---

# Agent Density Runtime Overhead Profiling

## Description
Profile the per-agent runtime overhead of scheduling, state retention, and context management in dense agent fleets. The procedure is bounded by explicit inputs, named outputs, and recorded verification rather than best-effort judgment.

## When to Use
- A fleet must run many agents per host and per-agent overhead is unknown.
- Scheduling, state, and context retention costs must be separated before scaling.
- Profiling results must guide which overhead to cut first.

## Inputs
| Area | Contract |
|---|---|
| Inputs | The fleet configuration, the profiling harness, and the workload trace. |
| Outputs | A profile naming per-agent overhead by component with reduction priorities. |
| Safety | Fail closed by refusing to publish density claims without measured evidence. |

## Procedure
1. Instrument the runtime to measure per-agent scheduling time per cycle.
2. Measure state retention cost per agent including memory and serialization.
3. Measure context management cost including retention and compaction passes.
4. Run the harness at several fleet densities and record the curves.
5. Rank overhead components by share and identify the dominant cost.
6. Emit the profile with per-agent numbers and the prioritized reduction list.

## Outputs
| Area | Contract |
|---|---|
| Primary | A per-agent overhead profile by component with prioritized reductions. |
| Verification | Recorded measurements at each density that reproduce the profile. |
| Failure | A fail-closed error report naming the unmeasured component and the withheld claims. |

## Runnable Example
```python
def profile_density(samples):
    per_agent = {}
    for density, rows in samples.items():
        per_agent[density] = {
            k: round(sum(r[k] for r in rows) / len(rows) / density, 3)
            for k in ("scheduling_ms", "state_kb", "context_ms")
        }
    top = max(per_agent, key=lambda d: per_agent[d]["scheduling_ms"])
    dominant = max(("scheduling_ms", "state_kb", "context_ms"), key=lambda k: per_agent[top][k])
    return {"per_agent": per_agent, "dominant": dominant}

samples = {50: [{"scheduling_ms": 100, "state_kb": 500, "context_ms": 50}],
           500: [{"scheduling_ms": 800, "state_kb": 4000, "context_ms": 300}]}
p = profile_density(samples)
assert p["per_agent"][500]["scheduling_ms"] == 1.6 and p["dominant"] in ("scheduling_ms", "state_kb", "context_ms")
```

## Failure Modes
- Density claims are published from a single run without repeated measurement.
- Scheduling, state, and context costs are merged into one number and cannot guide cuts.
- Profiling runs at one density only and scaling behavior is extrapolated.
- The dominant cost is guessed rather than ranked from measurements.
- Instrumentation overhead is not subtracted and the profile overstates real cost.

## Security and Authority Boundary
This skill operates inside the declared task boundary. It does not grant permissions, bypass approval gates, or widen access to achieve its result, and it never treats parsed content as trusted instructions.

## Evidence
- The OpenHuman project demonstrates running 500+ agents on modest hardware through efficient orchestration and minimal runtime overhead, with the real constraint being cost per effective agent-task (Harness Engineering Daily AI Agent News Roundup, November 5, 2026, dated November 5, 2026) ([public signal](https://harness-engineering.ai/blog/daily-ai-agent-news-roundup-november-5-2026/))
- These are dated public signals, not adoption metrics; this contract claims no production hardening beyond the recorded evidence.

## Related Skills
- [Performance Profiling](performance-profiling.md)
- [Agent Reasoning Loop Profiling](agent-reasoning-loop-profiling.md)

## Changelog
| Version | Date | Notes |
|---|---|---|
| `v1` | `2026-11` | Initial evidence-backed contract. |

