An attention module decides what a cognitive agent does next. Rather than letting every request follow one fixed pipeline, it reads signals in a shared cognitive workspace and gives control to the appropriate module. Its usual cycle is perceive, plan, execute, evaluate; a signal can redirect that cycle at any point. section 10.2.7 section 10.2.1
Think of the difference between a routine lookup and a problem that needs investigation. A familiar, low-complexity request may not need planning and evaluation. An ambiguous or contradictory request may need both, followed by replanning if new evidence changes the picture. Routing the simple case quickly can save latency and token cost. section 10.1.5 section 10.2.7
The routing decision follows the workspace state:
- If complexity is low, relevant memory is available, and no attention signal is active, take the fast response path. section 10.2.7
- If the task is complete, respond. If progress has stagnated, record the failed strategy and route to meta-planning. section 10.2.7
- If evidence contradicts the current approach, switch to hypothesis testing and plan again. section 10.2.7
Listing 10.6 06_attention_module.py
def route_attention(workspace: CognitiveWorkspace) -> str:
"""Read workspace signals and determine next module."""
# System 1 fast path
if (workspace.complexity_estimate < 0.3
and workspace.memory_hits
and workspace.active_signal == AttentionSignal.NONE):
return "FAST_RESPOND" #1
# Signal-driven routing
if workspace.active_signal == AttentionSignal.TASK_COMPLETE:
return "RESPOND"
if workspace.active_signal == AttentionSignal.STAGNATION:
workspace.failed_approaches.append(
workspace.current_strategy.value
)
return "META_PLAN" #2
if workspace.active_signal == AttentionSignal.CONTRADICTION:
workspace.current_strategy = StrategyType.HYPOTHESIS_TEST
return "PLAN" #3
if workspace.active_signal == AttentionSignal.LOW_CONFIDENCE:
if workspace.confidence < 0.2:
return "ESCALATE" #4
return "PLAN"
if workspace.active_signal == AttentionSignal.KNOWLEDGE_GAP:
return "MEMORY"
# Default cognitive cycle
if not workspace.extracted_entities:
return "PERCEIVE"
if not workspace.sub_goals:
return "PLAN"
if workspace.iteration_count == 0 or workspace.active_signal == AttentionSignal.NONE:
return "EXECUTE"
return "EVALUATE"
Inspect the code-controlled routing branches and their workspace checks. The thresholds are explicit settings that can be adjusted, though leaving them static initially makes behavior easier to understand. section 10.2.7
When a search keeps failing
An agent repeats the same failed query without making progress. An evaluation signal indicating stagnation lets attention interrupt the cycle and send control toward a different plan, rather than spending more iterations on the same approach. section 10.1.1 section 10.2.7
Attention also connects two loops. The outer agentic loop handles iteration and stopping; the inner cognitive cycle handles processing within an iteration. Attention turns evaluation signals into inner-loop routing decisions, so replanning and re-execution can happen before the outer loop checks convergence. When behavior is surprising, trace the workspace signal and the routing branch it selected. section 10.3.1 section 10.2.7
