local-agent

command
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 11 Imported by: 0

README

Local Agent Example

This example is a small Gemini-backed CLI agent built directly on the Glue library. It registers a local_time tool, streams the assistant text to stdout, and persists sessions through stores/file.

The implementation lives in main.go and is intentionally short: it shows the full shape of a Glue application — provider, store, tool registration, session management, and event-stream output — in under 120 lines.

Run

Set a Gemini API key, then run:

export GEMINI_API_KEY=...
go run ./examples/local-agent \
  --prompt "Use local_time for America/Toronto and summarize it." \
  --id demo

Flags:

  • --prompt (required) — prompt text
  • --id — session id (default example)
  • --model — Gemini model id (default gemini-2.5-flash)
  • --store — session store directory (default .glue/example-sessions)

The session is persisted to disk, so re-running with the same --id continues the conversation.

Test

go test ./examples/local-agent

Three offline tests cover the local_time tool's happy path, missing timezone arg, and invalid JSON arg. The live test (TestLiveLocalAgent) is gated behind GEMINI_API_KEY and skipped in CI.

Compare to cmd/glue

cmd/glue/run is the generic local CLI; this example is a self-contained program showing how to build a tool-calling agent in your own main.go. The two share glue.NewAgent + gemini.New + stores/file + the same event-streaming pattern.

Documentation

Overview

Command local-agent is a small Gemini-backed CLI built directly on the glue library. It registers a local_time tool so the model can call into the Go process to get the current wall-clock time for a requested timezone label, streams the assistant text to stdout, and persists sessions through stores/file. Use it as a smoke test and as a tutorial for new applications.

Jump to

Keyboard shortcuts

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