1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! # Core Agent Architecture
//!
//! This module contains the core components of the VTCode agent system,
//! implementing the main agent loop, context management, and performance monitoring.
//!
//! ## Architecture Overview
//!
//! The core system is built around several key components:
//!
//! - **Agent**: Main agent implementation with conversation management
//! - **Context Compression**: Intelligent context management and summarization
//! - **Performance Monitoring**: Real-time metrics and benchmarking
//! - **Prompt Caching**: Strategic caching for improved response times
//! - **Decision Tracking**: Audit trail of agent decisions and actions
//! - **Error Recovery**: Intelligent error handling with context preservation
//! - **Timeout Detection**: Prevents runaway operations
//! - **Trajectory Management**: Session state and history tracking
//!
//! ## Key Components
//!
//! ### Agent System
//! ```rust,no_run
//! use vtcode_core::core::agent::core::Agent;
//! use vtcode_core::VTCodeConfig;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = VTCodeConfig::load()?;
//! let agent = Agent::new(config).await?;
//! agent.run().await?;
//! Ok(())
//! }
//! ```
//!
//! ### Context Management
//! ```rust,no_run
//! use vtcode_core::core::context_compression::{ContextCompressor, ContextCompressionConfig};
//!
//! let compressor = ContextCompressor::new(ContextCompressionConfig::default());
//! let compressed = compressor.compress(&conversation_history)?;
//! ```
//!
//! ### Performance Monitoring
//! ```rust,no_run
//! use vtcode_core::core::performance_profiler::PerformanceProfiler;
//!
//! let profiler = PerformanceProfiler::new();
//! profiler.start_operation("tool_execution");
//! // ... execute tool ...
//! let metrics = profiler.end_operation("tool_execution");
//! ```