THE AGENT LOOP, MADE VISIBLE

From a prompt
to real work.

nah gives a model a task, a bounded set of tools, and a clear path to act. Every step returns through an explicit loop you can inspect, shape, and stop.

TypeScript first Streamed events You own the controls
nahAGENT RUN
YOUR TASKprompt + context
MODELdecide next step
TOOLSact in environment
EVENTSobserve the run
control stays in your app01 — 04 / REPEATS UNTIL DONE
THE SHAPE OF A RUN

A loop you can follow.

Each model decision and tool outcome is an explicit part of the run. Nothing disappears behind a one-shot “agent” call.

RUN 8F31 / CODING AGENT IN PROGRESS
01
INPUT“Fix the failing test”

Prompt + repository context enter the run.

prompt
02
MODEL STEPInspect the test and implementation

The model requests a read operation.

text → tool
03
TOOL RESULTTest output points to a mismatch

Structured results become the next model context.

tool-result
continues with new context
04
APPROVAL GATEReview a proposed file edit

Your policy decides whether the action can proceed.

approval
05
FINISHChange verified, summary returned

Final answer and usage are available to your app.

done
event stream connected5 STEPS · 2 TOOL CALLS · 1 APPROVAL
FOUR MOVING PARTS

Small steps. Clear ownership.

Your application sets the boundaries; the loop carries context from one decision to the next.

01

Give it a task

A prompt, working directory, and system instructions become the run’s starting context. The agent receives only the tools and limits your app gives it.

02

The model chooses

The model can respond with an explanation or request a tool. Each response is one bounded step in a loop your application can observe.

03

Tools do the work

Read, search, edit, and shell tools run in your environment. Mutating actions can pause for your approval before anything changes.

04

Results guide the next step

Tool output returns to the model as context. It can inspect the result, choose another action, or finish with a final answer.

AN EXPLICIT API

Wire the loop into your product.

Use the framework when you want to compose the agent yourself. Stream events into your UI, connect approvals to your policy, and keep the run result in your hands.

Explore the framework
agent.tsYOUR APP · TYPESCRIPT
const run = runAgent({model, prompt: "Fix the failing test", system: buildSystemPrompt(cwd), tools: createCodingTools(env, {approveToolCall: askForApproval,}), maxSteps: 12, maxSpendUsd: 0.50,});for await (const event of run.events) {renderRunEvent(event);}const result = await run.result;
stream each step to your UIevents → result
ONE RUNTIME, MORE WAYS TO BUILD

Start where you are.

Build a custom agent, use nah as your coding partner, or inspect the work as it happens.

READY TO BUILD?

Make the loop yours.

Start with the agent loop guide, then shape the run around your product and your users.