Using CoreTex In An Agent
The normal agent lifecycle is:
before model call: prefetch(query) -> inject rendered cited context
after model call: sync_turn(messages, tools, documents)
session boundary: flush_session() -> M3 boundary + durable checkpoint
periodically: resolve public state -> update authority -> restart if needed
Use ./coretex/.venv/bin/python for a minimal Python integration:
from coretex_consumer.config import load_config, load_authority
config = load_config("./coretex/consumer.json")
authority = load_authority(config)
assert authority is not None # fresh public current-state authority
with authority.open_memory(config["profile"], config["store"]) as memory:
memory.sync_turn(
messages=[{"role": "user", "content": "The deployment window is Friday."}]
)
recalled = memory.prefetch("deployment window", budget=128)
print(recalled.render())
Applications usually call AgentMemory directly or through the packaged
localhost sidecar:
prefetch(query, budget, as_of=None)returns cited, budget-bounded context;sync_turn(...)ingests messages, tool calls, tool results, and documents;flush_session()runs the session-end M3 boundary and checkpoints;health()reports store and active-release health; andcapabilities()reports the active hooks and consolidation policy.
Always inject the authoritative rendered context returned by prefetch.
Preserve citations through accounting, send only raw events into sync_turn,
and assign separate scopes to unrelated users.
Non-Python applications can use the packaged localhost sidecar or wrap the same five operations in their own process boundary. The sidecar remains bound to localhost as a private integration seam.