Skip to main content

agent_framework_core/
lib.rs

1//! # agent-framework-core
2//!
3//! Core abstractions for `agent-framework-rs`, a Rust implementation of the
4//! Microsoft Agent Framework. This crate provides the building blocks:
5//!
6//! - [`types`] — the data model: messages, content, responses, options.
7//! - [`client`] — the [`ChatClient`](client::ChatClient) trait and the
8//!   automatic function-invocation loop.
9//! - [`agent`] — the [`SupportsAgentRun`](agent::SupportsAgentRun) trait and
10//!   [`Agent`](agent::Agent).
11//! - [`compaction`] — conversation-history compaction strategies and the
12//!   [`Tokenizer`](compaction::Tokenizer) abstraction.
13//! - [`tools`] — executable tools and hosted-tool markers.
14//! - [`session`] — [`AgentSession`](session::AgentSession), a lightweight
15//!   conversation identity + state container.
16//! - [`history`] — [`HistoryProvider`](history::HistoryProvider)s: conversation
17//!   history as a [`ContextProvider`](memory::ContextProvider).
18//! - [`memory`] — context / memory providers.
19//! - [`middleware`] — agent, chat, and function middleware pipelines.
20//! - [`observability`] — OpenTelemetry GenAI-style `tracing` instrumentation.
21//! - [`skills`] — [`Skill`](skills::Skill) capability packages, surfaced via
22//!   [`SkillsProvider`](skills::SkillsProvider), a
23//!   [`ContextProvider`](memory::ContextProvider) that progressively
24//!   discloses skill instructions and resources through
25//!   framework-generated tools.
26//! - [`settings`] — secret-masking [`SecretString`](settings::SecretString)
27//!   and precedence-based setting resolution.
28//! - [`workflow`] — graph-based multi-agent workflow orchestration.
29//!
30//! ## Example
31//!
32//! ```no_run
33//! use agent_framework_core::prelude::*;
34//! # async fn demo(client: impl ChatClient + 'static) -> Result<()> {
35//! let agent = Agent::builder(client)
36//!     .name("assistant")
37//!     .instructions("You are a helpful assistant.")
38//!     .build();
39//!
40//! let response = agent.run_once("Hello!").await?;
41//! println!("{}", response.text());
42//! # Ok(())
43//! # }
44//! ```
45
46pub mod agent;
47pub mod client;
48pub mod compaction;
49pub mod error;
50pub mod history;
51pub mod memory;
52pub mod middleware;
53pub mod observability;
54pub mod session;
55pub mod settings;
56pub mod skills;
57pub mod streaming;
58pub mod tools;
59pub mod types;
60pub mod workflow;
61
62pub use error::{Error, Result};
63
64/// Commonly used imports.
65pub mod prelude {
66    pub use crate::agent::{
67        Agent, AgentBuilder, AgentRunOptions, AgentRunStream, AgentToolStreamCallback,
68        AsToolOptions, SupportsAgentRun,
69    };
70    pub use crate::client::{
71        ChatClient, ChatStream, EmbeddingClient, FunctionInvokingChatClient, RetryOn, RetryPolicy,
72        RetryingChatClient,
73    };
74    pub use crate::compaction::{
75        compact, ApproxTokenizer, CompactionProvider, CompactionStrategy, SelectiveToolResult,
76        SlidingWindow, TokenBudget, Tokenizer, Truncation,
77    };
78    pub use crate::error::{Error, Result};
79    pub use crate::history::{FileHistoryProvider, HistoryProvider, InMemoryHistoryProvider};
80    pub use crate::memory::{ContextProvider, SessionContext};
81    pub use crate::middleware::{
82        AgentContext, ChatContext, FunctionInvocationContext, LiveToolList, Middleware,
83        MiddlewarePipeline, Next,
84    };
85    pub use crate::observability::{ObservabilityConfig, ObservableChatClient};
86    pub use crate::session::{AgentSession, SessionState};
87    pub use crate::settings::{load_setting, SecretString};
88    pub use crate::skills::{Skill, SkillsProvider};
89    pub use crate::tools::{
90        hosted_code_interpreter, hosted_file_search, hosted_image_generation, hosted_mcp,
91        hosted_web_search, ApprovalMode, FunctionInvocationConfig, FunctionTool, McpApprovalMode,
92        Tool, ToolDefinition, ToolKind, ToolSource,
93    };
94    pub use crate::types::{
95        AgentResponse, AgentResponseUpdate, ChatOptions, ChatResponse, ChatResponseUpdate, Content,
96        Embedding, EmbeddingGenerationOptions, FinishReason, FunctionApprovalRequestContent,
97        FunctionApprovalResponseContent, FunctionCallContent, FunctionResultContent,
98        GeneratedEmbeddings, Message, ResponseFormat, Role, TextContent, ToolMode, UsageDetails,
99    };
100    pub use crate::workflow::{
101        CheckpointStorage, ConcurrentBuilder, Executor, FileCheckpointStorage, GroupChatBuilder,
102        GroupChatDirective, GroupChatManager, GroupChatState, HandoffBuilder,
103        HandoffInteractionMode, InMemoryCheckpointStorage, MagenticBuilder, MagenticContext,
104        MagenticManager, MagenticPlanReviewDecision, MagenticPlanReviewRequest,
105        MagenticStallInterventionDecision, MagenticStallInterventionRequest, RequestInfoExecutor,
106        SequentialBuilder, SharedState, StandardMagenticManager, Workflow, WorkflowAgent,
107        WorkflowAgentExt, WorkflowBuilder, WorkflowContext, WorkflowEvent, WorkflowExecutor,
108        WorkflowRun, WorkflowRunState,
109    };
110}