Skip to content

Open-source alternative to Claude Agent SDK — lightweight, provider-agnostic. Beta stage, contributions & feedback welcome!

License

Notifications You must be signed in to change notification settings

Octane0411/open-agent-sdk

Repository files navigation

Open Agent SDK

Build in Public License: MIT TypeScript

An open-source alternative to Claude Agent SDK — lightweight, customizable, and provider-agnostic.

中文文档


What is this?

Open Agent SDK is a TypeScript framework for building AI agents. It provides a developer experience similar to Claude Agent SDK but with full transparency and no vendor lock-in.

Why Choose This?

🎯 API Compatible with Claude Agent SDK

Drop-in replacement with feature parity — same Agent loop, tools, sessions, permissions, and hooks. Minimal learning curve for existing Claude Agent SDK users.

🔓 Open Source & Extensible

Full MIT-licensed source code. Easily customize and extend with custom tools, providers, and hooks.

🚀 No Claude Code Dependency

Pure TypeScript implementation that runs independently. No need to install or run Claude Code — works with any LLM provider directly.

Key features:

  • Agent Loop — Observation-thought-action cycle for autonomous agents
  • Built-in Tools — File operations (read/write/edit), shell execution, code search (glob/grep), web search
  • Streaming Support — Real-time response streaming with token usage tracking
  • Multi-Provider — Works with OpenAI, Google Gemini, and Anthropic
  • Provider Extensibility — Add custom providers with a simple interface
  • Session Management — Persistent conversations with InMemory and File storage
  • Permission System — 4 permission modes (default/acceptEdits/bypassPermissions/plan)
  • Hooks Framework — Event-driven extensibility (10 hook events)
  • Subagent System — Delegate tasks to specialized agents
  • Type Safety — Full TypeScript support with strict type constraints
  • Cancellation — AbortController support for interrupting long-running operations

Installation

npm install open-agent-sdk@alpha

Or with specific package manager:

# npm
npm install open-agent-sdk@alpha

# yarn
yarn add open-agent-sdk@alpha

# pnpm
pnpm add open-agent-sdk@alpha

# bun
bun add open-agent-sdk@alpha

Note: Currently in alpha. Use @alpha tag to install the latest alpha version.

Requirements:

  • Bun >= 1.0.0 (primary runtime)
  • Node.js >= 20 (with peer dependencies)
  • TypeScript >= 5.0

Quick Start

Basic Usage

import { prompt } from 'open-agent-sdk';

const result = await prompt("What files are in the current directory?", {
  model: 'your-model',
  apiKey: process.env.OPENAI_API_KEY,
});

console.log(result.result);
console.log(`Duration: ${result.duration_ms}ms`);
console.log(`Tokens: ${result.usage.input_tokens} in / ${result.usage.output_tokens} out`);

Session-Based Conversations

import { createSession } from 'open-agent-sdk';

const session = createSession({
  model: 'your-model',
  apiKey: process.env.OPENAI_API_KEY,
});

// Send message
await session.send("What is 5 + 3?");

// Stream the response
for await (const message of session.stream()) {
  if (message.type === 'assistant') {
    console.log(message.content);
  }
}

// Continue conversation (context preserved)
await session.send("Multiply that by 2");
for await (const message of session.stream()) {
  console.log(message.content);
}

session.close();

API Reference

See the full API Reference for detailed documentation on:

  • prompt() - Execute single prompts with the agent
  • createSession() / resumeSession() - Manage persistent conversations
  • All configuration options and types

Documentation

Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                              Open Agent SDK                                  │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                              │
│   User Code              Core SDK                      External              │
│  ┌─────────┐           ┌─────────┐                   ┌─────────┐            │
│  │ prompt()│──────────►│ Agent   │──────────────────►│ OpenAI  │            │
│  └─────────┘           │  Loop   │                   │ Google  │            │
│  ┌─────────┐           │         │                   │Anthropic│            │
│  │ Session │──────────►│ ┌─────┐ │                   └─────────┘            │
│  └─────────┘           │ │Tools│ │                                          │
│                        │ │(14) │ │                   ┌─────────┐            │
│                        │ └─────┘ │──────────────────►│  File   │            │
│                        │ ┌─────┐ │                   │  Edit   │            │
│                        │ │Hooks│ │                   │ Search  │            │
│                        │ │(10) │ │                   │  Web    │            │
│                        │ └─────┘ │                   │ Tasks   │            │
│                        └────┬────┘                   └─────────┘            │
│                             │                                               │
│                        ┌────┴────┐         ┌─────────┐                      │
│                        │ Session │◄───────►│Storage  │                      │
│                        │ Manager │         │Memory/  │                      │
│                        └─────────┘         │File     │                      │
│                                            └─────────┘                      │
└─────────────────────────────────────────────────────────────────────────────┘

Project Status

Current Version: v0.1.0-alpha.0

This project is being developed in public. Follow our progress:

Roadmap

Version Features Status
v0.1.0-alpha Core Agent loop, 14 tools, 3 providers, Session, Hooks, Permissions ✅ Released
v0.1.0-beta Structured outputs, File checkpointing, Session forking enhancements 🚧 In Progress
v0.1.0 Stable release 📋 Planned
v0.2.0 Browser automation, Skill system, Query class 📋 Planned
v1.0.0 Full Claude Agent SDK compatibility, Python SDK 📋 Planned

Benchmarks

We're preparing comprehensive benchmarks comparing Open Agent SDK with Claude Agent SDK across various real-world scenarios:

  • Code Understanding - Analyze and explain complex codebases
  • File Operations - Read, write, and edit files efficiently
  • Task Completion - Multi-step task execution and reasoning
  • Tool Usage - Effectiveness in using built-in tools
  • Performance - Response time, token usage, and accuracy

Status: 📋 Coming Soon

Results will be published in the docs/benchmarks/ directory with full methodology and reproducible test cases.

Development

# Clone the repository
git clone https://github.com/Octane0411/open-agent-sdk.git
cd open-agent-sdk

# Install dependencies
bun install

# Run tests
bun test

# Run with coverage
bun test --coverage

# Type checking
cd packages/core && npx tsc --noEmit

# Run demo
GEMINI_API_KEY=your-key bun examples/demo.ts

Why build this?

Claude Agent SDK is excellent but closed-source. We wanted:

  1. Full transparency — Open code, free to customize
  2. Provider independence — No lock-in to a single vendor
  3. Lightweight core — Focused, understandable architecture
  4. No Claude Code dependency — Pure TypeScript, runs independently

Contributing

Contributions welcome. Please read CONTRIBUTING.md.

License

MIT © 2026 Octane0411

About

Open-source alternative to Claude Agent SDK — lightweight, provider-agnostic. Beta stage, contributions & feedback welcome!

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •