Relations gives Elixir applications reusable graph recipes for Relate. Its first recipe, Relations.Evidence, records what a tool actually returned and lets another process or agent recall it later, with the original call ID, arguments and outcome. The application owns the database through Relatex.

Record a tool result

Add {:relations, github: "houllette/relations"} to your Mix dependencies. The native client comes from Hex. Its first build needs the tools and release archive described in the Relatex installation instructions.

Start a directory-backed Relatex process under your application's supervisor. Give the directory a persistent location on the host.

children = [{Relatex, database: "./agent-graph", name: MyApp.Graph}]
Supervisor.start_link(children, strategy: :one_for_one)

At the point where your tool returns, choose the arguments, output and metadata to persist. For example, a file reader might record this result.

alias Relations.Evidence

entry = %Evidence{
  session_id: "run-17",
  call_id: "call-001",
  tool: "read",
  arguments: %{"path" => "sample.txt"},
  output: "specimen=4cf2",
  metadata: %{"trace_id" => "trace-8"}
}

{:ok, ^entry} = Evidence.record(MyApp.Graph, entry)

The tool name and IDs are nonempty UTF-8 strings. Output is UTF-8 text and may be empty. Arguments and metadata default to empty maps and accept nested JSON values with string keys. Set status: :error to keep the output from a failed call. Replaying the same entry is safe, including from concurrent processes sharing this database owner. If a session reuses a call ID with different content, recording returns {:error, :conflict} and preserves the original evidence.

Recall it in a later session

A new process can use the same supervised name after the database reopens. Give an agent access to the session its host has selected. A session ID scopes a lookup within the graph; the calling application controls access.

{:ok, entry} = Evidence.fetch(MyApp.Graph, "run-17", "call-001")
IO.puts(entry.output)

{:ok, [first]} = Evidence.recall(MyApp.Graph, "run-17", limit: 1)
{:ok, next_page} = Evidence.recall(MyApp.Graph, "run-17", after: first.call_id, limit: 1)

An exact lookup returns :not_found for an unknown call. Session recall returns an empty list when the page is exhausted. Pages sort by call ID in ascending string order, with an exclusive cursor, a default size of 50 and a maximum of 100. Each page reads the current graph. See the Relations.Evidence module documentation for the graph labels and properties you can query from your own application.

Run the live Lemieux example

From this checkout, start Ollama with a tool-capable model installed, then run the example. It defaults to qwen3.8:27b. Set RELATIONS_OLLAMA_MODEL to select another installed tag.

elixir examples/lemieux_evidence.exs

The first agent reads a random specimen from a temporary file. The example records the tool result, closes the database and removes the source file. A second agent with a fresh transcript can only call the session-scoped recall tool. The script checks the reported specimen and its provenance against the original tool result. Lemieux is installed by the example and adds no runtime dependency to a consuming application.

Development

Install the versions in .tool-versions, then run mix deps.get and mix test. The tests run against embedded Relate and work without a model. Run mix precommit for dependency audits, compilation, formatting, linting, documentation and tests. Run MIX_ENV=test mix dialyzer for type checking.

For local agent tooling, run mix tidewave to start the development MCP endpoint on loopback port 4028. Approve the project's .mcp.json in an interactive Claude Code session and use /mcp to check the connection.