refactor(g3-core): add section markers to lib.rs for better organization
Added clear section comments to organize the 3000-line lib.rs into logical groupings: - CONSTRUCTION METHODS (~line 159) - CONFIGURATION & PROVIDER RESOLUTION (~line 444) - TASK EXECUTION (~line 782) - SESSION MANAGEMENT (~line 1069) - CONTEXT WINDOW OPERATIONS (~line 1148) - STREAMING & LLM INTERACTION (~line 1563) - TOOL EXECUTION (~line 2825) This improves code navigation and provides clear boundaries for future extraction into separate modules. No behavioral changes - all 191 tests pass. Agent: fowler
This commit is contained in:
@@ -153,6 +153,10 @@ pub struct Agent<W: UiWriter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<W: UiWriter> Agent<W> {
|
impl<W: UiWriter> Agent<W> {
|
||||||
|
// =========================================================================
|
||||||
|
// CONSTRUCTION METHODS
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
pub async fn new(config: Config, ui_writer: W) -> Result<Self> {
|
pub async fn new(config: Config, ui_writer: W) -> Result<Self> {
|
||||||
Self::new_with_mode(config, ui_writer, false, false).await
|
Self::new_with_mode(config, ui_writer, false, false).await
|
||||||
}
|
}
|
||||||
@@ -436,6 +440,10 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// CONFIGURATION & PROVIDER RESOLUTION
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
/// Validate that the system prompt is the first message in the conversation history.
|
/// Validate that the system prompt is the first message in the conversation history.
|
||||||
/// This is a critical invariant that must be maintained for proper agent operation.
|
/// This is a critical invariant that must be maintained for proper agent operation.
|
||||||
///
|
///
|
||||||
@@ -772,6 +780,10 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
self.session_id.as_deref()
|
self.session_id.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// TASK EXECUTION
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
pub async fn execute_task(
|
pub async fn execute_task(
|
||||||
&mut self,
|
&mut self,
|
||||||
description: &str,
|
description: &str,
|
||||||
@@ -1050,6 +1062,10 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
Ok(task_result)
|
Ok(task_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// SESSION MANAGEMENT
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
/// Generate a session ID based on the initial prompt
|
/// Generate a session ID based on the initial prompt
|
||||||
fn generate_session_id(&self, description: &str) -> String {
|
fn generate_session_id(&self, description: &str) -> String {
|
||||||
session::generate_session_id(description, self.agent_name.as_deref())
|
session::generate_session_id(description, self.agent_name.as_deref())
|
||||||
@@ -1124,6 +1140,10 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// CONTEXT WINDOW OPERATIONS
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
/// Manually trigger context compaction regardless of context window size
|
/// Manually trigger context compaction regardless of context window size
|
||||||
/// Returns Ok(true) if compaction was successful, Ok(false) if it failed
|
/// Returns Ok(true) if compaction was successful, Ok(false) if it failed
|
||||||
pub async fn force_compact(&mut self) -> Result<bool> {
|
pub async fn force_compact(&mut self) -> Result<bool> {
|
||||||
@@ -1536,6 +1556,10 @@ impl<W: UiWriter> Agent<W> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// STREAMING & LLM INTERACTION
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
/// Build the final response and prepare for return.
|
/// Build the final response and prepare for return.
|
||||||
///
|
///
|
||||||
/// This is the single canonical path for completing a streaming turn:
|
/// This is the single canonical path for completing a streaming turn:
|
||||||
@@ -2795,6 +2819,10 @@ Skip if nothing new. Be brief."#;
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// TOOL EXECUTION
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
pub async fn execute_tool(&mut self, tool_call: &ToolCall) -> Result<String> {
|
pub async fn execute_tool(&mut self, tool_call: &ToolCall) -> Result<String> {
|
||||||
// Tool tracking is handled by execute_tool_in_dir
|
// Tool tracking is handled by execute_tool_in_dir
|
||||||
self.execute_tool_in_dir(tool_call, None).await
|
self.execute_tool_in_dir(tool_call, None).await
|
||||||
|
|||||||
Reference in New Issue
Block a user