Skip to main content

matrixcode_core/agent/
mod.rs

1//! Agent module - event-driven AI agent implementation.
2//!
3//! Provides Agent struct with streaming responses, tool execution, and event output.
4//!
5//! ## Module Structure (Refactoring in Progress)
6//!
7//! The agent module is being refactored to improve separation of concerns:
8//!
9//! **Current Structure** (will be phased out):
10//! - `builder.rs`: Agent builder pattern
11//! - `helpers.rs`: Helper functions and utilities
12//! - `run.rs`: Main execution loop (716 lines, to be simplified)
13//! - `streaming.rs`: Streaming response handling
14//! - `tools.rs`: Tool execution logic
15//! - `types.rs`: Agent struct definition (26 fields, to be split)
16//!
17//! **New Structure** (being introduced in phases):
18//! - `core/`: Core configuration and state management
19//!   - `config.rs`: Configuration constants (max iterations, retries, etc.)
20//!   - `state.rs`: State management (messages, tokens) - Phase 3
21//!   - `executor.rs`: Execution engine - Phase 7
22//! - `context/`: Context management
23//!   - `manager.rs`: Context manager - Phase 4
24//! - `session/`: Session management
25//!   - `manager.rs`: Session manager - Phase 6
26//! - `tests/`: Comprehensive test coverage
27
28// New modular structure (being introduced)
29pub mod core;
30pub mod context;
31pub mod session;
32// Note: agent/tools/ directory will be created in Phase 5
33// Currently agent/tools.rs file exists and will be migrated
34// pub mod tools; // TODO: Enable in Phase 5
35
36// Existing structure (will be phased out in Phases 3-7)
37mod builder;
38mod helpers;
39mod run;
40mod streaming;
41mod tools;
42mod types;
43
44// Re-export public items from types directly
45pub use types::{Agent, AgentBuilder};
46pub use helpers::ContextInfo;
47
48// Re-export new core components for gradual adoption
49pub use core::{AgentConfig, AgentState};
50pub use context::AgentContext;
51pub use session::SessionManager;