Run / Context assembly

R03 / Run

Context assembly

Guild Stack gives each specialist a focused context bundle before dispatch: task lane, required skills, relevant wiki pages, and no project-wide dump.
First move
Compare lane input with returned handoff
Expected receipt
.guild/context/<run-id>/
Last verified
Jun 10, 2026

Page evidence and guidance

Read as StartWhy context is focused and what project material can be included. SteerUniversal, domain, and task layers plus freshness and budget controls. ExtendSource precedence, selectors, schemas, token accounting, and provenance.

Use this page to inspect what a specialist saw before it worked, what Guild Stack intentionally left out, and what the specialist handed back when the lane finished.

Every dispatched lane receives a focused context bundle. The bundle is a file, not a vague memory state:

.guild/context/<run-id>/<specialist>-<task-id>.md

Dispatch passes that path by pointer. When a result looks wrong, compare the bundle with the handoff receipt instead of guessing what the agent remembered.

Operational mapGive each lane the smallest complete brief.
  1. Task lanescope + acceptance
  2. Recallrelevant wiki + graph
  3. Bundlefiles + constraints
  4. Specialistbounded execution
  5. Receiptchanges + omissions
Context assembly gives each specialist a bounded three-layer bundle, then the handoff receipt records what came back.
Diagram notes and sources

Reduced motion: Renders the final capped bundle and drop order as static numbered labels; no cap-fill or drop animation plays.

  • docs/v2/knowledge-memory.md
  • docs/v2/dispatch-execution.md
  • architecture/modules/context.md

What goes into a bundle

A bundle has three layers:

LayerContentSize
UniversalProject identity, run rules, and conventions every lane needs.Small fixed layer.
RoleThe specialist’s standards, required playbooks, and role-specific knowledge.Protected; not dropped for task material.
TaskLane objective, source refs, upstream depends_on contracts, matched wiki pages, decisions, and graph-derived hints.First to shrink under pressure.
  • Target total: ~3k tokens.
  • Hard cap: 6k tokens.
  • Graph sub-cap: 1200 tokens for graph-derived material.
  • Proof cue: the deterministic linter checks the finished bundle budget before dispatch.

Included and omitted facts

For a backend lane that implements an approved auth endpoint, the bundle might include:

IncludedWhy
The lane objective from .guild/plan/<slug>.md.Keeps the specialist tied to approved scope.
depends_on from the architecture lane.Carries upstream contract decisions forward.
Relevant .guild/wiki/** decisions about auth and security.Uses canonical project memory before broad reads.
The specialist playbook and role boundary.Prevents a backend lane from turning into release or copy work.
Named source refs from the plan.Gives enough files to start without a project dump.

It might omit:

OmittedWhy
Unmatched wiki pages.They are not relevant enough for this lane.
Extra graph nodes beyond the sub-cap.Graph material is useful but droppable.
Raw project-wide transcripts.The bundle is a focused task brief, not a context dump.
Conflicting low-trust recalled chunks.Protection quarantines or wraps untrusted content before prompt use.

Budget pressure is deterministic: protect role content, keep matched decisions and open questions, drop graph material first, and record omissions under dropped_for_budget:. Nothing disappears silently.

Recall before read

Context assembly starts from recall. A lane queries project knowledge before opening broad source files. The current implementation combines several channels into one protected result:

Operational mapRetrieve evidence without replacing its source.
  1. Querytask intent
  2. Wiki searchcanonical pages
  3. Rankgraph + BM25
  4. Contextbounded bundle
  5. Citationssource refs
Recall rail: query, rank, assemble, inject — wiki canon outranks the graph projection and the recall bundle.
Diagram notes and sources

Reduced motion: Renders all nodes and precedence labels immediately; no draw or lift animation.

  • docs/v2/knowledge-memory.md
  • docs/v2/codebase-understanding.md
  • architecture/modules/knowledge.md
  • architecture/modules/learning.md
ChannelWhat it readsWhy it matters
Structuralknowledge-graph.json for callers, callees, impact, and dead-code style questions.Gives code-structure answers without spending model context first.
Wiki waterfallSQLite FTS, then file BM25, then filesystem scan over .guild/wiki/**.Keeps .guild/wiki/** canonical while allowing rebuildable indexes.
Knowledge recallknowledge-recall.json through the KnowledgeGraph ranking path.Adds ranked graph context after the wiki branch.
Memory transportMCP, HTTP-MCP, bridge, or filesystem BM25 depending on host capability.Records degraded retrieval when a stronger transport is unavailable.

Every recalled chunk passes through protectChunks before it reaches the prompt. The protection step probes for injection, classifies trust tier, quarantines flagged content, and wraps non-operator content. That is why the bundle can include project memory without treating every file as equally trusted.

The paired handoff receipt

The bundle is only half of the story. A finished lane writes a receipt under the run directory:

.guild/runs/<run-id>/handoffs/<specialist>-<task-id>.md

The useful debug pair is:

Before workAfter work
.guild/context/<run-id>/<specialist>-<task-id>.md.guild/runs/<run-id>/handoffs/<specialist>-<task-id>.md
What the specialist was allowed to see.What the specialist claims it did, learned, assumed, or could not complete.
Includes source refs and omissions.Includes output, assumptions, learnings, escalation notes, and receipt metadata.

Power Users can diff these files between runs to explain changed behavior. Beginner Users can open the handoff to see the work trail without reading every source file. Harness Developers can treat the bundle path plus handoff receipt as the stable cross-host communication boundary.

What the specialist sees

The bundle is the authoritative task brief. Ambient host context can still exist, such as a repo’s AGENTS.md, host memory, plugin skills, and configured MCP servers, but Guild Stack tells the specialist to privilege the bundle when there is a conflict and surface contradictions in its handoff receipt.

On team backends, the launcher restates the bundle path and required playbooks in the pane prompt. The file path is the shared contract across host shapes.

What this is not

  • It is not a guarantee that a host has no ambient context.
  • It is not an authoritative database; .guild/wiki/** is canonical, while indexes and recall projections are derived and rebuildable.
  • It is not auto-promotion. Learning can propose candidates, but promotion into durable wiki or policy remains human-gated.
  • It is not a claim that every host has the same memory transport. Capability gaps degrade with an observable signal.

Why this design

BenefitHow context assembly delivers it
Specialists stay on taskThe lane receives a short bundle with its objective, role material, and named refs.
Runs are reproducibleThe prompt points at a concrete .guild/context/<run-id>/... file.
Failures are debuggableYou can diff bundles, receipts, and source refs between runs.
Costs stay boundedRecall and graph material are capped before dispatch.
Memory stays honestCanonical wiki files remain the source of truth; derived indexes only speed lookup.

Source truth

  • docs/v2/architecture/modules/context.md - module contract, protected recall, budget linter, and bundle path.
  • docs/v2/dispatch-execution.md - task-agent lifecycle, dispatch-by-pointer, recall-before-read, and receipt handoff.
  • docs/v2/architecture/modules/communication.md - file-first handoff envelopes, receipts, and artifact bus boundaries.

See also