Skip to main content
The Claude Agent SDK adapter allows you to run AgentMark prompts as agentic tasks using Anthropic’s Claude Agent SDK. This adapter is suited for agentic execution with tool use, budget controls, and built-in tracing. Available for both TypeScript and Python.

Installation

npm install @agentmark-ai/claude-agent-sdk-adapter @anthropic-ai/claude-agent-sdk

Setup

Create your AgentMark client with a ClaudeAgentModelRegistry. The registry supports maxThinkingTokens for extended thinking:
agentmark.client.ts
import { createAgentMarkClient, ClaudeAgentModelRegistry } from "@agentmark-ai/claude-agent-sdk-adapter";

const modelRegistry = new ClaudeAgentModelRegistry()
  .registerModels(["claude-sonnet-4-20250514"])
  .registerModels(["claude-opus-4-20250514"], {
    maxThinkingTokens: 10000,
  });

export const client = createAgentMarkClient({
  loader: fileLoader,
  modelRegistry,
});

Running Prompts

The Claude Agent SDK adapter runs prompts as agentic tasks. The agent executes autonomously, using tools and multi-turn reasoning:
import { client } from "./agentmark.client";

const prompt = await client.loadTextPrompt("task.prompt.mdx");
const input = await prompt.format({
  props: { task: "Analyze the auth module and suggest improvements" },
});

const result = await runAgent(input);
console.log(result.text);

Adapter Options

Configure agent behavior through adapter options:
const input = await prompt.format({
  props: { task: "Refactor the database layer" },
  adapterOptions: {
    permissionMode: "auto",
    maxTurns: 10,
    cwd: "/path/to/project",
    maxBudgetUsd: 5.00,
    allowedTools: ["read", "write", "bash"],
    disallowedTools: ["browser"],
    systemPromptPreset: "default",
    onWarning: (warning) => {
      console.warn("Agent warning:", warning);
    },
  },
});
OptionTypeScriptPythonDescription
Permission modepermissionModepermission_modeHow the agent requests permission for actions
Max turnsmaxTurnsmax_turnsMaximum number of agentic reasoning turns
Working directorycwdcwdWorking directory for file system operations
Budget limitmaxBudgetUsdmax_budget_usdMaximum USD budget for the task
Allowed toolsallowedToolsallowed_toolsWhitelist of tools the agent can use
Disallowed toolsdisallowedToolsdisallowed_toolsBlacklist of tools the agent cannot use
System promptsystemPromptPresetsystem_prompt_presetSystem prompt preset to use
Warning handleronWarningon_warningCallback for agent warnings

Object Generation

For structured output, use object prompts:
import { client } from "./agentmark.client";
import { z } from "zod";

const prompt = await client.loadObjectPrompt("extract.prompt.mdx", {
  schema: z.object({
    sentiment: z.enum(["positive", "negative", "neutral"]),
    confidence: z.number(),
  }),
});

const input = await prompt.format({
  props: { text: "This product is amazing!" },
});

const result = await runAgent(input);
console.log(result.object);

Tools

Configure tools that are converted to MCP servers internally:
agentmark.client.ts
import { createAgentMarkClient, ClaudeAgentModelRegistry, ClaudeAgentToolRegistry } from "@agentmark-ai/claude-agent-sdk-adapter";

const tools = new ClaudeAgentToolRegistry({
  weather: {
    description: "Get current weather for a location",
    parameters: {
      type: "object",
      properties: {
        location: { type: "string", description: "City name" },
      },
      required: ["location"],
    },
    execute: async ({ location }) => {
      return `The weather in ${location} is sunny and 72°F`;
    },
  },
});

export const client = createAgentMarkClient({
  loader: fileLoader,
  modelRegistry,
  tools,
});
Then reference tools in your prompts:
task.prompt.mdx
---
name: task
text_config:
  model_name: claude-sonnet-4-20250514
  tools:
    - weather
---

<System>You are a helpful assistant with access to weather data.</System>
<User>{props.task}</User>

Tracing

Enable tracing using the /traced export:
import { createAgentMarkClient, ClaudeAgentModelRegistry } from "@agentmark-ai/claude-agent-sdk-adapter/traced";

const client = createAgentMarkClient({
  loader: fileLoader,
  modelRegistry,
});

// All prompt runs are now automatically traced
const prompt = await client.loadTextPrompt("task.prompt.mdx");
const input = await prompt.format({ props: { task: "..." } });
const result = await runAgent(input);
Learn more in the Observability documentation.

Getting Started (Python)

Scaffold a Python project with the Claude Agent SDK adapter:
npm create agentmark@latest my-app
# Select "Python" when prompted for language
# Select "Claude Agent SDK" as the adapter
Run the dev server:
agentmark dev

Limitations

  • No image generation — Use the AI SDK adapter for experimental_generateImage
  • No speech generation — Use the AI SDK adapter for experimental_generateSpeech
  • No streaming — Results are returned after the agent completes all turns

Next Steps

Have Questions?

We’re here to help! Choose the best way to reach us: