examples/

directory
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0

README

AgentKit examples

Eight small programs, each showing one part of AgentKit. Every example is a single main.go you can read top to bottom. They repeat their setup rather than share a helper package, so everything you need is in the file you have open. Each has a README.md saying what it shows and how to run it.

Contents

The examples

Five run offline, with no API key and no network: they use the scripted model provider/faux, or no model at all. Three call a real model.

Example Shows Needs Run it
agentdemo The agent loop and its event stream, step by step. nothing go run ./examples/agentdemo
toolbox Every built-in tool, called by hand through a Runner; try them on your own directory. nothing go run ./examples/toolbox
codemode Code mode: one tool that runs a model-written script over other tools. nothing go run ./examples/codemode
indexedsearch The code_search index: queries, symbol lookup, keeping it current. nothing cd examples/indexedsearch && go run .
toolserver The agentkit-tools command: an MCP session on its stdin and stdout, and single calls from request files. nothing cd examples/toolserver && go run .
codingagent A small coding agent: built-in tools, a workspace and the shell guard. a model go run ./examples/codingagent --dir . "which files define the tool policy?"
customtools Writing your own tools well: schemas, argument repair, guidelines, ending a run. a model go run ./examples/customtools
mcp Importing the tools of an MCP server, and the name-clash protection. a model go run ./examples/mcp

The indexedsearch and toolserver examples are their own Go modules, so run them from their directory.

Where to start

  1. agentdemo to see what a run is.
  2. toolbox to see what the tools do.
  3. codingagent for a real agent on your own code.

Then pick the example for the feature you need. The user guide explains each feature in prose, with the same building blocks.

Choosing a provider for the model-calling examples

codingagent, customtools and mcp read three environment variables of their own and pass them to agentkit.Config. The library itself never reads them.

Variable Sets Default
AGENTKIT_PROVIDER Config.Provider: anthropic, openrouter or ollama anthropic
AGENTKIT_MODEL Config.Model: a tier (SIMPLE, STANDARD, ADVANCED) or a model id STANDARD
AGENTKIT_EFFORT Config.Effort: low, medium, high, xhigh or max the tier's effort

The provider then reads its own credential: ANTHROPIC_API_KEY (or Vertex AI or Bedrock settings), OPENROUTER_API_KEY, or OLLAMA_HOST for an Ollama server.

export ANTHROPIC_API_KEY=sk-ant-...
go run ./examples/codingagent "summarise this repository"

AGENTKIT_PROVIDER=openrouter OPENROUTER_API_KEY=sk-or-... go run ./examples/customtools

ollama pull qwen3.8:27b
AGENTKIT_PROVIDER=ollama AGENTKIT_MODEL=SIMPLE go run ./examples/codingagent "hello"

Each prints a summary line with the provider, model and effort it ran, the turns, tokens and cost. See Choosing a provider for every credential and deployment, and Troubleshooting when something fails.

Directories

Path Synopsis
Command agentdemo runs AgentKit end to end with no API key and no network.
Command agentdemo runs AgentKit end to end with no API key and no network.
Command codemode shows the code-mode tool: the model writes one Starlark script that calls several tools, filters what they return, and hands back only the answer.
Command codemode shows the code-mode tool: the model writes one Starlark script that calls several tools, filters what they return, and hands back only the answer.
Command codingagent is a coding agent with the built-in file and shell tools, a workspace root, an execute policy and a live event stream.
Command codingagent is a coding agent with the built-in file and shell tools, a workspace root, an execute policy and a live event stream.
Command customtools is the reference for writing your own tools: schemas built from combinators, the two handler shapes, error results the model can recover from, per-tool argument repair, sequential execution for tools with side effects, and a terminating submit_answer.
Command customtools is the reference for writing your own tools: schemas built from combinators, the two handler shapes, error results the model can recover from, per-tool argument repair, sequential execution for tools with side effects, and a terminating submit_answer.
Command mcp is AgentKit as a Model Context Protocol CLIENT: it borrows another program's tools and hands them to a model.
Command mcp is AgentKit as a Model Context Protocol CLIENT: it borrows another program's tools and hands them to a model.
Command toolbox calls AgentKit's built-in tools by hand, with no model: the same tools an agent gets from tools.For, run through the same agentkit.Runner path an agent's calls take, so you can see what each one takes and returns and try your own arguments.
Command toolbox calls AgentKit's built-in tools by hand, with no model: the same tools an agent gets from tools.For, run through the same agentkit.Runner path an agent's calls take, so you can see what each one takes and returns and try your own arguments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL