Overview
The Prefrontal layer is the final filter before waking the agent. It takes a high-scoring window from Layer 2 (Limbic) and decides:- Should we escalate? Is the score above threshold and the context clear enough?
- What should we ask? If escalating, form a specific, focused question using the module’s question template.
Cost: Near-zero (string interpolation only)
Output:
Output:
EscalationDecision with a scoped question or should_escalate=FalseArchitecture
Escalation Decision
Every evaluation produces anEscalationDecision:
pulse/prefrontal.py
Invariant:
should_escalate is True only when question is a non-empty string.Gating Logic
The Prefrontal layer rejects escalation if any of the following are true:- Score is below threshold (default: 0.65)
- Question template is missing or empty
- Template substitution produces an empty string
- Template substitution raises any exception
pulse/prefrontal.py
Template Interpolation
The question template is a simple Python format string with a{location} placeholder:
/home/user/Downloads/hw3.pdf, the template is interpolated:
Current Limitations
The current implementation only supports{location}, which is extracted from the last event in the window:
pulse/prefrontal.py
{delta_type}, {timestamp}, {extension}, etc.
Ambiguity Resolution (Future)
In the current implementation, each module has its own LSTM and question template. When multiple modules share a cluster (see Layer 2: Limbic), Layer 3 must disambiguate. Planned approach (from ARCHITECTURE.md):
If Layer 3 cannot identify a single best-matching module (two modules in the cluster both match equally well), it forms a broader question:
"Something changed in the {cluster} cluster. Specifically: {event_summary}. Which of the following is relevant: {module_list}?"
This broader question is more expensive for the agent to answer, but it only occurs when Layer 3 genuinely cannot resolve the ambiguity deterministically.
Threshold Tuning
The escalation threshold can be adjusted at runtime:pulse/prefrontal.py
Threshold tuning guidelines
Threshold tuning guidelines
- 0.5–0.6: Very sensitive. More false positives, fewer missed events.
- 0.65–0.7: Balanced (default). Recommended for most modules.
- 0.75–0.85: Conservative. Fewer false positives, may miss edge cases.
- 0.9+: Extremely selective. Only fires on very confident patterns.
default_threshold from its fingerprint and adjust based on user feedback.Public API
pulse/prefrontal.py
Design Principles
Deterministic
Pure string interpolation. No LLM calls, no neural networks.
Fail-Safe
All template errors result in no escalation, never crashes.
Scoped Questions
Questions are specific to the triggering event, not generic.
Tunable
Threshold can be adjusted per-module for precision/recall trade-off.
Example Flow
Homework Agent
- Layer 1 (Retina): Detects new file
/home/user/Downloads/hw3.pdf - Layer 2 (Limbic): LSTM scores the event window → 0.87 (above threshold)
- Layer 3 (Prefrontal): Evaluates escalation
- Template:
"A new file appeared at {location}. Is this file related to a course assignment or homework?" - Interpolates:
"A new file appeared at /home/user/Downloads/hw3.pdf. Is this file related to a course assignment or homework?" - Returns:
EscalationDecision(should_escalate=True, question="...", confidence=0.87)
- Template:
- Kernel: Receives
EscalationDecisionand wakes agent with the scoped question
Below-Threshold Case
- Layer 1 (Retina): Detects time tick at 3:47 AM
- Layer 2 (Limbic): LSTM scores the event window → 0.23 (below threshold 0.65)
- Layer 3 (Prefrontal): Returns
EscalationDecision(should_escalate=False, question=None, confidence=0.23) - Kernel: Does not wake the agent
Integration with Kernel
The Prefrontal layer is the final output of the Pulse subsystem. Whenshould_escalate=True, the kernel receives the EscalationDecision and wakes the agent with the formed question.
See Signal Bus for how escalation decisions are delivered to the kernel.