LINKORA
OverviewQuickstart

Agent SDK

Build AI agents with multi-turn loops, tools, and conversation state

The Agent SDK (@linkora/agent) provides the primitives you need to build agentic applications on Linkora. Instead of manually wiring up conversation loops, tool dispatch, and state tracking, the Agent SDK handles all of that so you can focus on defining *what* your agent does.

The Agent SDK is built on top of the TypeScript Client SDK: @linkora/agent depends on @linkora/sdk and installs it for you, so its Linkora class accepts the same client options. Add @linkora/sdk to your own dependencies if you also want to call REST endpoints directly, so that you control which version you get.

When to use the Agent SDK

Choose the Agent SDK when you need agentic behavior: multi-step reasoning where the model calls tools, processes results, and decides what to do next.

  • Multi-turn agent loops: callModel automatically loops until a stop condition is met
  • Tool definitions: define tools with the tool() helper and the SDK executes them for you
  • Stop conditions: control when the loop ends with stepCountIs, hasToolCall, maxCost, and more
  • Conversation state: the SDK tracks messages, tool results, and context across turns
  • Streaming: real-time token output within each agent step
  • Dynamic parameters: change model, temperature, or tools between turns based on context
  • MCP tools: plug in a remote Model Context Protocol server and its tools drop straight into callModel
If you only need simple request/response calls to a model without agent loops, the Client SDKs are a lighter-weight option.

Installation

LanguagePackage
TypeScript[`@linkora/agent`](https://www.npmjs.com/package/@linkora/agent)
Python[`linkora-agent-sdk`](https://pypi.org/project/linkora-agent-sdk/)
Go[`go-agent`](https://pkg.go.dev/github.com/LinkoraTeam/go-agent)
npm install @linkora/agent

The Python and Go packages are ports of @linkora/agent kept in sync automatically. See the Python agent SDK repository and Go agent SDK repository for language-specific details. The rest of this Agent SDK documentation uses TypeScript examples.

Quick example

import { Linkora, tool } from '@linkora/agent';
import { z } from 'zod';

const linkora = new Linkora({
  apiKey: process.env.LINKORA_API_KEY,
});

const weatherTool = tool({
  name: 'get_weather',
  description: 'Get the current weather for a location',
  inputSchema: z.object({
    location: z.string().describe('City name'),
  }),
  execute: async ({ location }) => {
    return { temperature: 72, condition: 'sunny', location };
  },
});

const result = linkora.callModel({
  model: '~anthropic/claude-sonnet-latest',
  input: 'What is the weather in San Francisco?',
  tools: [weatherTool],
});

const text = await result.getText();
console.log(text);

The SDK sends the input to the model, receives a tool call, executes get_weather, feeds the result back, and returns the final response, all in one callModel invocation.

Core concepts

`callModel`

The main entry point. It runs an inference loop that:

  1. Sends the input to the model
  2. If the model returns tool calls, executes them automatically
  3. Appends tool results to the conversation
  4. Repeats until a stop condition is met or no more tool calls are made

See the Call Model documentation for the full API.

Tools

Define tools with the tool() helper. Each tool has a name, description, Zod parameter schema, and an execute function. The SDK handles serialization, validation, and dispatch.

import { tool } from '@linkora/agent';
import { z } from 'zod';

const searchTool = tool({
  name: 'search',
  description: 'Search the web',
  inputSchema: z.object({ query: z.string() }),
  execute: async ({ query }) => {
    // Your search implementation
    return { results: ['...'] };
  },
});

Stop conditions

Control when the agent loop terminates:

import { Linkora, stepCountIs, maxCost } from '@linkora/agent';

const linkora = new Linkora({
  apiKey: process.env.LINKORA_API_KEY,
});

const result = linkora.callModel({
  model: '~anthropic/claude-sonnet-latest',
  input: 'Research this topic thoroughly',
  tools: [searchTool],
  stopWhen: [stepCountIs(10), maxCost(0.50)],
});

Agent SDK vs Client SDKs

Agent SDKClient SDKs
**Focus**Agentic primitives: multi-turn loops, tools, stop conditionsLean API client that mirrors the REST API with full type safety
**Use when**You want built-in agent loops, tool execution, and state managementYou want direct model calls and manage orchestration yourself
**Conversation state**Managed for you via `callModel`You manage it
**Tool execution**Automatic with the `tool()` helperYou dispatch tool calls
**Languages**TypeScript, Python, GoTypeScript, Python, Go

Next steps