Compile Context Bundle (Experimental)
context_bundleCompile a versioned context bundle from project memory for a task, with source attribution and a selection/drop audit. Use to inject relevant context into agent sessions without a network call.
Instructions
Experimental Context Bundle v1 compiler. Requires schema_version=1 and a non-blank task. Returns a policy-bounded, source-attributed ContextBundle with a complete selection/drop audit; project is explicit or derived from cwd, and role/risk/token budget have deterministic defaults. Historical as_of_epoch pins and include_superseded=true fail loudly until the canonical loader supports them. This reuses the production SessionStart canonical loader, performs no foreground LLM or network call, and returns canonical load failures as a blocked audited bundle. Its poisoning safety check may quarantine unsafe persisted rows, so callers must not treat it as side-effect-free. The JSON shape is versioned but remains experimental.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory used for canonical loading and project derivation. | |
| risk | No | Risk class: low, medium, or high (default medium). | |
| role | No | Agent role: coder, reviewer, planner, or researcher (default coder). | |
| task | Yes | Task description used for SessionStart relevance selection. | |
| branch | No | Optional Git branch scope filter. | |
| project | No | Exact project key/path. Defaults to the project derived from cwd. | |
| worktree | No | Optional worktree identity recorded in the versioned request. | |
| as_of_epoch | No | As-of epoch-seconds scope pin. Experimental v1 accepts only 0/omitted until historical canonical loading is implemented. | |
| token_budget | No | Total token budget for the bundle (default 4000). | |
| schema_version | Yes | Context Bundle request schema version; v1 requires 1. | |
| include_superseded | No | Allow superseded memories in scope. Experimental v1 accepts only false/omitted until canonical loading supports history. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audit | Yes | ||
| plan_hash | Yes | ||
| preferences | Yes | ||
| workstreams | Yes | ||
| memory_index | Yes | ||
| current_truth | Yes | ||
| degraded_mode | Yes | ||
| schema_version | Yes | ||
| failure_lessons | Yes | ||
| recent_sessions | Yes |