Skip to content

Latest commit

 

History

History
456 lines (321 loc) · 15.7 KB

File metadata and controls

456 lines (321 loc) · 15.7 KB
AutoAgents Logo

AutoAgents

Rustによる本番運用向けマルチエージェントフレームワーク

Crates.io Documentation License Build Status codecov Ask DeepWiki Crates.io Downloads (recent) PyPI - Downloads

English | 中文 | 日本語 | Español | Français | Deutsch | 한국어 | Português (Brasil)
この翻訳はコミュニティにより保守され、英語版より遅れる可能性があります。差異がある場合は英語版が正です。

ドキュメント | | コントリビュート


このプロジェクトが気に入りましたか? GitHubでスターを付けてください

概要

AutoAgents は、Rust で知的システムを構築するためのモジュール型マルチエージェントフレームワークです。型安全なエージェントモデル、構造化されたツール呼び出し、構成可能なメモリ、差し替え可能な LLM バックエンドを統合しています。アーキテクチャは性能・安全性・合成可能性を重視し、サーバーとエッジの両方を対象に設計されています。


主な機能

  • エージェント実行:ReAct と基本エグゼキュータ、ストリーミング応答、構造化出力
  • ツール:ツールと出力の派生マクロ、ツール実行のためのサンドボックス化 WASM ランタイム
  • メモリ:スライディングウィンドウメモリと拡張可能なバックエンド
  • LLM プロバイダー:統一インターフェースによるクラウドとローカルのバックエンド
  • LLM 最適化:キャッシュやリトライなどの最適化パスを備えた LLM パイプラインを構築し、推論の速度と信頼性を向上
  • マルチエージェント編成:型付き pub/sub 通信と環境管理
  • 音声処理:ローカル TTS と STT サポート
  • 可観測性:OpenTelemetry のトレースとメトリクス、プラガブルなエクスポーター

対応 LLM プロバイダー

クラウドプロバイダー

プロバイダー 状態
OpenAI
OpenRouter
Anthropic
DeepSeek
xAI
Phind
Groq
Google
Azure OpenAI
MiniMax

ローカルプロバイダー

プロバイダー 状態
Ollama
Mistral-rs
Llama-Cpp

実験的プロバイダー

詳細: https://github.com/liquidos-ai/AutoAgents-Experimental-Backends

プロバイダー 状態
Burn ⚠️ 実験的
Onnx ⚠️ 実験的

プロバイダーの対応はコミュニティの要望に応じて拡張中です。


ベンチマーク

Benchmark

詳細は GitHub を参照してください。


インストール

前提条件

  • Rust(最新安定版推奨)
  • Cargo パッケージマネージャ
  • LeftHook(Git hooks 管理)

Prerequisite

sudo apt update
sudo apt install build-essential libasound2-dev alsa-utils pkg-config libssl-dev -y

LeftHook のインストール

macOS(Homebrew):

brew install lefthook

Linux/Windows(npm):

npm install -g lefthook

クローンとビルド

git clone https://github.com/liquidos-ai/AutoAgents.git
cd AutoAgents
lefthook install
cargo build --workspace --all-features

Python バインディング

AutoAgents は Python バインディングを個別パッケージとして提供します:

  • autoagents-py(コア Python API + クラウドバックエンド)
  • autoagents-guardrails-py(Python LLMProvider 向けのオプション Guardrails)
  • autoagents-llamacpp-py(任意のローカル llama.cpp バックエンド)
  • autoagents-mistral-rs-py(任意のローカル mistral-rs バックエンド)

このリポジトリからの開発用インストール:

uv venv --python=3.12
source .venv/bin/activate          # Windows: .venv\Scripts\activate
uv pip install -U pip maturin pytest pytest-asyncio pytest-cov

# CPU バインディングをクリーン、ビルド、インストール
make python-bindings-build

# CPU + CUDA バインディングをクリーン、ビルド、インストール
make python-bindings-build-cuda

Make ターゲットは再ビルド前に古い editable-install アーティファクトを削除するため、 ソースツリー内の古い .abi3.so が読み込まれるのを防げます。

サンプルスクリプト:

  • コアクラウド例:bindings/python/autoagents/examples/openai_agent.py
  • llama.cpp 例:bindings/python/autoagents-llamacpp/examples/llamacpp_agent.py
  • mistral-rs 例:bindings/python/autoagents-mistralrs/examples/mistral_rs_agent.py

テストの実行

cargo test --features "full" --workspace

クイックスタート

use autoagents::core::agent::memory::SlidingWindowMemory;
use autoagents::core::agent::prebuilt::executor::{ReActAgent, ReActAgentOutput};
use autoagents::core::agent::task::Task;
use autoagents::core::agent::{AgentBuilder, AgentDeriveT, AgentOutputT, DirectAgent};
use autoagents::core::error::Error;
use autoagents::core::tool::{ToolCallError, ToolInputT, ToolRuntime, ToolT};
use autoagents::llm::LLMProvider;
use autoagents::llm::backends::openai::OpenAI;
use autoagents::llm::builder::LLMBuilder;
use autoagents_derive::{agent, tool, AgentHooks, AgentOutput, ToolInput};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::sync::Arc;

#[derive(Serialize, Deserialize, ToolInput, Debug)]
pub struct AdditionArgs {
    #[input(description = "Left Operand for addition")]
    left: i64,
    #[input(description = "Right Operand for addition")]
    right: i64,
}

#[tool(
    name = "Addition",
    description = "Use this tool to Add two numbers",
    input = AdditionArgs,
)]
struct Addition {}

#[async_trait]
impl ToolRuntime for Addition {
    async fn execute(&self, args: Value) -> Result<Value, ToolCallError> {
        println!("execute tool: {:?}", args);
        let typed_args: AdditionArgs = serde_json::from_value(args)?;
        let result = typed_args.left + typed_args.right;
        Ok(result.into())
    }
}

#[derive(Debug, Serialize, Deserialize, AgentOutput)]
pub struct MathAgentOutput {
    #[output(description = "The addition result")]
    value: i64,
    #[output(description = "Explanation of the logic")]
    explanation: String,
    #[output(description = "If user asks other than math questions, use this to answer them.")]
    generic: Option<String>,
}

#[agent(
    name = "math_agent",
    description = "You are a Math agent",
    tools = [Addition],
    output = MathAgentOutput,
)]
#[derive(Default, Clone, AgentHooks)]
pub struct MathAgent {}

impl From<ReActAgentOutput> for MathAgentOutput {
    fn from(output: ReActAgentOutput) -> Self {
        let resp = output.response;
        if output.done && !resp.trim().is_empty() {
            if let Ok(value) = serde_json::from_str::<MathAgentOutput>(&resp) {
                return value;
            }
        }
        MathAgentOutput {
            value: 0,
            explanation: resp,
            generic: None,
        }
    }
}

pub async fn simple_agent(llm: Arc<dyn LLMProvider>) -> Result<(), Error> {
    let sliding_window_memory = Box::new(SlidingWindowMemory::new(10));

    let agent_handle = AgentBuilder::<_, DirectAgent>::new(ReActAgent::new(MathAgent {}))
        .llm(llm)
        .memory(sliding_window_memory)
        .build()
        .await?;

    let result = agent_handle.agent.run(Task::new("What is 1 + 1?")).await?;
    println!("Result: {:?}", result);
    Ok(())
}

#[tokio::main]
async fn main() -> Result<(), Error> {
    let api_key = std::env::var("OPENAI_API_KEY").unwrap_or("".into());

    let llm: Arc<OpenAI> = LLMBuilder::<OpenAI>::new()
        .api_key(api_key)
        .model("gpt-4o")
        .max_tokens(512)
        .temperature(0.2)
        .build()
        .expect("Failed to build LLM");

    let _ = simple_agent(llm).await?;
    Ok(())
}

AutoAgents CLI

AutoAgents CLI は YAML 設定からエージェントワークフローを実行し、HTTP で提供します。詳細は https://github.com/liquidos-ai/AutoAgents-CLI を参照してください。


すぐに始めるための例:

ツール付きのシンプルなエージェント、非常に基本的なエージェント、エッジエージェント、チェーン、Actor ベースモデル、ストリーミング、Agent Hooks の追加などを示します。

キャッシュやリトライなどの最適化パスを備えた LLM パイプラインを示し、性能と信頼性の向上を実演します。

パイプラインの LLMLayer を使い、Block・Sanitize・Audit ポリシーで入力/出力ガードレールを設定する方法を示します。

AutoAgents を Model Context Protocol (MCP) と統合する方法を示します。

ローカルモデル向けに Mistral-rs と AutoAgents を統合する方法を示します。

チェーン、プランニング、ルーティング、並列、リフレクションの各パターンを示します。

さまざまな LLM プロバイダーの利用例です。

WASM ランタイムでツールを実行できるシンプルなエージェントです。

ファイル操作機能を備えた ReAct ベースの高度なコーディングエージェントです。

リアルタイムの TTS と STT を用いた AutoAgents 音声例です。

AutoAgents-llamacpp バックエンドを使って Android 上でローカルモデルを動かす例です。


コンポーネント

AutoAgents はモジュール化アーキテクチャで構築されています:

AutoAgents/
├── crates/
│   ├── autoagents/                # Main library entry point
│   ├── autoagents-core/           # Core agent framework
│   ├── autoagents-protocol/       # Shared protocol/event types
│   ├── autoagents-llm/            # LLM provider implementations
│   ├── autoagents-telemetry/      # OpenTelemetry integration
│   ├── autoagents-toolkit/        # Collection of ready-to-use tools
│   ├── autoagents-mistral-rs/     # LLM provider implementations using Mistral-rs
│   ├── autoagents-llamacpp/       # LLM provider implementation using LlamaCpp
│   ├── autoagents-speech/         # Speech model support for TTS and STT
│   ├── autoagents-guardrails/     # LLM Guardrails implementation
│   ├── autoagents-qdrant/         # Qdrant vector store
│   └── autoagents-derive/         # Procedural macros
├── examples/                      # Example implementations
├── bindings/                      # Bindings for different languages

コアコンポーネント

  • エージェント:知能の基本単位
  • 環境:エージェントのライフサイクルと通信を管理
  • メモリ:構成可能なメモリシステム
  • ツール:外部機能の統合
  • エグゼキュータ:推論パターン(ReAct、Chain-of-Thought)

開発

テストの実行

cargo test --workspace --features default --exclude autoagents-burn --exclude autoagents-mistral-rs --exclude wasm_agent

# Coverage (requires cargo-tarpaulin)
cargo install cargo-tarpaulin
cargo tarpaulin --all-features --out html

ベンチマークの実行

cargo bench -p autoagents-core --bench agent_runtime

Git Hooks

本プロジェクトは LeftHook による Git hooks 管理を利用しています。フックは自動的に次を実行します:

  • cargo fmt --check でコードを整形
  • cargo clippy -- -D warnings で静的解析
  • cargo test --all-features --workspace --exclude autoagents-burn でテスト実行

コントリビュート

コントリビュートを歓迎します。詳細は コントリビュートガイド行動規範 をご覧ください。


ドキュメント


コミュニティ

  • GitHub Issues:バグ報告と機能要望
  • Discussions:コミュニティ Q&A とアイデア
  • Discord:Discord コミュニティに参加 https://discord.gg/zfAF9MkEtK

パフォーマンス

AutoAgents は高性能を目指して設計されています:

  • メモリ効率:構成可能なバックエンドによる最適化
  • 並行性:tokio による async/await 完全対応
  • スケーラブル:マルチエージェント協調による水平スケール
  • 型安全:Rust の型システムによるコンパイル時保証

ライセンス

AutoAgents はデュアルライセンスです:

利用用途に合わせていずれかを選択できます。


謝辞

Liquidos AI チームと、素晴らしい研究者・エンジニアコミュニティによって構築されています。

特別な感謝:

  • 素晴らしいエコシステムを提供する Rust コミュニティ
  • 高品質なモデル API を提供する LLM プロバイダー
  • AutoAgents を改善してくれる全ての貢献者

スター履歴

Star History Chart