swiftide

bosun-aiMIT活跃维护

用 Rust 写的高性能 RAG 与 LLM 应用框架,支持流式索引、检索和智能体编排,适合构建低延迟的检索增强生成服务。

Fast, streaming indexing, query, and agentic LLM applications in Rust

v0.34.0发布于 2026-11-06 14:47 UTC804star +1 / 7 天74fork同步于 2026-11-10 23:53 UTC

怎么上手

由 README 提炼,执行前请确认
cargo add swiftide --features swiftide-agents,openai
cargo add anyhow
cargo add tokio --features macros,rt-multi-thread
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Rust 编写的 LLM 应用框架,用流式 RAG 管道和类型化任务图搭建智能体

用 Rust 写的高性能 RAG 与 LLM 应用框架,支持流式索引、检索和智能体编排,适合构建低延迟的检索增强生成服务。

核心能力

  • 用 Agent harness 循环调用模型、工具与生命周期钩子
  • 以 TaskNode 构建带输入输出类型的任务图并支持扇出汇合
  • 流式组合 loader、chunker、embedder、缓存与存储做索引
  • 支持暂停恢复任务以等待人工审批或外部回调
  • 接入 MCP 工具箱与 Langfuse 追踪执行过程

容易踩的坑

默认依赖精简,集成功能需按需开启对应 feature;使用 OpenAI 需先设置 OPENAI_API_KEY 环境变量;contrib 组件(文件工具、规划等)默认关闭,需单独启用 feature

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.34.0
  1. v0.34.0swiftide-v0.34.0最新正式版2026-11-06 · 2026-11-06 14:47 UTC

    New features

    • 71fa458 (agents) Add optional contrib tools and context hooks (#1207)

    • 9b64baf (core) [breaking] Chainable search strategy setters and inferable SimilaritySingleEmbedding::default() (#1226)

    BREAKING CHANGE: chainable search strategy setters and inferable SimilaritySingleEmbedding::default() (#1226)

    • 76b0960 (indexing) [breaking] Run returns pipeline stats (#1225)

    BREAKING CHANGE: run returns pipeline stats (#1225)

    • a9e21b7 (integrations) Set api_base and api_key on the OpenAI builder (#1228)

    • 27d50db (integrations) Add Perl to SupportedLanguages behind tree-sitter-perl (#1198)

    Bug fixes

    • c94ce79 (agents) Recover from unknown tool calls (#1218)

    • 8cf4ec0 (agents) Remove versions from internal dev dependencies (#1232)

    • 348d551 (anthropic) Stop double counting usage in streaming responses (#1220)

    • 669c4e5 (core) Log retried LLM attempts at WARN and give-up once at ERROR (#1229)

    • 3b1ad22 (deps) Resolve security advisories (#1215)

    • 7ac9497 (indexing) Keep the original error when a step before a batch fails (#1224)

    • cea196a (integrations) HTTP clients work without installing a rustls crypto provider (#1227)

    • 90bcadc (openai) Avoid repeating streamed text deltas (#1216)

    • 9bfa9a5 (openai) Preserve plaintext reasoning in Responses history (#1221)

    Docs

    • b988268 Showcase example crates, example anchors, agent skill and crate docs (#1223)

    • f184670 Correct the OpenAI base URL env var, retry log level and showcase branch (#1230)

    Full Changelog: https://github.com/bosun-ai/swiftide/compare/0.33.0...0.34.0

  2. v0.33.0swiftide-v0.33.02026-10-14 · 2026-10-14 15:44 UTC
    查看更新说明

    New features

    • a94760d (indexing) Convenience then_expand alias for then_chunk

    • 13d36c0 (agents) Stream output while commands run (#1162)

    • 7ff5a43 (agents) Allow fully overwriting agent history via context (#997)

    • 5bc2a94 (agents) Pass mutable agent to hooks (#1112)

    • 8ced907 (core) [breaking] Preserve exact command output (#1134)

    BREAKING CHANGE: preserve exact command output (#1134)

    • 2a0cb52 (core) [breaking] Separate command output streams (#1146)

    BREAKING CHANGE: separate command output streams (#1146)

    • 1c1dfc1 (core) [breaking] Split command output into stdout and stderr (#1066)

    BREAKING CHANGE: split command output into stdout and stderr (#1066)

    • 67998f9 (integrations) [breaking] Support AWS' new converse api (#1026)

    BREAKING CHANGE: There is now a new AWS Bedrock integration. Because Converse is fundamentally different, it's named as aws_bedrock_v2. Inner content parts for chat messages now have a more generic structure so they are also usable for AWS Bedrock. Additionally, a lifetime is introduced for ChatCompletionRequest to get some quick wins.

    • 360b3af (integrations/openai) [breaking] Present and re-use reasoning in responses api (#988)

    BREAKING CHANGE: Adds a ChatMessage::Reasoning that will include both the summary and compressed reasoning, so follow up turns in agents can use it properly, and users can display the summary in the UI if they want.

    • 8163a37 (macros) Read tool metadata from Rustdoc (#1182)

    • 087943e (openai) Support extra request body fields (#1094)

    • 65d44f2 (query) Add original and current question to answers::Simple

    • d19fc1d (scraping) Optional Spider Cloud support (#1125)

    • 1ee455d (tasks) [breaking] Add typed fan-out and joins (#1047)

    BREAKING CHANGE: Tasks now support typed fan-out and explicit joins, which changes task completion, branch inspection, transition construction, and finish semantics. Update task code to

  3. v0.32.1swiftide-v0.32.12025-11-15 · 2025-11-15 14:02 UTC
    查看更新说明

    New features

    Full Changelog: https://github.com/bosun-ai/swiftide/compare/0.32.0...0.32.1

  4. v0.32.0swiftide-v0.32.02025-11-06 · 2025-11-06 09:23 UTC
    查看更新说明

    New features

    • 9ae3331 (agents) [breaking] Improve toolspec api with schemars and support all possible types (#940)

    BREAKING CHANGE: macro-level json_type overrides beyond the basic primitives are no longer enforced; rely on Rust type inference or provide an explicit schemars-derived struct/custom schema when specific shapes are required

    • a0cc8d7 (agents) Stop with args with optional schema (#950)

    • 8ad7d97 (agents) Add configurable timeouts to commands and local executor (#963)

    • 29289d3 (agents) [breaking] Add working directories for executor and commands (#941)

    BREAKING CHANGE: Add working directories for executor and commands (#941)

    • ce724e5 (agents/mcp) Prefix mcp tools with the server name (#958)

    Bug fixes

    • 04cd88b (docs) Replace feature(doc_auto_cfg) with doc(auto_cfg)

    • 7873ce5 (integrations/openai) Simplefy responses api and improve chat completion request ergonomics (#956)

    • 24328d0 (macros) Ensure deny_unknown_attributes is set on generated args (#948)

    • 54245d0 Update async-openai and fix responses api (#964)

    • 72a6c92 Force additionalProperties properly on completion requests (#949)

    Full Changelog: https://github.com/bosun-ai/swiftide/compare/0.31.3...0.32.0

  5. v0.31.3swiftide-v0.31.32025-10-06 · 2025-10-06 15:28 UTC
    查看更新说明

    New features

    • a189ae6 (integrations/openai) Opt-in responses api (#943)

    Full Changelog: https://github.com/bosun-ai/swiftide/compare/0.31.2...0.31.3

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    CI Coverage Status Crate Badge Docs Badge Contributors Stargazers Discord MIT License LinkedIn

    Swiftide is an opinionated framework for building LLM applications. It gives you an agent harness, typed task graphs for orchestration, and streaming, composable indexing/query pipelines for RAG.

    Why Swiftide

    • Build agents that loop over LLM calls, tool calls, lifecycle hooks, and stop conditions.
    • Compose prompt steps, agents, command executors, and domain-specific Rust code in typed task graphs.
    • Fan out work into parallel branches and join typed results back into one task output.
    • Pause and resume agents or tasks for human approval, external callbacks, or persisted state.
    • Bring tools from local Rust functions, custom Tool implementations, or MCP servers.
    • Stream large indexing and retrieval workloads through loaders, transformers, embedders, caches, and storage backends.
    • Trace agent, task, and pipeline execution with tracing, metrics, and Langfuse support.

    The core primitives provide the shared interaction model. Around them, use pipelines for data flows, agents for tool loops, and tasks for graphs of typed hand-offs.

    Quick Start

    Swiftide keeps default dependencies light. Start with the agent harness and add the integrations your application needs.

    cargo add swiftide --features swiftide-agents,openai
    cargo add anyhow
    cargo add tokio --features macros,rt-multi-thread
    

    HTTPS works out of the box: Swiftide's HTTP clients use rustls with a built-in crypto provider. If your application installs its own process-wide rustls CryptoProvider before creating clients, Swiftide uses that one instead. Redis over rediss:// needs a process-wide provider; if none is installed when it connects, Swiftide installs aws-lc-rs.

    If using OpenAI, set the API key expected by the OpenAI-compatible integration:

    export OPENAI_API_KEY=...
    

    To use another OpenAI-compatible endpoint, such as a gateway, vLLM or LiteLLM, set its URL and key on the builder:

    let openai = OpenAI::builder()
        .api_base("http://127.0.0.1:8080/v1")
        .api_key("...")
        .default_prompt_model("my-model")
        .build()?;
    

    Agent Harness

    Use the agent harness to call a model, run tools, and control when an agent stops. Add tools as Rust functions or Tool implementations, and use hooks to run logic during the agent lifecycle.

    AgentContext manages conversation history and gives tools access to a ToolExecutor. Use the local executor or run commands in an isolated environment with the Docker executor.

    use anyhow::Result;
    use swiftide::{
        agents,
        chat_completion::{ToolOutput, errors::ToolError},
        traits::AgentContext,
    };
    
    #[swiftide::tool(
        description = "Looks up a Swiftide concept",
        param(name = "concept", description = "Concept to explain")
    )]
    async fn explain_concept(
        _context: &dyn AgentContext,
        concept: &str,
    ) -> Result<ToolOutput, ToolError> {
        let explanation = match concept {
            "tasks" => "Tasks compose typed nodes into explicit workflows.",
            "agents" => "Agents run LLM completions, tools, hooks, and stop conditions.",
            "pipelines" => "Pipelines stream data through indexing and retrieval steps.",
            _ => "Swiftide composes agents, task graphs, tools, and RAG pipelines.",
        };
    
        Ok(explanation.into())
    }
    
    #[tokio::main]
    async fn main() -> Result<()> {
        let openai = swiftide::integrations::openai::OpenAI::builder()
            .default_prompt_model("gpt-4o-mini")
            .build()?;
    
        agents::Agent::builder()
            .llm(&openai)
            .tools([explain_concept()])
            .on_new_message(|_, message| {
                println!("{message}");
                Box::pin(async { Ok(()) })
            })
            .limit(8)
            .build()?
            .query("Explain Swiftide tasks and agents in one paragraph.")
            .await?;
    
        Ok(())
    }
    

    The agent calls the model, exposes explain_concept as a tool, prints new messages, and stops within the configured turn limit. By default all agents have a tool to stop the loop. This can be customized.

    Agent capabilities include:

    • function tools through #[swiftide::tool], derived tools, or manual Tool implementations
    • lifecycle hooks before and after completions, tools, messages, streaming chunks, start, and stop
    • local or custom ToolExecutor implementations for command/file access
    • human-in-the-loop approval via ApprovalRequired and feedback-aware contexts
    • structured stop and failure payloads with custom JSON schemas
    • MCP toolboxes that load tools at runtime
    • streaming responses and reasoning-item handling for providers that support them

    Start with examples/hello_agents.rs, then look at the human approval, MCP, streaming, resume, and structured-output examples.

    Agent Tools and Hooks

    Use swiftide-agents-contrib to add file tools, plans, context hooks, and lazy executors to your agents. Choose the features you need and register the components on your agent.

    Feature on swiftideWhat it provides
    agents-contrib-file-toolsRead file pages or selected lines with ReadFile, replace text with ExactReplace, and edit files with ApplyPatch.
    agents-contrib-planningTrack steps and progress with UpdatePlan.
    agents-contrib-contextShorten large tool outputs with ToolSummarizer and summarize long conversations with ContextCompression.
    agents-contrib-lazy-executorStart an executor when the agent first needs it with LazyExecutor.
    cargo add swiftide --features agents-contrib-file-tools,agents-contrib-planning
    

    Import components from swiftide::agents_contrib, for example swiftide::agents_contrib::tools::ReadFile registers read_file; add .with_line_numbers() for read_file_with_line_numbers. Both accept file_name, optional one-based offset, and optional limit. Reads default to 2,000 lines, truncate long lines at 2,000 characters, and refuse windows above the 100,000-character budget. Partial pages explain how to continue. Contrib features are off by default. See the crate guide for examples, defaults, and the features to use when depending on the contrib crate directly.

    Typed Task Graphs

    Tasks are Swiftide's orchestration layer. A task is a typed graph of TaskNode steps. Each node has an input type, output type, and error type; transitions decide where the output goes next.

    Tasks are strongly typed at build time. It allows you to compose agents, other swiftide components, and functions to create complex automations.

    From examples/tasks.rs.

    use swiftide::{
        prompt::Prompt,
        tasks::{Task, TaskRunOutcome, Transition},
        traits::SimplePrompt,
    };
    use std::sync::Arc;
    
    let prompt_model: Arc<dyn SimplePrompt> = Arc::new(openai.clone());
    let briefing_agent = BriefingAgent::new(agent);
    let mut task: Task<Prompt, String> = Task::new();
    
    let brief = task.register_node(prompt_model.clone());
    let decide = task.register_node(briefing_agent);
    let render = task.register_node(prompt_model);
    
    task.starts_with(brief);
    task.register_transition(brief, move |short_brief| {
        decide.transitions_with(short_brief)
    })?;
    task.register_transition(decide, move |decision: BriefingDecision| {
        Transition::next(
            &render,
            Prompt::from("Write a hand-off note for {{audience}}: {{summary}}")
                .with_context_value("audience", decision.audience)
                .with_context_value("summary", decision.summary),
        )
    })?;
    task.register_transition(render, task.transitions_to_finish())?;
    
    match task.run(Prompt::from("Summarize the rollout plan")).await? {
        TaskRunOutcome::Completed(note) => println!("{note}"),
        TaskRunOutcome::Paused => println!("Task paused"),
    }
    

    Task capabilities include:

    • closure nodes for small glue steps and TaskNode implementations for domain logic
    • typed NodeId handles, transitions, and join payloads
    • static fan-out with explicit joins
    • sequential or parallel branch execution
    • pause, resume, and reset support
    • adapters for prompt-like Swiftide primitives, chat completions, and tool executors
    • TaskAgent for the simple case where an agent should run as a task node

    See examples/tasks.rs for a prompt plus custom agent workflow, and examples/tasks_fanout.rs for fan-out and join.

    RAG Pipelines

    Swiftide includes first-class indexing and querying pipelines for retrieval-augmented generation. Pipelines are streaming and composable: load data, transform it, embed it, cache it, store it, then retrieve and answer with a typed query flow.

    use swiftide::{
        indexing::{self, loaders::FileLoader, transformers::{ChunkCode, Embed, MetadataQACode}},
        integrations::qdrant::Qdrant,
    };
    
    async fn index(openai: swiftide::integrations::openai::OpenAI) -> anyhow::Result<()> {
        let qdrant = Qdrant::builder()
            .collection_name("swiftide-code")
            .vector_size(1536)
            .batch_size(50)
            .build()?;
    
        indexing::Pipeline::from_loader(FileLoader::new(".").with_extensions(&["rs"]))
            .with_default_llm_client(openai.clone())
            .then_chunk(ChunkCode::try_for_language_and_chunk_size("rust", 10..2048)?)
            .then(MetadataQACode::default())
            .then_in_batch(Embed::new(openai))
            .then_store_with(qdrant)
            .run()
            .await?;
    
        Ok(())
    }
    

    Indexing supports loaders, caches, chunkers, transformers, batch transformers, embedders, and storage backends. Query pipelines support query transformation, retrieval, response transformation, answer generation, hybrid search, reranking patterns, and evaluation.

    Integrations

    Swiftide integrations are feature-gated so application builds stay intentional.

    AreaSupported integrations
    LLM providersOpenAI and Azure OpenAI, Anthropic, Gemini, OpenRouter, AWS Bedrock Converse API, Groq, Ollama, Dashscope
    ToolingMCP toolboxes, local command execution, custom tool executors
    Storage and retrievalQdrant, Redis, LanceDB, PgVector, DuckDB, Redb
    Loading dataFiles, scraping, Fluvio, Kafka, Parquet, executor-backed file streams
    Code and text processingMarkdown, text splitting, tree-sitter code chunking and metadata
    Observabilitytracing, metrics, Langfuse

    Examples

    The examples has a variety of examples.

    More background is available on the Bosun blog, including posts about tasks, streaming agents, human-in-the-loop flows, and Rust performance for AI tools.

    Project Status

    Swiftide is pre-1.0. APIs can change while the agent harness and task graph APIs settle around production use. The current API docs and examples are the most reliable source of exact signatures.

    Swiftide is part of the bosun.ai project.

    Contributing

    Contributions are welcome. Read CONTRIBUTING.md, open an issue for design discussion, file a bug report, or propose a feature. Join the Discord for a faster feedback loop.

    Before opening a pull request:

    1. Run the focused checks for the crates you changed.
    2. Run cargo +nightly fmt --all -- --check.
    3. Run cargo clippy --workspace --all-targets --all-features -- -D warnings when touching shared behavior.
    4. Add or update examples, tests, or rustdoc when behavior changes.

    AI-generated code is welcome and should be reviewed like any other code. Keep abstractions small, keep domain logic separate from plumbing, and pay attention to allocations in indexing, querying, and task execution paths.

    AI agents can refer to AGENTS.md for workspace layout, commands, and expectations.

    Core Team Members

    License

    Distributed under the MIT License. See LICENSE for more information.