AI agents overview
Build AI agents that use your app's functions, and share tools with MCP clients.
Use agents when your application needs a model to interpret a request and choose how to complete it. Tools let it do useful work in your app: look up an order, search a catalog, or prepare a response using current data.
RELKIT agents run through native LangChain and LangGraph APIs. RELKIT connects those workflows to
your application’s functions, validation, permissions, durable threads, and execution limits. Use
defineAgent for model-driven work, or defineGraph and defineGraphNode for explicit workflows.
Adding subagents, skills, memory files, or a backend to defineAgent selects native DeepAgents
behavior through the same declaration.
Use an agent when the next step depends on a user’s question. Use an ordinary function when you already know the steps, such as calculating a total or saving an order.
Pre-setup
Use local Docker Redis for agent checkpoints and live updates. Model execution is a separate choice: begin with the deterministic model in the offline agent guide. Docker does not supply a hosted model or an API key.
Install agent execution and Redis support
From this guide’s application/package root, install only its selected requirements:
bun add @langchain/core@1.2.9 @langchain/langgraph@1.4.14 @relkit/langchain@0.7.13 @relkit/local@0.7.12 langchain@1.5.10 langsmith@0.10.8Keep these owner-specific versions and the lockfile together. Runtime SDKs belong in dependencies; build/type tooling belongs in devDependencies. Installing an adapter does not supply its optional SDK peers or enable the feature’s configuration.
From this guide’s application/package root, install only its selected requirements:
bun add @relkit/docker@0.7.12 @relkit/redis@0.8.1Keep these owner-specific versions and the lockfile together. Runtime SDKs belong in dependencies; build/type tooling belongs in devDependencies. Installing an adapter does not supply its optional SDK peers or enable the feature’s configuration.
The agent cohort also installs the filesystem provider used by the offline tutorial. This configuration selects Docker Redis for the running application instead.
Configure checkpoint and realtime profiles
/** Agent checkpoints and live updates use separate Docker Redis capabilities. */
import { defineApp, defineEnv } from "@relkit/app/config";
import { docker } from "@relkit/docker";
import { redisAgentState, redisRealtime } from "@relkit/redis";
export default defineApp({
env: defineEnv({}),
realtime: docker(redisRealtime()),
"agent-state": docker(redisAgentState()),
defaults: { realtime: "default", "agent-state": "default" },
});Use stateProfile: "default" in the agent, or omit it to select this default. Redis credentials
come from Docker. The deterministic model needs no environment key. When selecting a hosted model,
declare its required key as env.secret() in your existing defineEnv, supply it to the backend
process, and follow that model’s native configuration.
The declaration validates the key; it does not configure the model automatically.
Tools exposed only through MCP do not need checkpoint storage. Workspace files use a separate bucket profile when selected.
Check and start after registering the agent
Check Docker before continuing. After adding the resource and its service registration, run from the app root:
docker version
bun run check
bun run typecheck
bun run devcheck validates the graph; it starts no containers. dev starts only Docker recipes used by
that graph, waits for readiness, and binds their generated connection values. An unused profile
alone does not start a container. Keep the server running and use bun run relkit local status
in another terminal to inspect the services. Local Docker
covers detached startup and stopping services while retaining their volumes.
The AI APIs
Usually, adding tools to a model means writing argument schemas, dispatching tool calls, handling results, and controlling how long the model can keep working. RELKIT lets you reuse validated functions as tools, choose which tools an agent can use, and set limits on each run.
| API | What you use it for |
|---|---|
defineAgent |
Set native model, tool, middleware, DeepAgents, and client behavior. |
defineGraph |
Register a typed native LangGraph workflow and its public result. |
defineGraphNode |
Validate graph-node state updates, routes, and human continuation. |
defineTool |
Give an existing function a tool name, description, and execution policy. |
function.asTool() |
Turn a function into a tool directly. |
mcp |
Choose whether a tool is available to external MCP clients. |
The same tool can serve a RELKIT agent and an external AI client through Model Context Protocol (MCP). You do not need a RELKIT agent just to expose tools over MCP.
Native framework boundary
Pass compatible LangChain models, tools, and middleware directly—there is no public adapter wrapper. RELKIT function-backed tools remain native-compatible while preserving function execution, validation, authorization, and tool policies. LangGraph owns scheduling and control flow; RELKIT validates declared state and public output around it.
Observe durable execution
Client-exposed agents stream one canonical event history over HTTP iteration, AG-UI SSE, or WebSocket.
AG-UI is independently opt-in. Only when selecting that protocol, install its SDK and set
server.agUi to true in your existing application configuration:
From this guide’s application/package root, install only its selected requirements:
bun add @ag-ui/core@0.0.59
Keep these owner-specific versions and the lockfile together. Runtime SDKs belong in dependencies; build/type tooling belongs in devDependencies. Installing an adapter does not supply its optional SDK peers or enable the feature’s configuration.
This optional protocol is validated before readiness; ordinary
typed agent RPC and streaming do not select it.
The typed client exposes messages, tools, progress, selected middleware state, waiting requests, nested
execution, and final output separately. Every run, observation, control, and continuation supplies an
application-owned threadId; mounting a hook never invents one or starts work.
See Agent streaming and Threads and recovery.
For the complete native boundary, continue with Native runtime and DeepAgents and LangGraph, persistence, and resume.
Choose where to start
Follow the greeting-assistant tutorial to add an agent to an existing app and test it without a model API key.
Already have application functions? Turn one into a tool, then give it to an agent or connect an MCP client.
With the separately installed and enabled Inspector, open Agents to review an agent’s tools and limits, or Tools to review the functions each tool calls.