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. /LangGraph for Local Agents
  6. /Ch. 11
LangGraph for Local Agents

11. Specialized Worker Agents

Chapter 11 of 18 · 15 min
KEY INSIGHT

Workers are subgraphs, not functions. They read from team state, do domain work, and write results back to team state. Idempotency is essential—multi-agent runs fork and replay, and non-idempotent workers produce non-deterministic results.

Worker agents are compiled subgraphs that encapsulate a specific capability. Each worker is a create_react_agent (or custom graph) with its own toolset, and the team supervisor treats it as an opaque callable. Workers read from shared state and write results back—this is the only communication contract.

researcher_tools = [web_search, extract_content, save_to_vector_db]
researcher = create_react_agent(
    model=llm,
    tools=researcher_tools,
    state_schema=PartialableTeamState  # allows partial updates
)

coder_tools = [read_file, write_file, run_bash, run_tests]
coder = create_react_agent(
    model=llm,
    tools=coder_tools,
    state_schema=PartialableTeamState
)

To embed a worker in the team graph, use add_node with the compiled researcher or coder app directly. LangGraph will invoke that app as a subgraph, passing the team state in and receiving updated state out.

team_builder.add_node("researcher", researcher)
team_builder.add_node("coder", coder)

Workers should be idempotent: if a worker is called twice with the same input, it should produce the same output. This matters because the supervisor might decide to re-run a worker if a later step encounters an error. Workers that are not idempotent create non-deterministic multi-agent runs that are difficult to reproduce and debug.

The failure mode: workers that depend on shared mutable state (like a global variable) break when invoked as subgraphs because the subgraph runs in its own state context. All worker state must flow through the shared state dict. Workers should not reference external globals directly.

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

Create three specialized workers: a web_searcher, a content_summarizer, and a file_writer. Register them in a team graph. Run it with a task that requires all three in sequence and inspect the shared state at each step to confirm each worker contributed correctly.

← Chapter 10
Supervisor Agent
Chapter 12 →
Agent Communication