Context

Context management for agent conversations

The context command manages conversation context for AI agents.

Usage

bash
praisonai context [OPTIONS] COMMAND [ARGS]...

Commands

CommandOptionsDescriptionExit code
show--verboseShow current context0
add—Add context from file or text0
clear—Clear current context0
list—List context sources0
stats--agent, --jsonShow token usage / cache statistics0
compact--agent <id>, --threshold, --dry-runCompact per-agent history in the process-local store0 on work done, 1 when empty or no match
exportOUTPUT, --agent, --formatSerialise the store to a file0 when written, 1 on a fully-empty store

Examples

Show current context

bash
praisonai context show

Add file to context

bash
praisonai context add myfile.py

Clear context

bash
praisonai context clear

Compact the store

bash
praisonai context compact                 # compact every agent's history
praisonai context compact --agent agent-1 # compact one agent
praisonai context compact --dry-run       # show what would be compacted

compact cleans per-agent history only. It prints Compaction complete (N agent(s)). and exits 0 when work was done.

Export the store

bash
praisonai context export context.json           # snapshot to JSON
praisonai context export report.txt --format txt # human-readable summary

Empty store

The CLI is explicit about empty-state situations instead of reporting false success:

SituationCommandResult
Fully empty storecompactExits 1: “The context store is empty in this process.”
Shared-context-only storecompactExits 1 — compaction cleans per-agent history only; shared context has nothing to compact
--agent matches nothingcompact --agent XExits 1 with a “no agent matching …” message
Work actually donecompactPrints Compaction complete (N agent(s))., exits 0
Fully empty storeexportExits 1, writes no file
Shared-context-only storeexportExits 0 — the snapshot serialises shared context

Why is my store empty?

get_global_store() is an in-memory singleton scoped to the current process. The agent runtime does not write to it automatically — it only holds what a caller populated in this process via the context API. A separate CLI process cannot see a store an agent run filled elsewhere; move it across processes with snapshot() / restore(). See Context Management API → Scope.

See Also