Skip to content
SHAMPOO

Tool catalogue

build_context_pack

Write · Advanced · Intel and knowledge tiers

build_context_pack

  • Category: intel
  • Access: write
  • Audience: advanced (ordinary users do not normally call this directly)

Purpose

Compiles a role-specific context pack under a token budget from facts, claims, questions, and chunks. Call it to assemble grounded context for planning, review, execution, or handoff.

Arguments

Optional: pack_type, session_id, target_ref, token_budget.

  • pack_type.
  • session_id. Note: Must be owned by the caller (star bypasses); unowned reads as session not found.
  • target_ref. Note: Task id scoping the pack; absent means unscoped.
  • token_budget. Note: Unset or 0 means 4000; negatives pass through and select nothing.

Result

Object with pack_id (null when suppressed), pack_type, token_budget, token_usage, items_included, preview_items_included, task_scoped, persisted, freshness/relevance/quality scores, previewable, contract_version, selection_policy, advanced_context, sections, and body.

Boundaries

Operates inside the selected profile boundary. Task-scoped relevance uses the caller's visible tasks and linked entities only.

Lifecycle / side effects

Selects facts, claims, questions, and chunks greedily under the token budget, persists the pack with its summary artifact and provenance when anything was visible, retires stale packs of the same kind, and records a run-history entry. Empty packs are not persisted and carry pack_id null.

Errors

Unknown pack_type rejected with a normal error payload. Unowned session_id answers session not found. pack_type values are planner, reviewer, executor, bridge_checker, handoff.

Example

{
  "pack_type": "executor",
  "token_budget": 4000
}

Result shape:

{
  "items_included": 6,
  "pack_id": "<uuid>",
  "persisted": true,
  "task_scoped": false,
  "token_usage": 812
}

See also

enrich_context, resume_context, explain_impact, assess_context.

On this page