Skip to content

Configuration

import { createAgent } from "agent-lattice";
const agent = createAgent({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com/anthropic",
model: "deepseek-v4-flash",
systemPrompt: "You are a concise engineering assistant.",
maxTokens: 16384,
maxTurns: 50,
});

DeepSeek exposes an Anthropic-compatible endpoint, so configure baseURL and use a DeepSeek model name.

Use Anthropic directly by omitting baseURL and passing an Anthropic model name.

const agent = createAgent({
apiKey: process.env.ANTHROPIC_API_KEY,
model: "claude-sonnet-4-6",
systemPrompt: "You are a concise engineering assistant.",
});

Use systemPrompt to define an agent’s stable role, responsibility, and boundaries. This is especially important in team setups where each working Agent needs a different job description.

const backendAgent = createAgent({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com/anthropic",
model: "deepseek-v4-flash",
systemPrompt: [
"You are the backend executor agent.",
"Handle APIs, data models, storage, integrations, and server-side correctness.",
"Escalate product or UI decisions instead of guessing.",
].join("\n"),
});

Every agent gets a private workspace for durable files, code, reports, logs, and test evidence. The workspace belongs to that agent, not to a Team or teamMember() definition.

By default, the SDK stores agent work under ~/.agent/workspaces/<agent-name>. If the agent has no name, it uses ~/.agent/workspaces/agent-<session-id>.

const backendAgent = createAgent({
apiKey,
name: "backend",
model,
systemPrompt: "You are the backend executor agent.",
});

Use workspace only when the host wants to override the default location:

const backendAgent = createAgent({
apiKey,
name: "backend",
model,
workspace: ".agent-workspaces/backend",
});

The SDK automatically adds workspace tools and instructions telling the agent to report important paths and verification notes in natural language.

Pass workspace: false to opt out of the built-in workspace entirely: no built-in file/shell tools, no workspace prompt section — equivalent to createBareAgent(). Requires 0.23.0 or later. Unlike createBareAgent(), the option also works through defineAgent(), so defineAgent({ workspace: false }) spawns bare sessions. This is useful for typed-delegation specialists that should have no filesystem or shell surface.

Use createBareAgent() when the host wants a plain model loop with no default prompt, no default tools, and no workspace directory creation. This is useful for hosted applications that provide their own sandbox, tests that need exact tool lists, or wrappers that assemble capabilities themselves.

import { createBareAgent, createBuiltinTools } from "agent-lattice";
const agent = createBareAgent({
apiKey,
model,
systemPrompt: "You are a concise engineering assistant.",
tools: createBuiltinTools({
cwd: process.cwd(),
allowedDirectories: [process.cwd()],
}),
});

Most agents that produce durable files should use createAgent(). Choose createBareAgent() only when your application owns every capability explicitly.

const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);
const result = await agent.prompt("Summarize this repository.", {
signal: controller.signal,
});
Option Type Default Description
stream boolean true Enables model streaming and stream_event SDK messages.
signal AbortSignal undefined Cancels the active model request and tool loop.

maxTurns counts model requests, not tool executions. The default is 50, which gives multi-agent and tool-heavy flows room to complete while still protecting the host from infinite loops.

Set a lower value for small one-shot tools or tests:

const agent = createAgent({
apiKey,
model,
maxTurns: 8,
});