
Deep Thoughts
·
2026-05-07
·
8 分钟
The Soul of an AI Coding Assistant: The Think-Act-Observe Loop
If you dig through the Claude Code source, you will discover a counterintuitive fact: The core of the entire program is a while loop. Not a complex state machine, not an elaborate pipeline, not distributed coordination — just a plain while loop that does three things over and over: let the model think, let the model act, feed the results back. 1 2 3 4 5 6 7 8 9 while (user hasn't quit) { thinking = callLLM(conversation history + tool definitions) if (thinking.wants to call a tool) { result = executeTool(thinking.toolCall) conversationHistory.push(result) } else { output(thinking.reply) } } That’s it? The entire secret of an AI coding assistant lives in this loop?
1645 字
阅读 ➔