RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Multi-Agent Systems
  6. /Ch. 13
Multi-Agent Systems

13. Agent Observability

Chapter 13 of 24 · 15 min
KEY INSIGHT

Observable agents emit structured state events that enable retrospective analysis and real-time anomaly detection without degrading agent performance.

Observability in multi-agent systems extends far beyond simple logging. An observable agent exposes its internal state transitions, decision reasoning, and tool invocation patterns in a structured, queryable format. This chapter examines how to instrument agents for full visibility without degrading performance.

Structured State Telemetry

Agents emit state changes as discrete events with consistent schemas. Each state transition includes timestamp, previous state, new state, reason, and metadata. This event stream feeds into the observability pipeline where downstream systems can reconstruct agent behavior timelines.

# agent/telemetry.py
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Any
import json

class AgentState(Enum):
    IDLE = "idle"
    REASONING = "reasoning"
    TOOL_CALL = "tool_call"
    AWAITING_RESPONSE = "awaiting_response"
    COMPLETED = "completed"
    ERROR = "error"

@dataclass
class StateEvent:
    timestamp: datetime
    agent_id: str
    state: AgentState
    previous_state: AgentState | None
    reason: str
    metadata: dict[str, Any]
    
    def to_json(self) -> str:
        return json.dumps({
            "timestamp": self.timestamp.isoformat(),
            "agent_id": self.agent_id,
            "state": self.state.value,
            "previous_state": self.previous_state.value if self.previous_state else None,
            "reason": self.reason,
            "metadata": self.metadata
        })

class AgentTelemetry:
    def __init__(self, agent_id: str, emitter):
        self.agent_id = agent_id
        self.emitter = emitter
        self._current_state = AgentState.IDLE
    
    def emit_state_change(self, new_state: AgentState, reason: str, metadata: dict = None):
        event = StateEvent(
            timestamp=datetime.utcnow(),
            agent_id=self.agent_id,
            state=new_state,
            previous_state=self._current_state,
            reason=reason,
            metadata=metadata or {}
        )
        self.emitter.emit(event)
        self._current_state = new_state

Context Injection Pattern

Telemetry works best when injected into the agent's context window. This allows the observing system to correlate agent reasoning with external events without cross-referencing separate logs.

Failure Detection

Observable agents enable real-time alerting on state anomalies. An agent stuck in AWAITING_RESPONSE for more than the configured threshold triggers automatic investigation workflows.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Implement a telemetry decorator that wraps agent methods and automatically emits state events for any method execution exceeding 100ms. Record execution time, method name, and arguments in the metadata field.

← Chapter 12
Consensus Mechanisms
Chapter 14 →
Agent Tracing