Agent Architecture Lessons from Unix V4
Table of Contents
The Unix Kernel as Agent Blueprint
The 1973 Unix V4 kernel's organization into ken/ and dmr/ directories
isn't just historical artifact—it's a masterclass in separation of concerns
that directly maps to modern agent architectures.
The Original Split
/usr/sys/
├── ken/ Ken Thompson - Core Intelligence
│ ├── main.c Initialization/orchestration
│ ├── slp.c Sleep/wakeup (blocking/async)
│ ├── trap.c Interrupt handling
│ ├── sys1-4.c System calls (the API)
│ ├── sig.c Signal handling
│ ├── pipe.c Inter-process communication
│ └── ...
│
└── dmr/ Dennis Ritchie - I/O & Peripherals
├── bio.c Block I/O abstraction
├── tty.c Terminal handling
├── rk.c Disk driver
├── tm.c Tape driver
└── ...
Mapping to Agent Architecture
| Unix V4 | Agent Equivalent |
|---|---|
main.c |
Agent orchestrator/main loop |
slp.c |
async task management |
trap.c |
Tool call dispatcher |
sys1-4.c |
Capability/tool definitions |
sig.c |
Event/notification handling |
pipe.c |
Agent-to-agent communication |
bio.c |
I/O abstraction layer |
tty.c |
User interface/terminal |
rk.c, tm.c |
Specific tool implementations |
Key Patterns
1. Core vs. Periphery
Ken's code handles what the system does (process, memory, files).
Dennis's code handles how it interfaces with the world.
For agents:
- Core: Reasoning, planning, memory, tool selection
- Periphery: Specific tools (web fetch, file edit, shell exec)
2. Clean Interface Boundaries
/* bio.c - Dennis's abstraction */ bread(dev, blkno) /* Read block from any device */ bwrite(bp) /* Write block to any device */ /* Ken's code just calls bread/bwrite */ /* Never touches device-specific details */
For agents: Tools should expose clean interfaces. The reasoning core shouldn't know if "read file" uses local fs, S3, or network fetch.
3. The Trap Table Pattern
/* sysent.c - System call dispatch */ int (*sysent[])() { &nullsys, /* 0 = indir */ &rexit, /* 1 = exit */ &fork, /* 2 = fork */ &read, /* 3 = read */ &write, /* 4 = write */ ... };
This is exactly how agent tool dispatch works:
tools = { "read_file": read_file_impl, "write_file": write_file_impl, "web_search": web_search_impl, "bash": bash_impl, } def dispatch(tool_name, params): return tools[tool_name](**params)
4. Sleep/Wakeup (async patterns)
/* slp.c - Thompson's async primitives */ sleep(chan, pri) /* Block until event */ wakeup(chan) /* Signal event occurred */
Maps to modern agent patterns:
- Background tasks
- Waiting for user input
- Polling for tool completion
- multi-agent coordination
5. Signals (Interrupts)
/* sig.c - Interrupt handling */ signal(sig, handler) /* Register handler */ kill(pid, sig) /* Send signal */
Agent equivalents:
- User interruption (Ctrl-C → Escape)
- Timeout handling
- Graceful shutdown
- Priority escalation
Suggested Agent Structure
Based on Unix V4 patterns:
agent/
├── core/ "Ken's code" - The thinking part
│ ├── main.py Orchestration loop
│ ├── memory.py Context/state management
│ ├── planner.py Task decomposition
│ ├── dispatch.py Tool selection & routing
│ └── signals.py Interrupt/event handling
│
├── tools/ "Dennis's code" - The doing part
│ ├── base.py Abstract tool interface
│ ├── filesystem.py File operations
│ ├── shell.py Command execution
│ ├── web.py HTTP/search
│ └── ...
│
└── interface/ User-facing (like tty.c)
├── cli.py CLI interface
├── api.py HTTP API
└── mcp.py MCP server
The 41 System Call Lesson
Unix V4 had exactly 41 system calls. Not 400. Not 4000.
This minimal surface area is why Unix became portable and why it's still recognizable 50 years later.
For agents: A small, well-defined tool set beats a sprawling one. Claude Code has ~15 core tools. That's intentional.
| Unix V4 Syscalls | ~41 |
| Claude Code Tools | ~15 |
| Ratio | ~3:1 |
Both achieve remarkable capability through composition rather than explosion of primitives.
The Pipe Insight
Thompson's pipe implementation is 95 lines of C. It enables infinite composition of simple tools.
cat file | grep pattern | sort | uniq -c
Agent equivalent: Chaining tools, where one's output feeds another's input. The orchestrator doesn't need complex tools—it needs composable ones.
What Unix V4 Got Right for Agents
- Separation of policy and mechanism
- Minimal kernel, rich userspace
- Everything is a file (uniform interface)
- Small, composable tools
- Clean async primitives
- Explicit, numbered interfaces (syscalls → tools)
What Modern Agents Add
Things Thompson and Ritchie didn't have:
- Natural language dispatch (no numbered syscalls needed)
- Reasoning over tool selection (vs. deterministic code)
- Learned patterns (vs. hardcoded logic)
- Conversation context (persistent memory across calls)
But the structural insights remain valid.
References
- Unix V4 Software Catalog
- Booting Unix V4
- Terminal AI Agents
- Thompson & Ritchie, "The UNIX Time-Sharing System" (CACM 1974)
