Help us shape the future of Go! Take the 2026 Go Developer Survey

agent

command
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Command agent shows how to give an agent X-Ray as its memory through the Go SDK. It is provider-neutral: the model is an interface, and the example runs with a scripted model so it works with no API key. To use a real model, implement Model for your provider and pass it to NewAgent.

go run ./examples/agent                                  # X-Ray in this process
XRAY_URL=http://localhost:8083/mcp XRAY_TOKEN=... go run ./examples/agent

With no XRAY_URL the agent runs X-Ray's memory store inside its own process and keeps it in agent-memory.json, so what it learns survives a restart. With XRAY_URL it uses a shared X-Ray over MCP. The agent code is the same for both, because the in-process store and the remote client implement xray.Memory.

The agent does three things with X-Ray:

  1. Recall. Before it answers, it searches memory for the question and puts what it finds in the system prompt, each item with its id and origin.
  2. Tools. It hands the model three memory tools, so the model decides what is worth saving and what is wrong.
  3. Evidence. Anything the model saves is linked to the items that were in front of it, so refuting a fact later retires what was drawn from it.

Jump to

Keyboard shortcuts

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