Back to articles
every AI agent I've read has a god object. after 12 codebases I think I know why.

every AI agent I've read has a god object. after 12 codebases I think I know why.

via Dev.toneuzhou

I've spent the last few months reading through AI agent source code. Not the docs -- the actual implementations. 12 projects so far: Claude Code, Cline, Dify, Goose, Codex CLI, DeerFlow, and six others. Every single one has a god object. Not like "oh this file is a bit big." I mean a single class or module that handles the agent loop, streaming, tool execution, context management, error recovery, and half a dozen other concerns that have no business being in the same file. Cline's is 3,756 lines. Hermes Agent's is 9,000. Claude Code's query.ts is 1,729 lines and it's actually one of the smaller ones. At first I thought this was just organic code growth -- ship fast, refactor later, except later never comes. But after seeing the same pattern in 12 completely unrelated projects built by different teams, I started thinking it might be something deeper. Here's what I think is going on. An agent loop is a state machine. Every iteration reads context, calls a model, parses tool calls, execut

Continue reading on Dev.to

Opens in a new tab

Read Full Article
4 views

Related Articles