liveBook · Manning

Chapter 10: Exploring the cognitive agent that thinks, monitors, and adapts

What you will learn in chapter 10 of AI Agents in Action, Second Edition

The introduction explains why capable agents need cognition and metacognition rather than simply more reasoning patterns.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why capable agents need cognition and metacognition rather than simply more reasoning patterns.

Key terms: cognition, metacognition, reasoning patterns, agentic loop

10.1 Understanding agent cognition and metacognition as engineering concepts

Previews why existing reasoning patterns are insufficient and the concepts that will guide the cognitive agent architecture.

10.1.1 The five failure modes of capable-but-not-cognitive agents

The section diagnoses five common agent failures by connecting each observable behavior to a missing cognitive capability and a proposed architectural component.

Key terms: confident wrong answer, evidence evaluation, evaluation module, broken record, stagnation awareness, attention module, rigid plan, model updating, replanning mode, planning module

10.1.2 From reasoning primitives to cognitive architecture

This section contrasts fixed reasoning patterns with a cognitive architecture that chooses patterns for the problem and changes strategy when feedback reveals trouble.

Key terms: cognitive primitives, cognitive architecture, reasoning patterns, feedback loop, Evaluation component, attention mechanism, static reasoning

10.1.3 Defining cognition for agents

Defines agent cognition as an observable, engineerable quality of an agent’s task model and identifies four capabilities that demonstrate it.

Key terms: agent cognition, internal model of a task, observable capabilities, task decomposition, dependency reasoning, subtasks, compositional tool use, model updating, hypothesis, new evidence

10.1.4 Defining metacognition for agents

Defines agent metacognition as monitoring its own thinking through confidence calibration, stagnation detection, and knowledge boundary awareness.

Key terms: cognition, metacognition, confidence calibration, stagnation detection, knowledge boundary awareness, internal signals, implicit–explicit confidence gap, token probabilities, retrieval scores, evidence consistency

10.1.5 Three theoretical foundations

The section turns three ideas from cognitive science into design principles for a cognitive agent: specialized modules, a shared workspace, and processing depth matched to the query.

Key terms: Minsky’s Society of Mind, specialized agent modules, shared state, Baars’ global workspace theory, cognitive workspace, shared state object, Kahneman’s System 1 and System 2, attention module, full cognitive cycle

10.2 Mapping the mind into a cognitive agent architecture

This section introduces the upcoming walkthrough of the cognitive agent architecture’s components and code.

10.2.1 Architecture overview

The section maps the cognitive agent’s seven components around a shared workspace and explains how memory and an enclosing agentic loop support their coordination.

Key terms: cognitive workspace, global workspace, task representation, active hypotheses, intermediate results, confidence state, perception module, planning module, execution module, evaluation module

10.2.2 The cognitive workspace

This section explains how a shared cognitive workspace represents the agent’s state and lets modules signal when its course needs to change.

Key terms: cognitive workspace, global workspace, ResearchState, cognitive state, active_signal, CONTRADICTION, attention module, global workspace broadcast mechanism

10.2.3 The perception module

The section explains how the perception module turns a user query into a structured task and uses its complexity to route the agent’s response.

Key terms: perception module, structured task representation, workspace, triage, complexity estimate, system 1 fast path, full cognitive cycle, dual-process theory

10.2.4 The planning module

The planning module uses the perceived task and relevant past experience to select a strategy and produce a plan for execution.

Key terms: planning module, task representation, perception module, HYPOTHESIS_TEST, memory hits, knowledge graph, PlanOutput, execution module

10.2.5 The execution module

The execution module carries out a plan step and records annotated results so the cognitive agent can evaluate what happened.

Key terms: execution module, workspace, plan step, MCP servers, function calls, evaluation module, result annotation, finding object, content, source

10.2.6 The evaluation module

This section explains how the evaluation module monitors a cognitive agent’s work during execution, checks for failures, and differs from post-hoc reflection.

Key terms: evaluation module, metacognitive core, workspace, evidence quality assessment, stagnation detection, contradiction flagging, evaluation, Reflexion, real-time monitoring, post-hoc correction

10.2.7 The attention module

The attention module routes a cognitive agent through its normal cycle or a faster response path using signals in the shared workspace.

Key terms: attention module, attention signals, cognitive workspace, cognitive cycle, fast path, low-complexity, relevant past experience, system 1, deterministic, global cognitive workspace

10.2.8 The memory module and the MCP memory server

This section explains how an MCP-backed knowledge graph gives the cognitive agent persistent memory and how the memory module uses it during the cognitive cycle.

Key terms: memory module, MCP memory server, knowledge graph, entities, relations, observations, proactive retrieval, experience recording, relation building, workspace

10.3 Building and running the cognitive agent

Introduces the upcoming assembly, demonstration, and metacognitive monitoring of the cognitive agent.

10.3.1 The cognitive loop

This section explains how an inner cognitive cycle fits inside the agentic loop and how attention routes evaluation signals before the outer loop checks for convergence.

Key terms: agentic loop, cognitive cycle, attention module, L2 loop, evaluation signals, routing, convergence checking, run_cognitive_loop

10.3.2 A complete cognitive agent with MCP

This section presents a runnable assembly of the cognitive agent and points readers to traces for observing it in action.

Key terms: cognitive architecture, MCP servers, memory server, filesystem server, workspace, cognitive loop

10.3.3 Walkthrough: Watching the cognitive cycle in action

The section walks through how a cognitive agent uses perception, memory, hypothesis testing, evaluation, and memory recording to handle a deployment failure that a standard timeout answer would miss.

Key terms: TaskType.CONTRADICTORY, attention module, MEMORY, HYPOTHESIS_TEST, workspace, execution module, evaluation module, confidence delta, CONTINUE, TASK_COMPLETE

10.3.4 Confidence-gated execution

This section introduces confidence gating as a structural check before an agent presents a response.

Key terms: confidence gating, workspace’s confidence state, evaluation module

10.3.5 Stagnation detection and strategy pivoting

This section explains how a cognitive agent detects stalled progress and replans instead of repeating a failed strategy.

Key terms: stagnation detection, attention module, META_PLAN, failed_approaches, workspace

10.3.6 Knowledge boundary awareness

The section explains how an agent should recognize gaps in its knowledge and why acknowledging uncertainty matters for user trust.

Key terms: knowledge boundary awareness, training and retrieval coverage, graceful degradation, overcommitted guess, metacognitive monitoring, trust, confidently wrong answers

10.3.7 Emergent behaviors

This section shows how four useful behaviors emerge from specialized cognitive modules coordinating through a shared workspace and accumulating knowledge graph.

Key terms: emergent behaviors, specialized modules, shared workspace, knowledge graph, society of mind, Curiosity, KNOWLEDGE_GAP, exploratory subgoals, Adaptive persistence, stagnation detection

10.4 Measuring cognitive capability and looking ahead

This section introduces five practical tests for deciding whether an agent is likely to benefit from a cognitive architecture.

Key terms: practical diagnostic framework, five failure modes, cognitive architecture

10.4.1 Cognitive efficiency metrics

This section defines four production metrics for measuring how efficiently an agent works, how well its confidence matches reality, how quickly it adapts, and how accurately it recognizes its limits.

Key terms: cognitive efficiency, optimal number, attention module’s fast path, metacognitive calibration, confidence, accuracy, adaptation rate, stagnation detection, strategy pivot, knowledge boundary accuracy

10.4.2 Before and after: Measuring the effect

This section proposes two controlled comparisons to measure the cognitive agent’s performance and the effect of accumulated experience.

Key terms: standard ReAct agent, cognitive agent, identical queries, answer correctness, confidence calibration, graceful degradation rate, empty knowledge graph, populated graph, compounding returns, stagnation events

10.4.3 The road to more general agents

This section explains how a troubleshooting-focused cognitive agent could be adapted to other domains and why modular architecture offers a path toward more general capabilities.

Key terms: cognitive workspace, attention module, evaluation module, confidence-gating patterns, perception module, execution module, modular cognitive architectures, compositional generalization, reasoning, monitoring

10.5 Exercises

Five exercises guide the reader through building and testing a cognitive agent’s workspace, evaluation, attention routing, memory, and confidence calibration.

10.6 Summary

The summary brings together cognition, metacognitive monitoring, modular architecture, and persistent memory as the basis for an agent that can adapt across problems and sessions.

Concepts explained in this chapter

← Chapter 9: Understanding the agentic loop Chapter 11: Tips for building agentic systems →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.