A small agent.
An explicit control loop.

A first search rarely covers every part of a research question. This agent checks collected evidence, searches for what is missing, and replans before producing an answer. TypeScript controls the loop, the OpenAI client handles model calls and web search, and Zod defines the decision contracts.

Decide. Execute. Update. Repeat.

Interactive walkthrough

Illustrative trace · no live API calls

Actions update state → next round
Round 1 / 5 · frame 1 / 20

Start with a question and a two-step plan covering features only.

Evidence
0
Analyses
0
Current step
0
Confidence
—
Answer
Pending
Active node / Shared state

Query, plan, evidence, analyses, current step, attempts, and answer live in one AgentState.

Small enough to inspect.

Shared contracts
Zod schemas define decisions and plan steps. TypeScript types are inferred from those schemas to avoid duplicate definitions.
Missing information
The sample query asks about SDK features, pricing, and limitations. The initial plan covers features only, giving the decision layer a reason to search more or replan.
Bounded loop
The agent runs up to five decision rounds, then generates a best-effort answer if needed. This limits rounds, rather than total API calls or elapsed time.
Step failures
A failed planned step is recorded in state and the step pointer advances. Other action failures can still terminate execution.

A learning project with visible boundaries.

This is a command-line prototype. Calculation is a placeholder; state is in memory; there is no formal evaluation suite or application-level retry policy. Model confidence is a routing heuristic, and fallback answers can be incomplete. The downloadable source includes setup instructions and a blank environment template.