Skip to main content
Minimal agent with a system prompt, LLM client, and a single blocking Run(). Use this to verify your LLM credentials and SDK install before adding tools or Temporal. Source: examples/simple_agent/

What it demonstrates

  • NewAgent with WithLLMClient and WithSystemPrompt
  • Blocking Run() returning AgentRunResult
  • Optional token usage footer via SHOW_LLM_USAGE=true

Run

From examples/:
go run ./simple_agent "Hello, what can you do?"
SHOW_LLM_USAGE=true go run ./simple_agent "Hello"

Key code

The example loads LLM settings from examples/.env and calls Run once:
a, err := agent.NewAgent(
    agent.WithName("simple-agent"),
    agent.WithSystemPrompt("You are a helpful assistant that can generate text."),
    agent.WithLLMClient(llmClient),
    // config.RuntimeOption(cfg) adds WithTemporalConfig when AGENT_RUNTIME=temporal
)
if err != nil {
    log.Fatal(err)
}
defer a.Close()

result, err := a.Run(ctx, prompt, nil)
fmt.Println(result.Content)
For a from-scratch module without the examples helper package, follow the Quickstart.

Expected output

I'm a helpful assistant that can answer questions, explain concepts, summarize content,
and help with a wide range of text-based tasks. What would you like to explore?

--- LLM Usage ---
Input tokens:  45
Output tokens: 38
The LLM response varies; the optional usage footer appears only when SHOW_LLM_USAGE=true.

Learn more

Quickstart

Build an agent in your own module

Tools

Add built-in and custom tools

Configuration

All agent options