Executor Agent

The ExecutorAgent orchestrates the four cognition modules through an iterative decision cycle. It implements a Recognizer-first pipeline with a conditional Decayer→Activator thinking loop.

Execution Flow

sequenceDiagram
    participant U as User
    participant E as Executor
    participant R as Recognizer
    participant D as Decayer
    participant A as Activator
    participant M as Memory Manager

    U->>E: user_message
    E->>R: RecognizerInput
    R-->>E: RecognizerOutput (input_type, memories, utility_updates)
    E->>M: store new memories
    alt input_type == QUESTION or rule_statement
        E->>D: DecayerInput
        D-->>E: DecayerOutput (requires_activation, tier_metrics)
        alt requires_activation == true
            E->>A: ActivatorInput
            A->>M: retrieve from Qdrant
            M-->>A: retrieved memories
            A-->>E: ActivatorOutput (merged buffer)
        end
    end
    E->>E: generate_response (LLM + buffer)
    E-->>U: response
    E->>E: apply_interaction_decay
    

Step-by-Step

  1. Recognizer (always first) — Classifies input type (statement / question / feedback), extracts semantic and episodic memories, assesses utility of existing memories, proposes topic updates.
  2. Memory Manager (store) — New memories from the Recognizer are stored in Qdrant with embeddings.
  3. Decayer (conditional) — Runs only for questions or rule-containing statements. Uses two-tier uncertainty (LLM + cosine similarity) to decide if activation is needed.
  4. Activator (conditional) — Expands the query into a DAG of sub-queries, retrieves memories from Qdrant, curates and merges the buffer. May trigger multiple times in the thinking loop.
  5. Response generation — LLM call with the curated memory buffer as context.
  6. Post-response — Second Recognizer pass for meta-learning insights; Ebbinghaus decay applied to all buffer memories; low-scoring memories purged.

Module Internal Flows

Decayer Flow

flowchart LR
    I["DecayerInput
(query + buffer)"] --> T1["Tier 1: LLM
Uncertainty"] T1 --> T2["Tier 2: Cosine
Similarity"] T2 --> D{"Both tiers
high?"} D -->|Yes| ACT["requires_activation = true"] D -->|No| SUF["is_sufficient = true"]

Activator Flow

flowchart LR
    I["ActivatorInput
(query + clusters)"] --> QE["Query Expansion
DAG"] QE --> RET["Qdrant Retrieval
(per sub-query)"] RET --> CUR["Buffer Curation
(LLM or heuristic)"] CUR --> OUT["ActivatorOutput
(merged buffer)"]

Recognizer Flow

flowchart LR
    I["RecognizerInput
(user + response)"] --> CLS["Input
Classification"] CLS --> SEM["Semantic
Extraction"] CLS --> EPI["Episodic
Detection"] CLS --> UTL["Utility
Assessment"] CLS --> TOP["Topic
Construction"] SEM --> OUT["RecognizerOutput"] EPI --> OUT UTL --> OUT TOP --> OUT

Memory Hierarchy

flowchart TB
    subgraph MemoryHierarchy ["Memory Hierarchy Space"]
        direction TB
        L1["L1: Dynamic Procedural
(clustering topics, meta-learning)"] L2["L2: Semantic
(factual knowledge, rules, preferences)"] L3["L3: Episodic
(experiences, strategies, traces)"] end L1 --- L2 L2 --- L3 HIGH["High Accessibility"] -.-> L1 LOW["Low Accessibility"] -.-> L3

Configuration Reference (ExecutorConfig)

ParameterTypeDefaultDescription
max_thinking_iterationsint2Maximum iterations in Decayer→Activator thinking loop
decay_temperaturefloat10.0Ebbinghaus stability multiplier T: R = e^(-t/(S*T)). Higher = slower decay
purge_decay_thresholdfloat0.1Decay score below which memories are purge candidates
purge_utility_thresholdfloat0.2Utility score below which low-decay memories are purged
include_l1boolTrueInclude L1 (clustering topics + procedural) in LLM prompt
include_l2boolTrueInclude L2 (semantic/factual) in LLM prompt
include_l3boolTrueInclude L3 (episodic) in LLM prompt
enable_memory_linkingboolTrueL2-L3 bidirectional linking for cross-level retrieval
reinforce_decay_on_useboolTrueBoost decay scores for memories used in responses
decay_reinforcement_boostfloat0.1Activation score boost for used memories
response_modelstr"gpt-4.1-mini"Model for response generation
response_temperaturefloat0.7Temperature for response generation
max_interaction_historyint10Max K-entries in working memory interaction history
k_recent_contextint10Recent K-entries included in response context

Metrics Reference

The ExecutorAgent tracks detailed per-interaction metrics in last_metrics. These are grouped by module:

Recognizer Metrics

KeyDescription
recognizer_latency_msTotal Recognizer invocation latency
input_typeClassified input type (statement / question / feedback)
recognizer_semantic_memories_countNumber of semantic memories extracted
recognizer_has_episodicWhether an episodic entry was created
recognizer_utility_updates_countNumber of utility score updates
recognizer_prompt_tokensPrompt tokens consumed by Recognizer
recognizer_completion_tokensCompletion tokens from Recognizer

Decayer Metrics

KeyDescription
decayer_triggeredWhether Decayer was invoked (False for statements)
decayer_trigger_reasonReason: "question", "rule_statement", or "empty_buffer_with_session_memories"
decayer_latency_msTotal Decayer latency
decayer_prompt_tokensPrompt tokens consumed by Decayer
decayer_completion_tokensCompletion tokens from Decayer
decayer_status"skipped" when Decayer did not run

Activator Metrics

KeyDescription
activator_trigger_countNumber of Activator invocations in thinking loop
activator_multi_triggerWhether Activator triggered more than once
activator_latency_msTotal Activator latency
activator_prompt_tokensPrompt tokens consumed by Activator
activator_completion_tokensCompletion tokens from Activator
dag_node_countNumber of nodes in the query expansion DAG
dag_edge_countNumber of edges in the query expansion DAG

Response Metrics

KeyDescription
response_generation_latency_msResponse LLM call latency
response_prompt_tokensPrompt tokens for response generation
response_completion_tokensCompletion tokens from response
total_latency_msTotal end-to-end latency for the interaction

Memory & Thinking Loop Metrics

KeyDescription
new_memories_storedList of memory IDs inserted this interaction
evicted_memory_idsMemory IDs purged due to low decay + utility
memory_link_statsL2-L3 linking statistics (links created, total)
topic_construction_action"create", "update", or "none"
topic_construction_idClustering tag ID for topic operation
topic_construction_summarySummary text for the topic operation
thinking_iterations_usedHow many Decayer→Activator loops ran
per_iteration_metricsList of per-iteration detail dicts
thinking_loop_latency_msTotal thinking loop wall-clock time

Logging Systems

IntermediateLogger

Full per-interaction snapshots when log_intermediate_data=true. Each entry contains: DecayerSnapshot (tier metrics, cluster assessments), ActivatorSnapshot (DAG nodes/edges, retrieved memory IDs), BufferSnapshot before and after (all memories with decay/utility/reward scores, token counts), judge score, and the complete metrics dict. Output: intermediate_<run_id>.json.

DecayTracker

Per-memory decay timelines when log_decay_curves=true. Records (memory_id, interaction_id, decay_score, was_accessed, was_reinforced) at each interaction. Enables plotting Ebbinghaus decay curves and analyzing reinforcement patterns.

ActivatorTracker

Activation trigger patterns when log_activator_triggers=true. Tracks trigger frequency, rate, uncertainty levels, and which clusters triggered activation.

MetricsCollector

Aggregated run-level statistics. Computes mean, std, min, max, p50, p95 for all numeric metrics across interactions. Tracks total token usage, activator trigger rate, and judge score distribution.