Examples
These examples are small, runnable programs that exercise the public
github.com/ly95/agent-go API.
| Example |
What it demonstrates |
basic |
A stateless OpenAI-backed agent run without tools |
mcp |
A read-only operation exposed to the model through the runtime's in-process MCP server |
skill |
A reusable Skill pattern that bundles instructions, operation registration, and execution |
All examples use the OpenAI Responses API and fail explicitly when required
configuration is missing.
export OPENAI_API_KEY="..."
export OPENAI_MODEL="..."
# Optional; defaults to https://api.openai.com/v1
export OPENAI_BASE_URL="https://api.openai.com/v1"
Run
Run commands from the repository root:
go run ./examples/basic "Explain agent loops in one paragraph."
go run ./examples/mcp "Use the tool to add 19 and 23."
go run ./examples/skill "Analyze this text: small tools make agents easier to test."
The MCP example uses the runtime's built-in, in-process MCP boundary:
OperationRegistry defines trusted tool contracts, the runtime discovers those
contracts through MCP, and the host still owns policy and execution. It does not
connect to an arbitrary remote MCP server.
The Skill example intentionally treats a Skill as a host-side composition
pattern rather than a runtime primitive. Its textskill.Skill packages model
instructions, operation registration, and an executor while the host remains in
control of authorization.
These examples are stateless and read-only. Production write operations also
require a durable ExecutionStore; confirmation-required writes additionally
require approval and verification implementations.