Portal Community

AgentMemoryConfig

Every AgentComposite carries an AgentMemoryConfig that controls all memory behaviour:

public class AgentMemoryConfig
{
    // ── Working Memory ──────────────────────────────────────────
    public int    MaxWorkingMemoryTokens { get; set; } = 100_000;
    public string PruningStrategy        { get; set; } = "FIFO";   // FIFO | Summarize | SlidingWindow
    public int    SlidingWindowTurns     { get; set; } = 10;
    public int    MinHistoryMessages     { get; set; } = 2;         // Never prune below this count

    // ── Episodic Memory ─────────────────────────────────────────
    public bool   EpisodicEnabled        { get; set; } = true;
    public string EpisodicRecallMode     { get; set; } = "Semantic"; // Recency | Semantic
    public int    EpisodicTopK           { get; set; } = 3;
    public int    EpisodicRetentionDays  { get; set; } = 90;
    public bool   EpisodicPIIDetection   { get; set; } = false;

    // ── Semantic Memory ─────────────────────────────────────────
    public bool   SemanticEnabled        { get; set; } = true;
    public int    SemanticTopK           { get; set; } = 5;
    public float  SemanticMinScore       { get; set; } = 0.75f;
    public bool   HybridSearchEnabled    { get; set; } = false;
    public bool   RerankerEnabled        { get; set; } = false;

    // ── Procedural Memory ───────────────────────────────────────
    public bool   ProceduralEnabled      { get; set; } = true;
    public bool   ProceduralLearning     { get; set; } = false;     // Agent captures new procedures
    public float  ProceduralMinScore     { get; set; } = 0.80f;     // Min confidence for embedding match
}

Configuration Properties Reference

PropertyDefaultEffect
MaxWorkingMemoryTokens100,000Maximum tokens in the assembled context. Set to ~80% of the model's context window.
PruningStrategyFIFOHow message history is trimmed when over budget.
EpisodicEnabledtrueWhether past conversation sessions are recalled. Disable for stateless bots.
EpisodicTopK3Number of past episode snippets injected per turn. Higher = more context, more tokens.
EpisodicRetentionDays90How long episodes are kept before soft-delete and purge.
SemanticEnabledtrueWhether the knowledge base is queried. Disable if the agent has no indexed documents.
SemanticTopK5Number of knowledge chunks retrieved per turn. Tune for answer quality vs. token cost.
SemanticMinScore0.75Minimum cosine similarity to include a chunk. Lower = more results, more noise.
HybridSearchEnabledfalseEnable RRF hybrid (vector + keyword) retrieval. Better for precise term matching.
RerankerEnabledfalseCross-encoder reranking of retrieved chunks. Improves precision at cost of latency.
ProceduralEnabledtrueWhether procedures are matched before each LLM call.
ProceduralLearningfalseWhether the agent captures new procedures from successful task completions.

Recommended Configurations by Agent Type

Agent TypeEpisodicSemanticProceduralPruning
Knowledge Q&A bot (no memory)DisabledEnabled, TopK 5DisabledFIFO
Customer service (returning users)Enabled, TopK 3Enabled, TopK 5OptionalFIFO
Task automation agentDisabledOptionalEnabledSlidingWindow (10)
Full enterprise assistantEnabled, TopK 3Enabled, TopK 5, HybridEnabledSummarize
High-throughput batch agentDisabledDisabledDisabledFIFO (minimal history)

Configuring via API

// PATCH /api/octopus/agents/{agentId}/memory-config
PATCH /api/octopus/agents/agent_hr_01/memory-config
Authorization: Bearer {adminToken}
Content-Type: application/json

{
  "episodicEnabled":       true,
  "episodicTopK":          3,
  "episodicRetentionDays": 90,
  "semanticEnabled":       true,
  "semanticTopK":          5,
  "semanticMinScore":      0.75,
  "hybridSearchEnabled":   false,
  "proceduralEnabled":     true,
  "proceduralLearning":    false,
  "maxWorkingMemoryTokens": 100000,
  "pruningStrategy":       "FIFO"
}

// Response: 200 OK — agent uses new config on next turn

Tuning for Cost Reduction

Memory retrieval contributes tokens to every LLM call. To reduce token costs:

Changes Take Effect Immediately

Memory configuration changes via the API or admin UI take effect on the next conversation turn — no server restart or session reset is required. Running conversations automatically pick up the new configuration.