wabot_feature_agent/lib.rs
1//! # wabot-feature-agent
2//!
3//! Rust port of `wabot-ts/src/feature/agent`. An **agent** is an LLM
4//! you drive from code, where a [`Mindset`] is one an end user talks
5//! to. Same models, same `#[tools]`, different control:
6//!
7//! ```ignore
8//! let mut session = factory.for_agent(triage).with_context(order_json).session().await;
9//!
10//! let urgent: bool = session.confirm("Is this complaint urgent?").await?;
11//! let plan: Plan = session.ask("Draft a resolution plan.").await?;
12//! ```
13//!
14//! `ask` returns a **validated, typed** value: the answer struct is
15//! offered to the model as a synthetic tool, and a malformed answer
16//! goes back to the model to correct rather than to the caller as an
17//! error.
18//!
19//! ## Delegation from a mindset
20//!
21//! A chatbot can hand work to an agent
22//! ([`MindsetOperator::with_agents`]). That path is deliberately
23//! narrow, because the person on the other end of the chat is not the
24//! developer:
25//!
26//! * tool sets marked `expose_to_mindsets = false` are invisible
27//! unless the binding allow-lists them by name;
28//! * each call gets a fresh session with **no chat history** — only
29//! the task text the model wrote;
30//! * a budget is capped by default
31//! ([`DEFAULT_MINDSET_AGENT_BUDGET`]), so an autonomous delegation
32//! can't run away on cost.
33//!
34//! [`Mindset`]: wabot_feature_mindset::Mindset
35//! [`MindsetOperator::with_agents`]: wabot_feature_mindset::MindsetOperator::with_agents
36
37pub mod agent;
38pub mod factory;
39pub mod mindset_toolset;
40pub mod reply;
41pub mod session;
42
43pub use agent::Agent;
44pub use factory::{AgentBuilder, AgentFactory};
45pub use mindset_toolset::{
46 agent_binding, register_agents, AgentBindingBuilder, AgentSpec, MindsetAgentToolset,
47 DEFAULT_MINDSET_AGENT_BUDGET,
48};
49pub use reply::{AgentError, AgentReply, StopReason, ANSWER_TOOL_NAME};
50pub use session::{
51 AgentBudget, AgentSession, AgentSessionDeps, BooleanAnswer, DEFAULT_CHAT_ITEMS,
52 DEFAULT_MAX_STEPS,
53};
54
55#[cfg(test)]
56mod tests;