liveBook · Manning

Cognitive workspace

As explained in AI Agents in Action, Second Edition

A cognitive workspace is a structured data object that represents an agent's task, findings, confidence, and other information needed across a cognitive cycle.

A cognitive workspace is the shared, structured state of a cognitive agent. Every module reads it and writes to it, using it to coordinate task understanding, strategies, findings, confidence, execution history, and attention signals. Unlike conversation history or a scratchpad, it represents the agent’s current reasoning state, including contradictions, progress, and uncertainty. section 10.2.1 section 10.2.2

A practical workspace organizes the cognitive cycle around several kinds of state:

  • Task representation records what the agent believes it has been asked, including task type and estimated complexity. section 10.2.1 section 10.5
  • Strategies and hypotheses capture the current approach, such as direct answering, decomposition, exploration, or hypothesis testing. section 10.2.2
  • Findings record discovered content, sources, relevance, and quality notes, while confidence state records how trustworthy the results appear. section 10.2.2
  • Execution history records attempted approaches, and attention signals identify conditions such as low confidence, stagnation, contradiction, knowledge gaps, or completion. section 10.2.1 section 10.2.2

Contradiction redirects the cycle

Suppose evaluation detects contradictory findings. It sets active_signal to CONTRADICTION. The attention module reads that signal, changes the strategy to hypothesis testing, and routes control back to planning rather than continuing execution. This makes the workspace an active communication channel, not merely a container for accumulated results. section 10.2.2 section 10.2.7

The workspace connects perception, planning, execution, evaluation, attention, and memory inside an agentic loop. Attention normally routes perceive, plan, execute, and evaluate, but workspace signals can interrupt that sequence. For simple, familiar queries with a relevant memory hit, it can instead select a fast response path. section 10.2.1 section 10.2.7

Listing 10.1 01_cognitive_workspace.py
from pydantic import BaseModel, Field
from enum import Enum
from typing import Optional

class TaskType(str, Enum):
    SIMPLE_LOOKUP = "simple_lookup"
    MULTI_STEP = "multi_step"
    CONTRADICTORY = "contradictory"
    AMBIGUOUS = "ambiguous"
    COMPOSITIONAL = "compositional"
    UNKNOWN = "unknown"

class StrategyType(str, Enum):
    DIRECT = "direct"              #1
    DECOMPOSE = "decompose"        #2
    EXPLORE = "explore"            #3
    HYPOTHESIS_TEST = "hypothesis_test"  #4

class AttentionSignal(str, Enum):
    NONE = "none"
    LOW_CONFIDENCE = "low_confidence"
    STAGNATION = "stagnation"
    CONTRADICTION = "contradiction"
    KNOWLEDGE_GAP = "knowledge_gap"
    TASK_COMPLETE = "task_complete"

class Finding(BaseModel):
    content: str
    source: str
    relevance_score: float = 0.0
    quality_note: str = ""

class CognitiveWorkspace(BaseModel):
    # Task representation
    raw_query: str = ""
    task_type: TaskType = TaskType.UNKNOWN
    extracted_entities: list[str] = Field(default_factory=list)
    complexity_estimate: float = 0.0   #5
    ambiguities: list[str] = Field(default_factory=list)

    # Active hypotheses
    current_strategy: StrategyType = StrategyType.DIRECT
    sub_goals: list[str] = Field(default_factory=list)
    alternative_strategies: list[str] = Field(default_factory=list)

    # Intermediate results
    findings: list[Finding] = Field(default_factory=list)
    memory_hits: list[str] = Field(default_factory=list)  #6

    # Confidence state
    confidence: float = 0.5          #7
    confidence_trend: list[float] = Field(default_factory=list)

    # Execution history
    steps_taken: list[str] = Field(default_factory=list)
    failed_approaches: list[str] = Field(default_factory=list)
    iteration_count: int = 0

    # Attention signals
    active_signal: AttentionSignal = AttentionSignal.NONE
    signal_source: str = ""

Inspect the typed Pydantic model defining task types, strategies, attention signals, and findings. section 10.2.2

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines typed state and signal-driven routing, but defers complete field definitions and full agent assembly to surrounding implementations.
Examples
Uses typed task classifications, contradiction signals, findings, routing decisions, and exercises spanning perception, evaluation, attention, and memory.
What it assumes
Assumes basic Python modeling and agentic-loop familiarity while teaching workspace state, module coordination, and attention signals through implementation.
What you can do after
Build and inspect a typed workspace, populate it from queries, and diagnose routing changes caused by confidence, contradiction, or stagnation.
How it connects
Connects the agentic loop with perception, planning, execution, evaluation, attention, memory, confidence gating, and global workspace theory.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.