Skip to content

Agent

An Agent is a program that receives a question, decides what tools to use, and produces an answer. It runs a ReAct loop (Reason + Act):

User question
-> LLM thinks + picks a tool
-> Tool executes, returns result
-> LLM thinks again (with tool result)
-> Final answer (or pick another tool)

The loop continues until the LLM produces a final answer or hits maxSteps (default: 10).

import { Schift, Agent, RAG } from "@schift-io/sdk";
const schift = new Schift({ apiKey: "sch_..." });
const rag = new RAG({ bucket: "my-docs" }, schift.transport);
const agent = new Agent({
name: "My Agent",
instructions: "You are a helpful assistant. Use the knowledge base.",
rag,
tools: [myCustomTool],
model: "gpt-4o-mini",
transport: schift.transport,
maxSteps: 15,
});
const result = await agent.run("What is Schift?");
console.log(result.output);

Agents support three ways to connect to an LLM:

Routes through Schift’s /v1/chat/completions endpoint. Supports model routing across OpenAI, Google, and Anthropic.

const agent = new Agent({
name: "Cloud Agent",
instructions: "...",
model: "gpt-4o-mini", // or "claude-sonnet-4-6", "gemini-2.5-flash"
transport: schift.transport,
});

Connect directly to OpenAI, Google, or Anthropic endpoints. Bypasses Schift Cloud for LLM calls (RAG still uses Schift Cloud).

const agent = new Agent({
name: "Direct Agent",
instructions: "...",
model: "gpt-4o-mini",
baseUrl: "https://api.openai.com/v1",
apiKey: process.env.OPENAI_API_KEY,
});

Connect to Ollama, vLLM, LiteLLM, or any OpenAI-compatible endpoint.

const agent = new Agent({
name: "Local Agent",
instructions: "...",
model: "llama3",
baseUrl: "http://localhost:11434/v1",
});

See the Self-hosting guide for details.

AgentWorkflowClient
Use whenInteractive Q&A, tool callingFixed data pipelines (ETL, batch)Simple embed/search calls
LoopReAct (dynamic, LLM decides)DAG (fixed steps, deterministic)None
ToolsYesBlock typesN/A
MemoryConversation historyN/AN/A
OptionTypeDefaultDescription
namestringrequiredDisplay name
instructionsstringrequiredSystem prompt for the LLM
modelModelId | string"gpt-4o-mini"LLM model identifier
transportTransportSchift Cloud transport (from schift.transport)
baseUrlstringCustom OpenAI-compatible endpoint
apiKeystringAPI key for direct/self-hosted mode
toolsAgentTool[][]Tools available to the agent
ragRAGRAG instance (auto-registers as tool)
memoryMemoryConfig{ maxMessages: 50 }Conversation memory config
maxStepsnumber10Max ReAct loop iterations

agent.run() returns an AgentRunResult:

interface AgentRunResult {
steps: AgentStep[]; // Each step in the ReAct loop
output: string; // Final answer text
totalDurationMs: number; // Total execution time
}

Each step has a type: think, tool_call, tool_result, final_answer, or error.