This directory contains small scripts that demonstrate different agent patterns.
Run them with pnpm using the commands shown below.
agents-as-tools.ts– Orchestrate translator agents using them as tools.pnpm examples:agents-as-tools
agents-as-tools-structured.ts– Use structured tool input withAgent.asTool().pnpm examples:agents-as-tools-structured
agents-as-tools-conditional.ts– Enable language tools based on user preference.pnpm examples:agents-as-tools-conditional
deterministic.ts– Fixed agent flow with gating and quality checks.pnpm examples:deterministic
forcing-tool-use.ts– Require specific tools before final output.pnpm -F agent-patterns start:forcing-tool-use
human-in-the-loop.ts– Manually approve certain tool calls.pnpm examples:human-in-the-loop
human-in-the-loop-stream.ts– Streaming version of human approval.pnpm examples:streamed:human-in-the-loop
input-guardrails.ts– Reject unwanted requests with guardrails.pnpm examples:input-guardrails
llm-as-a-judge.ts– Evaluate and iterate on story outlines.pnpm -F agent-patterns start:llm-as-a-judge
output-guardrails.ts– Block unsafe output using guardrails.pnpm examples:output-guardrails
parallelization.ts– Run translations in parallel and pick the best.pnpm examples:parallelization
routing.ts– Route messages to language-specific agents.pnpm examples:routing
streamed.ts– Stream agent output, both text and events.pnpm examples:streamed
streaming-guardrails.ts– Check streaming output against guardrails.pnpm -F agent-patterns start:streaming-guardrails