while (true) {
const reply = await model(messages);
const result = await runTool(reply.toolCall);
messages.push(reply, { role: 'user', content: result });
}for (let step = 0; step < MAX_STEPS; step++) {
const reply = await model(messages);
if (!reply.toolCall) return reply;
const result = await runTool(reply.toolCall).catch((e) => ({ error: e.message }));
messages.push(reply, { role: 'tool', id: reply.toolCall.id, content: result });
}The loop stops on a final answer or a step limit, and errors go back to the model as tool results.
A framework is a library for building agents. A harness is the complete runtime around a model, often built with a framework, that runs a specific agent.
The harness decides the tools, prompts, context management and retries the model works with, which strongly affects results.
The agent loop, tool definitions and execution, context and memory management, permission checks, and a way to show progress to the user.