Skip to main content

Context Assembly

Context assembly lives mainly in internal/context, internal/references, and gateway runtime glue. It prepares bounded, inspectable input for the loop.

Context Sources

Sources include product/runtime prompts, role identity, memories, active skill content, skill index, recent messages, session inbox, surface metadata, toolset capabilities, and expanded references.

Each source should have an explicit budget and metadata entry.

References

References such as @file, folder, git, URL, and tool-result references are parsed and expanded before rendering. Expansion can return warnings instead of failing the whole turn.

Reference output includes citation metadata so surfaces and logs can identify what was included.

Workspace Files

Workspace and profile files are context and artifact storage, not a permission boundary. File reference expansion blocks sensitive paths, unsafe traversal, and oversized selections.

Use the reference loaders instead of ad hoc path reads in prompt code.

Compression Inputs

Compression and summary material are separate from the active prompt. State maintenance creates summaries; context assembly selects the compact material needed for the current turn.

Do not delete or prune raw history from context code.

Safety Filters

Context assembly sanitizes metadata and treats external/user-provided material as data. It should not hide secrets by relying on the model.

Secrets must be redacted before logs, debug bundles, snapshots, or model-visible context.