Skip to content

CloudPlayPlus/open_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌊 Open Agent

A commercial-grade Flutter AI Agent SDK with multi-provider support, tool calling, and MCP (Model Context Protocol).

Architecture

open_agent/              # Umbrella package (re-exports everything)
open_agent_core/         # Pure Dart SDK — no Flutter dependency
  ├── models/            # Message, Content, Tool, ChatEvent
  ├── client/            # ChatProvider interface + OpenAI adapter
  ├── agent/             # AgentLoop (tool calling cycle) + Session
  └── mcp/              # MCP tool bridge
open_agent_ui/           # Flutter UI widgets (TODO)
example/                 # Demo app

Quick Start

import 'package:open_agent_core/open_agent_core.dart';

// 1. Configure
final config = AgentConfig.openai(
  apiKey: 'sk-...',
  model: 'gpt-4o',
  systemPrompt: 'You are a helpful assistant.',
);

// 2. Create session
final session = ChatSession(
  config: config,
  provider: OpenAiProvider(config),
);

// 3. Chat with streaming
await for (final event in session.send('Hello!')) {
  switch (event) {
    case TextDelta(:final text):
      stdout.write(text); // Stream to UI
    case ToolCallEvent(:final name):
      print('Calling tool: $name');
    case DoneEvent():
      print('\n--- Done ---');
    default:
      break;
  }
}

Tool Calling

final tools = ToolRegistry();
tools.register(ToolDefinition(
  name: 'search',
  description: 'Search the web',
  parameters: {
    'type': 'object',
    'properties': {
      'query': {'type': 'string', 'description': 'Search query'},
    },
    'required': ['query'],
  },
  executor: (args) async {
    return await mySearchApi(args['query']);
  },
));

final session = ChatSession(
  config: config,
  provider: OpenAiProvider(config),
  tools: tools,
);

// The AgentLoop automatically:
// 1. Sends messages to the model
// 2. Detects tool call requests
// 3. Executes tools
// 4. Feeds results back
// 5. Repeats until final answer

MCP Integration

final mcpBridge = McpToolBridge();

// Connect to an MCP server (e.g. filesystem, database, etc.)
await mcpBridge.connectServer(
  name: 'filesystem',
  transport: StdioTransport(command: 'npx', args: ['-y', '@anthropic/mcp-filesystem']),
);

// Register all MCP tools into the agent
mcpBridge.registerAll(tools);

// Now the agent can use MCP tools transparently!

Supported Providers

Any OpenAI-compatible API works out of the box:

Provider Base URL
OpenAI https://api.openai.com/v1
DeepSeek https://api.deepseek.com/v1
Groq https://api.groq.com/openai/v1
Ollama http://localhost:11434/v1
Together https://api.together.xyz/v1

Roadmap

  • Core SDK (pure Dart)
  • OpenAI-compatible provider
  • Tool calling agent loop
  • MCP client bridge
  • Anthropic native provider
  • Google Gemini native provider
  • Flutter UI widget library
  • Audio/TTS support
  • Persistent sessions (SQLite)
  • Token budget / context window management

Documentation

License

MIT

About

Commercial-grade Flutter AI Agent SDK with multi-provider support, tool calling, and MCP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors