Assembly pipeline
The context assembly service is a Python gRPC process that turns a request, a directive, recent messages, and retrieved memories into model-ready context within a token budget.
What the status means: the pipeline exists and has local tests. It is not accepted as production-ready. Caller authentication at the service boundary and the deadline contract remain open.
Pipeline
budget calculation
→ parallel directive / hot-memory / cold-memory retrieval
→ composite scoring
→ relevance gate
→ packing
→ formatting
→ assembled context
The service exposes ContextAssemblyService with three RPCs:
| RPC | Purpose |
|---|---|
AssembleContext | Retrieve, rank, pack, and format context. |
SearchMemories | Retrieve memories without full assembly. |
RecordMemoryFeedback | Record usefulness after an outcome is known. |
Deadline behavior
The configured defaults are:
- Client/outer retrieval timeout:
IBEX_CONTEXT_TIMEOUT=45ms. - Server retrieval wall:
IBEX_CONTEXT_DEADLINE_MS=40ms. - Directive timeout:
5ms. - Hot-memory timeout:
15ms. - Cold-memory timeout:
45ms.
The effective retrieval wait is min(timeout, deadline), leaving headroom for packing and formatting under the proxy's 45ms client timeout. Slow branches are cancelled rather than allowed to consume the full budget.
Budget and packing
- The model capability catalog supplies context windows and tokenizer-family policy.
- Token estimates are deliberately conservative; they are estimates, not tokenizer-exact counts.
- The packer uses dynamic programming under a cell ceiling, then falls back to greedy packing for large candidate sets.
- An exact-budget repair step handles bucket rounding.
AssemblyOptionsexposes weights and caps. The weight fields are a forward contract; they do not override the memory relevance gate yet.
Formatting and prompt safety
Memory content is untrusted data. The formatter:
- Escapes attribute values and body text so a memory cannot forge closing tags.
- Opens each memory element with a per-assembly nonce.
- Serializes only; it never parses memory markup.
- Keeps directive, history, memory, and tool sections ordered and clearly delimited.
Memory content must never be interpreted as instructions by the proxy or model runtime.
Degradation
The proxy may proceed without context if retrieval or assembly fails. The intended behavior is directive-only or history-only context, with the failure recorded in metrics and traces. This fallback is part of the local behavior; it is not a measured hosted SLO.
Current limits
- Caller authentication and principal propagation at the context boundary are incomplete.
- The deadline configuration and caller expectations have a known discrepancy.
- Composite scoring still uses an interim schema until all components are wired.
- No hosted p99 or end-to-end assembly SLO is published.
- The context service is provisional, not a stable public integration contract.

