Skip to content

Context Package Schema

A Context Package is the knowledge-enriched, governed, and budgeted bundle of information that the Knowledge Platform assembles for an agent task before execution. It is the mechanism by which the factory grounds autonomous agents in prior decisions, reusable patterns, relevant code, and runtime feedback — instead of relying on the model's parametric memory alone.

sequenceDiagram
    participant AM as Agent Mesh
    participant CB as ContextBuilderService
    participant KG as KnowledgeGraphService
    participant VM as VectorMemoryService
    participant MI as MetadataIndexService
    participant GOV as MemoryPolicyService
    AM->>CB: BuildContextPackage(request)
    CB->>KG: graph neighborhood (project, module, decisions)
    CB->>VM: semantic search (blueprints, docs, patterns)
    CB->>MI: structured filter (artifacts, tasks)
    CB->>GOV: evaluate access + classification
    GOV-->>CB: allowed sources (redacted as needed)
    CB-->>AM: ContextPackage (sources, budget, ttl)
Hold "Alt" / "Option" to enable pan & zoom

Build request

{
  "contextBuildRequestId": "ctxreq-19a2",
  "tenantId": "connectsoft",
  "projectId": "proj-booking-saas",
  "moduleId": "module-reservations-api",
  "agentId": "ConnectSoft.Agent.SolutionArchitect",
  "skillId": "ConnectSoft.Skill.DesignServiceBlueprint",
  "taskId": "task-4d21",
  "traceId": "trace-9f1c2b7d",
  "intent": "Design the service blueprint for reservations",
  "scope": ["project", "boundedContext:Reservations"],
  "retrieval": {
    "semantic": true,
    "graph": true,
    "metadata": true,
    "tokenBudget": 16000,
    "maxSources": 40
  }
}

Context package

{
  "contextPackageId": "ctx-31f8",
  "contextBuildRequestId": "ctxreq-19a2",
  "tenantId": "connectsoft",
  "projectId": "proj-booking-saas",
  "traceId": "trace-9f1c2b7d",
  "createdAt": "2026-06-11T00:00:00Z",
  "ttlSeconds": 1800,
  "tokenBudget": 16000,
  "tokensUsed": 14210,
  "sources": [
    {
      "contextSourceId": "src-001",
      "kind": "DecisionRecord",
      "ref": "art-decision-eventbus-22",
      "title": "Use MassTransit on Azure Service Bus",
      "score": 0.92,
      "classification": "Internal",
      "tokens": 850,
      "origin": "graph"
    },
    {
      "contextSourceId": "src-002",
      "kind": "ServiceBlueprint",
      "ref": "art-serviceblueprint-orders-7",
      "title": "Orders service blueprint (reuse)",
      "score": 0.88,
      "classification": "Internal",
      "tokens": 2200,
      "origin": "semantic"
    }
  ],
  "graphProjectionId": "gp-7781",
  "policyDecisionId": "mad-5521"
}

Field contract

Field Purpose
contextPackageId Stable id; cacheable in Redis as a hot context.
ttlSeconds Freshness window; expired packages are rebuilt.
tokenBudget / tokensUsed Hard budget the builder honors so prompts stay within model limits.
sources[] The selected, ranked, access-checked knowledge items.
sources[].kind Source type: DecisionRecord, ServiceBlueprint, CodeSymbol, Documentation, KnowledgePattern, RuntimeSignal, PromptTemplate, etc.
sources[].origin How it was retrieved: graph, semantic, metadata, pinned.
sources[].score Relevance/ranking score.
sources[].classification Sensitivity; governs whether content was included or redacted.
graphProjectionId The graph neighborhood projection used.
policyDecisionId The memory access decision that authorized the package.

Governance and traceability

  • Every source is checked against a MemoryAccessPolicy; the resulting MemoryAccessDecision (policyDecisionId) and MemoryAccessAudit make context assembly fully auditable.
  • The package is linked to its taskId and traceId, so the Observability & Feedback Platform can later attribute artifact quality and runtime outcomes back to the exact context that produced them — closing the improvement loop.