Skip to content

Context and Memory

ContextBuilder controls how event history is transformed into model input.

Verified built-ins include:

  • ContextBuilders.Xml()
  • ContextBuilders.Compact()
  • ContextBuilders.JsonStructured()
  • ContextBuilders.FromFunc(...)

ContextWindowConfig contains compaction and pruning thresholds. On the agent itself:

  • AutoCompaction is enabled by default.
  • GetContextStatsAsync() returns token and context stats.

The memory system is file-backed and rooted under:

<workingDirectory>/memory/memories

It enforces virtual paths under /memories/... and is designed for cross-session knowledge capture rather than opaque vector-store behavior.

Context can include non-text user input using:

  • Message.UserImage(...)
  • Message.UserBlocks(...)

When persisted, non-text user input becomes UserContentEvent.