Building Tool Systems for LLM Agents

This collection of guides covers the design and implementation of tool calling systems for LLM agents, drawing from analysis of two production systems: Claude Code (Anthropic) and Codex (OpenAI).

Guides

01 - Overview Comparison

High-level comparison of Claude Code and Codex approaches to tool calling. Covers architectural philosophy, key differentiators, and recommendations for choosing between approaches.

Key topics:

02 - Tool Architecture

Deep dive into building tool systems: schemas, registries, handlers, routers, and output formatting.

Key topics:

03 - MCP Integration

Guide to integrating Model Context Protocol (MCP) for external tool access and resources.

Key topics:

04 - Sandboxing and Safety

Comprehensive guide to safety mechanisms: hooks, sandboxing, approval policies, and command classification.

Key topics:

05 - Parallel Execution

Strategies for safe parallel tool execution, synchronization, and race condition prevention.

Key topics:

06 - Tool Instructions and Parsing

Deep dive into how LLMs are instructed about tools and how their responses are parsed.

Key topics:

07 - Context Gathering

Comprehensive guide to how agents gather, structure, manage, and optimize context.

Key topics:

08 - Model Selection and Swapping

Guide to selecting and swapping models for agents, sub-agents, and background tasks.

Key topics:

09 - Context Management

Comprehensive guide to managing context within LLM context windows.

Key topics:

Quick Reference

Claude Code Approach

Codex Approach

Getting Started

If you're building an LLM agent tool system:

  1. Start with the overview to understand the tradeoffs
  2. Read tool architecture for core implementation patterns
  3. Add MCP support if you need external tool integration
  4. Implement safety mechanisms before production use
  5. Consider parallelism for performance optimization

Source Repositories

These guides are based on analysis of:

Contributing

Found an error or want to add more patterns? The guides are in this repository's guides/ directory.