Give a model a tool and let it decide when to call it.
Level: LLM · Concept: Agents · Needs: a model API key (DEEPSEEK_API_KEY as written; any provider works)
flowchart LR
Q([question]) --> A[Agent]
A -- tool call --> T[multiply]
T -- result --> A
A --> R([answer])
- The agent loops: ask the model, run requested tools, send results back.
maxIterationsbounds the loop.output.toolCallsrecords every call.
# Once, from the repository root
pnpm install && pnpm build
export DEEPSEEK_API_KEY=sk-...
pnpm --filter @astack-examples/agent startThe full program is index.ts.
Next: Custom model