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
- Recognizer (always first) — Classifies input type (statement / question / feedback), extracts semantic and episodic memories, assesses utility of existing memories, proposes topic updates.
- Memory Manager (store) — New memories from the Recognizer are stored in Qdrant with embeddings.
- Decayer (conditional) — Runs only for questions or rule-containing statements. Uses two-tier uncertainty (LLM + cosine similarity) to decide if activation is needed.
- 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.
- Response generation — LLM call with the curated memory buffer as context.
- 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)
| Parameter | Type | Default | Description |
|---|---|---|---|
max_thinking_iterations | int | 2 | Maximum iterations in Decayer→Activator thinking loop |
decay_temperature | float | 10.0 | Ebbinghaus stability multiplier T: R = e^(-t/(S*T)). Higher = slower decay |
purge_decay_threshold | float | 0.1 | Decay score below which memories are purge candidates |
purge_utility_threshold | float | 0.2 | Utility score below which low-decay memories are purged |
include_l1 | bool | True | Include L1 (clustering topics + procedural) in LLM prompt |
include_l2 | bool | True | Include L2 (semantic/factual) in LLM prompt |
include_l3 | bool | True | Include L3 (episodic) in LLM prompt |
enable_memory_linking | bool | True | L2-L3 bidirectional linking for cross-level retrieval |
reinforce_decay_on_use | bool | True | Boost decay scores for memories used in responses |
decay_reinforcement_boost | float | 0.1 | Activation score boost for used memories |
response_model | str | "gpt-4.1-mini" | Model for response generation |
response_temperature | float | 0.7 | Temperature for response generation |
max_interaction_history | int | 10 | Max K-entries in working memory interaction history |
k_recent_context | int | 10 | Recent 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
| Key | Description |
|---|---|
recognizer_latency_ms | Total Recognizer invocation latency |
input_type | Classified input type (statement / question / feedback) |
recognizer_semantic_memories_count | Number of semantic memories extracted |
recognizer_has_episodic | Whether an episodic entry was created |
recognizer_utility_updates_count | Number of utility score updates |
recognizer_prompt_tokens | Prompt tokens consumed by Recognizer |
recognizer_completion_tokens | Completion tokens from Recognizer |
Decayer Metrics
| Key | Description |
|---|---|
decayer_triggered | Whether Decayer was invoked (False for statements) |
decayer_trigger_reason | Reason: "question", "rule_statement", or "empty_buffer_with_session_memories" |
decayer_latency_ms | Total Decayer latency |
decayer_prompt_tokens | Prompt tokens consumed by Decayer |
decayer_completion_tokens | Completion tokens from Decayer |
decayer_status | "skipped" when Decayer did not run |
Activator Metrics
| Key | Description |
|---|---|
activator_trigger_count | Number of Activator invocations in thinking loop |
activator_multi_trigger | Whether Activator triggered more than once |
activator_latency_ms | Total Activator latency |
activator_prompt_tokens | Prompt tokens consumed by Activator |
activator_completion_tokens | Completion tokens from Activator |
dag_node_count | Number of nodes in the query expansion DAG |
dag_edge_count | Number of edges in the query expansion DAG |
Response Metrics
| Key | Description |
|---|---|
response_generation_latency_ms | Response LLM call latency |
response_prompt_tokens | Prompt tokens for response generation |
response_completion_tokens | Completion tokens from response |
total_latency_ms | Total end-to-end latency for the interaction |
Memory & Thinking Loop Metrics
| Key | Description |
|---|---|
new_memories_stored | List of memory IDs inserted this interaction |
evicted_memory_ids | Memory IDs purged due to low decay + utility |
memory_link_stats | L2-L3 linking statistics (links created, total) |
topic_construction_action | "create", "update", or "none" |
topic_construction_id | Clustering tag ID for topic operation |
topic_construction_summary | Summary text for the topic operation |
thinking_iterations_used | How many Decayer→Activator loops ran |
per_iteration_metrics | List of per-iteration detail dicts |
thinking_loop_latency_ms | Total 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.