Skip to content
Navigation

The Context Engine (orbiter-context) gives agents structured, hierarchical memory that persists across LLM calls. It manages state, prompt assembly, token budgets, workspace artifacts, knowledge retrieval, checkpointing, and context-aware tools — all coordinated through a single Context object.

Why Use Context?

Without the context engine, each agent turn starts from scratch. With it you get:

  • Hierarchical state — parent/child contexts with inherited key-value data.
  • Composable prompts — neurons assemble prompt sections by priority.
  • Event-driven processors — run logic before/after LLM calls and tool invocations.
  • Workspace artifacts — versioned file storage with observer notifications.
  • Knowledge retrieval — TF-IDF search over ingested documents.
  • Token tracking — per-agent, per-step usage accounting.
  • Checkpointing — save and restore context snapshots.
  • Context tools — planning, knowledge, and file tools the agent can call.

Quick Start

python
from orbiter.context import Context, ContextConfig, make_config, AutomationMode

# Create a context with sensible defaults
config = make_config(AutomationMode.COPILOT)
ctx = Context(task_id="task-1", config=config)

# Store and retrieve state
ctx.state.set("user_name", "Alice")
print(ctx.state.get("user_name"))  # "Alice"

# Fork a child context for a sub-task
child = ctx.fork("subtask-1")
child.state.set("step", 3)

# Child inherits parent state
print(child.state.get("user_name"))  # "Alice" (inherited)

# Merge child results back
ctx.merge(child)

Architecture Overview

code
Context
  |-- config: ContextConfig     (immutable settings)
  |-- state: ContextState       (hierarchical key-value store)
  |-- children: list[Context]   (forked child contexts)
  |-- token_usage: TokenTracker (per-step token accounting)
  |
  +-- PromptBuilder             (assembles prompt from neurons)
  +-- ProcessorPipeline         (event-driven pre/post processing)
  +-- Workspace                 (versioned artifact storage)
  +-- KnowledgeStore            (text search + TF-IDF scoring)
  +-- CheckpointStore           (save/restore snapshots)
  +-- Context Tools             (planning, knowledge, file tools)

Automation Modes

The AutomationMode enum controls how much autonomy the agent has:

ModeDescriptionHistory RoundsSummary Threshold
PILOTFull autonomy, minimal history35
COPILOTBalanced autonomy and context1015
NAVIGATORMaximum context, human-guided2030
python
from orbiter.context import make_config, AutomationMode

pilot_cfg = make_config(AutomationMode.PILOT)
copilot_cfg = make_config(AutomationMode.COPILOT)
navigator_cfg = make_config(AutomationMode.NAVIGATOR)

Guides

GuideWhat It Covers
State ManagementHierarchical key-value state, parent inheritance, fork/merge
Prompt BuildingNeurons, priority ordering, variable substitution
ProcessorsEvent-driven pipeline (pre_llm_call, post_tool_call, etc.)
WorkspaceVersioned artifact storage, observers, filesystem persistence
KnowledgeText chunking, TF-IDF search, knowledge store
CheckpointsSnapshot save/restore, version history
Token TrackingPer-agent per-step usage, trajectories, summaries
Context ToolsPlanning, knowledge, and file tools for agents

API Summary

SymbolModuleDescription
Contextorbiter.contextCentral context object with state, children, and token tracking
ContextConfigorbiter.contextFrozen configuration (mode, history_rounds, thresholds)
ContextStateorbiter.contextHierarchical key-value store with parent inheritance
PromptBuilderorbiter.contextAssembles prompts from neurons with priority ordering
Neuronorbiter.contextABC for named prompt sections with priority
neuron_registryorbiter.contextRegistry of built-in and custom neurons
ContextProcessororbiter.contextABC for event-driven context processing
ProcessorPipelineorbiter.contextManages and fires processors by event
SummarizeProcessororbiter.contextBuilt-in processor for pre_llm_call summarization
ToolResultOffloaderorbiter.contextBuilt-in processor for post_tool_call result offloading
Workspaceorbiter.contextVersioned artifact storage with observer pattern
ArtifactTypeorbiter.contextEnum: CODE, CSV, IMAGE, JSON, MARKDOWN, TEXT
TokenTrackerorbiter.contextPer-agent per-step token usage tracking
Checkpointorbiter.contextFrozen snapshot of context state
CheckpointStoreorbiter.contextSave, list, and restore checkpoints
make_configorbiter.contextFactory for preset configurations by automation mode
AutomationModeorbiter.contextEnum: PILOT, COPILOT, NAVIGATOR
get_context_toolsorbiter.contextReturns all context tools (planning + knowledge + file)
get_planning_toolsorbiter.contextReturns planning tools (add_todo, complete_todo, get_todo)
get_knowledge_toolsorbiter.contextReturns knowledge tools (get, grep, search)
get_file_toolsorbiter.contextReturns file tools (read_file)