Skip to main content

Scope: process-local, in-memory, opt-in

get_global_store() returns the low-level ContextStoreImpl singleton. Before you use it, know exactly what it is:
  • In-memory, scoped to the current process. It is not persisted automatically and is never shared with another process. A separate praisonai CLI process can therefore never see a store an agent run populated. Cross-process sharing requires explicit snapshot() / restore().
  • Nothing in the agent runtime writes to it. Agent.chat_history and the session/memory subsystems keep their own state. This store is an opt-in structure a caller must populate — via store.get_mutator(agent_id).append(...).commit() or store.add_shared_context(...).
  • Empty on first creation. It only holds what a caller put in it during this process. The same singleton is returned on later calls, so it may already contain data from earlier in the process.

Populate the store

Cross-process sharing

The store lives in one process only. To move it to another process, serialise it with snapshot() and rebuild it with restore():

Context Management API

Complete reference for CLI commands, flags, environment variables, and configuration options.

Scope: process-local, in-memory, opt-in

get_global_store() returns a singleton that is easy to misread. Three facts govern its behaviour:
  1. In-memory, process-local. The store lives only in the current process. It is not persisted and not shared, so a separate praisonai CLI process can never see a store an agent run populated. Cross-process sharing requires explicit snapshot() / restore().
  2. Nothing in the agent runtime writes to it. Agent.chat_history and the session/memory subsystems keep their own state. This store is opt-in — a caller must populate it via get_mutator(...) or add_shared_context(...).
  3. Empty until you fill it. A freshly created store holds nothing; the same singleton is returned on later calls, so it may already contain data you added earlier in this process.
Populate the store:
Cross-process sharing with snapshot() / restore():

The user inspects or trims context via CLI and config; the agent stays within the configured window.

How It Works

Quick Start

1

Enable context flags in chat

2

Inspect usage in session

CLI Flags

Auto-Compaction

Interactive mode (praisonai chat, praisonai code) actually enforces the flag inside the worker loop — proactive check every turn plus a reactive retry on provider context-length errors. In non-interactive workflow runs the same flag is applied via the standard ContextManager config.

Optimization Strategy

Trigger Threshold

Monitoring

Redaction

Output Reserve

Interactive Commands

Examples

Environment Variables

Configuration File

Precedence Order

Configuration is resolved in this order (highest to lowest):
  1. CLI flags (--context-strategy smart)
  2. Environment variables (PRAISONAI_CONTEXT_STRATEGY=smart)
  3. Config file (config.yaml)
  4. Defaults

Python SDK

Complete Example

Best Practices

Call ledger.track_history after each assistant message so budgets and snapshots stay accurate.
Write monitor snapshots on turn boundaries or overflow — not on every token delta.
Allocate budgets before the run and attach a monitor when debugging context growth.
Use the high-level Agent context= config in production; drop to the raw API only for custom integrations.

Context Management

Overview of context management features

Context Monitor

Real-time context snapshots for debugging