# Context Budget Governance

> Design and review context budget governance for agent prompts and model calls. Use when assembling long conversation context, tool results, retrieved evidence, memory, task state, system rules, multimodal observations, or compressed summaries under a token budget.

- **Type:** Skill
- **Install:** `agentstack add skill-hsienw-ai-agent-engineering-playbook-context-budget-governance`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [HsienW](https://agentstack.voostack.com/s/hsienw)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [HsienW](https://github.com/HsienW)
- **Source:** https://github.com/HsienW/ai-agent-engineering-playbook/tree/master/skills-runtime-governance/context-budget-governance

## Install

```sh
agentstack add skill-hsienw-ai-agent-engineering-playbook-context-budget-governance
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Context Budget Governance

## Skill Interface

- Name: context-budget-governance.
- Description: Design and review context budget governance for agent prompts and model calls that assemble conversation context, tool results, retrieved evidence, memory, task state, system rules, multimodal observations, and compressed summaries under a token budget.
- Parameters: Token budget, output reserve, candidate context blocks, priority model, relevance and recency scores, safety filters, compression policy, source identifiers, and verification scenarios.
- Instructions: Use this skill when a model call must fit useful context into a fixed budget. Prioritize safety and current task state, normalize blocks, redact before inclusion, compress lower-priority content, drop low-value blocks last, and record what changed.

Context assembly is a policy decision. The model should receive the most
important safe context under a budget, with deterministic degradation when the
budget is exceeded.

## Priority Model

Use explicit priorities:

| Priority | Content |
| --- | --- |
| P0 | System and security rules |
| P1 | Current task, user request, and task state |
| P2 | Relevant contracts, schemas, and caller-injected rules |
| P3 | High-value retrieved evidence and memory |
| P4 | Recent conversation summary |
| P5 | Low-value raw tool output |

P0 and P1 should remain unless the request is impossible to serve safely.

## Assembly Process

1. Define token budget and reserve output space.
2. Normalize all candidate context into typed blocks.
3. Score blocks by priority, recency, relevance, and safety.
4. Redact sensitive fields before inclusion.
5. Compress lower-priority blocks when over budget.
6. Drop low-value blocks only after compression options are exhausted.
7. Record what was included, compressed, or dropped.

## Compression Rules

- Preserve requirements, constraints, and evidence references.
- Compress raw tool output before dropping task-critical context.
- Keep source identifiers and timestamps when evidence freshness matters.
- Do not summarize secrets into the prompt.
- Do not allow untrusted retrieved content to override system or developer
  instructions.
- Keep current user intent separate from historical summaries.

## Verification

Test ultra-long conversations, large tool outputs, many retrieved sources,
multimodal observations, malicious retrieved instructions, missing budget,
over-budget P0/P1 content, deterministic compression, and traceability of
included and dropped blocks.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [HsienW](https://github.com/HsienW)
- **Source:** [HsienW/ai-agent-engineering-playbook](https://github.com/HsienW/ai-agent-engineering-playbook)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-hsienw-ai-agent-engineering-playbook-context-budget-governance
- Seller: https://agentstack.voostack.com/s/hsienw
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
