--quiet flag suppresses logs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
|
||||
use anyhow::Result;
|
||||
/// Extract coach feedback by reading from the coach agent's specific log file
|
||||
/// Uses the coach agent's session ID to find the exact log file
|
||||
fn extract_coach_feedback_from_logs(_coach_result: &g3_core::TaskResult, coach_agent: &g3_core::Agent<ConsoleUiWriter>, output: &SimpleOutput) -> Result<String> {
|
||||
@@ -37,7 +37,8 @@ fn extract_coach_feedback_from_logs(_coach_result: &g3_core::TaskResult, coach_a
|
||||
}
|
||||
|
||||
Err(anyhow::anyhow!("Could not extract feedback from coach session: {}", session_id))
|
||||
}use anyhow::Result;
|
||||
}
|
||||
|
||||
use clap::Parser;
|
||||
use g3_config::Config;
|
||||
use g3_core::{project::Project, ui_writer::UiWriter, Agent};
|
||||
@@ -113,6 +114,10 @@ pub struct Cli {
|
||||
/// Override the model for the selected provider
|
||||
#[arg(long, value_name = "MODEL")]
|
||||
pub model: Option<String>,
|
||||
|
||||
/// Disable log file creation (no logs/ directory or session logs)
|
||||
#[arg(long)]
|
||||
pub quiet: bool,
|
||||
}
|
||||
|
||||
pub async fn run() -> Result<()> {
|
||||
@@ -218,9 +223,9 @@ pub async fn run() -> Result<()> {
|
||||
// Initialize agent
|
||||
let ui_writer = ConsoleUiWriter::new();
|
||||
let mut agent = if cli.autonomous {
|
||||
Agent::new_autonomous_with_readme(config.clone(), ui_writer, readme_content.clone()).await?
|
||||
Agent::new_autonomous_with_readme_and_quiet(config.clone(), ui_writer, readme_content.clone(), cli.quiet).await?
|
||||
} else {
|
||||
Agent::new_with_readme(config.clone(), ui_writer, readme_content.clone()).await?
|
||||
Agent::new_with_readme_and_quiet(config.clone(), ui_writer, readme_content.clone(), cli.quiet).await?
|
||||
};
|
||||
|
||||
// Execute task, autonomous mode, or start interactive mode
|
||||
@@ -235,6 +240,7 @@ pub async fn run() -> Result<()> {
|
||||
cli.show_prompt,
|
||||
cli.show_code,
|
||||
cli.max_turns,
|
||||
cli.quiet,
|
||||
)
|
||||
.await?;
|
||||
} else if let Some(task) = cli.task {
|
||||
@@ -396,7 +402,7 @@ async fn run_interactive_retro(
|
||||
|
||||
// Create agent with RetroTuiWriter
|
||||
let ui_writer = RetroTuiWriter::new(tui.clone());
|
||||
let mut agent = Agent::new_with_readme(config, ui_writer, readme_content.clone()).await?;
|
||||
let mut agent = Agent::new_with_readme_and_quiet(config, ui_writer, readme_content.clone(), false).await?;
|
||||
|
||||
// Display initial system messages
|
||||
tui.output("SYSTEM: AGENT ONLINE\n\n");
|
||||
@@ -930,6 +936,7 @@ async fn run_autonomous(
|
||||
show_prompt: bool,
|
||||
show_code: bool,
|
||||
max_turns: usize,
|
||||
quiet: bool,
|
||||
) -> Result<()> {
|
||||
let start_time = std::time::Instant::now();
|
||||
let output = SimpleOutput::new();
|
||||
@@ -1194,7 +1201,7 @@ async fn run_autonomous(
|
||||
// Use the same config with overrides that was passed to the player agent
|
||||
let config = agent.get_config().clone();
|
||||
let ui_writer = ConsoleUiWriter::new();
|
||||
let mut coach_agent = Agent::new_autonomous(config, ui_writer).await?;
|
||||
let mut coach_agent = Agent::new_autonomous_with_readme_and_quiet(config, ui_writer, None, quiet).await?;
|
||||
|
||||
// Ensure coach agent is also in the workspace directory
|
||||
project.enter_workspace()?;
|
||||
|
||||
@@ -55,6 +55,8 @@ pub struct ErrorContext {
|
||||
pub context_tokens: u32,
|
||||
/// Session ID if available
|
||||
pub session_id: Option<String>,
|
||||
/// Whether to skip file logging (quiet mode)
|
||||
pub quiet: bool,
|
||||
}
|
||||
|
||||
impl ErrorContext {
|
||||
@@ -65,6 +67,7 @@ impl ErrorContext {
|
||||
last_prompt: String,
|
||||
session_id: Option<String>,
|
||||
context_tokens: u32,
|
||||
quiet: bool,
|
||||
) -> Self {
|
||||
let timestamp = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -85,6 +88,7 @@ impl ErrorContext {
|
||||
timestamp,
|
||||
context_tokens,
|
||||
session_id,
|
||||
quiet,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +130,11 @@ impl ErrorContext {
|
||||
|
||||
/// Save error context to a file for later analysis
|
||||
fn save_to_file(&self) {
|
||||
// Skip file logging if quiet mode is enabled
|
||||
if self.quiet {
|
||||
return;
|
||||
}
|
||||
|
||||
let logs_dir = std::path::Path::new("logs/errors");
|
||||
if !logs_dir.exists() {
|
||||
if let Err(e) = std::fs::create_dir_all(logs_dir) {
|
||||
|
||||
@@ -422,11 +422,12 @@ pub struct Agent<W: UiWriter> {
|
||||
tool_call_metrics: Vec<(String, Duration, bool)>, // (tool_name, duration, success)
|
||||
ui_writer: W,
|
||||
is_autonomous: bool,
|
||||
quiet: bool,
|
||||
}
|
||||
|
||||
impl<W: UiWriter> Agent<W> {
|
||||
pub async fn new(config: Config, ui_writer: W) -> Result<Self> {
|
||||
Self::new_with_mode(config, ui_writer, false).await
|
||||
Self::new_with_mode(config, ui_writer, false, false).await
|
||||
}
|
||||
|
||||
pub async fn new_with_readme(
|
||||
@@ -434,7 +435,7 @@ impl<W: UiWriter> Agent<W> {
|
||||
ui_writer: W,
|
||||
readme_content: Option<String>,
|
||||
) -> Result<Self> {
|
||||
Self::new_with_mode_and_readme(config, ui_writer, false, readme_content).await
|
||||
Self::new_with_mode_and_readme(config, ui_writer, false, readme_content, false).await
|
||||
}
|
||||
|
||||
pub async fn new_autonomous_with_readme(
|
||||
@@ -442,15 +443,37 @@ impl<W: UiWriter> Agent<W> {
|
||||
ui_writer: W,
|
||||
readme_content: Option<String>,
|
||||
) -> Result<Self> {
|
||||
Self::new_with_mode_and_readme(config, ui_writer, true, readme_content).await
|
||||
Self::new_with_mode_and_readme(config, ui_writer, true, readme_content, false).await
|
||||
}
|
||||
|
||||
pub async fn new_autonomous(config: Config, ui_writer: W) -> Result<Self> {
|
||||
Self::new_with_mode(config, ui_writer, true).await
|
||||
Self::new_with_mode(config, ui_writer, true, false).await
|
||||
}
|
||||
|
||||
async fn new_with_mode(config: Config, ui_writer: W, is_autonomous: bool) -> Result<Self> {
|
||||
Self::new_with_mode_and_readme(config, ui_writer, is_autonomous, None).await
|
||||
pub async fn new_with_quiet(config: Config, ui_writer: W, quiet: bool) -> Result<Self> {
|
||||
Self::new_with_mode(config, ui_writer, false, quiet).await
|
||||
}
|
||||
|
||||
pub async fn new_with_readme_and_quiet(
|
||||
config: Config,
|
||||
ui_writer: W,
|
||||
readme_content: Option<String>,
|
||||
quiet: bool,
|
||||
) -> Result<Self> {
|
||||
Self::new_with_mode_and_readme(config, ui_writer, false, readme_content, quiet).await
|
||||
}
|
||||
|
||||
pub async fn new_autonomous_with_readme_and_quiet(
|
||||
config: Config,
|
||||
ui_writer: W,
|
||||
readme_content: Option<String>,
|
||||
quiet: bool,
|
||||
) -> Result<Self> {
|
||||
Self::new_with_mode_and_readme(config, ui_writer, true, readme_content, quiet).await
|
||||
}
|
||||
|
||||
async fn new_with_mode(config: Config, ui_writer: W, is_autonomous: bool, quiet: bool) -> Result<Self> {
|
||||
Self::new_with_mode_and_readme(config, ui_writer, is_autonomous, None, quiet).await
|
||||
}
|
||||
|
||||
async fn new_with_mode_and_readme(
|
||||
@@ -458,6 +481,7 @@ impl<W: UiWriter> Agent<W> {
|
||||
ui_writer: W,
|
||||
is_autonomous: bool,
|
||||
readme_content: Option<String>,
|
||||
quiet: bool,
|
||||
) -> Result<Self> {
|
||||
let mut providers = ProviderRegistry::new();
|
||||
|
||||
@@ -560,6 +584,7 @@ impl<W: UiWriter> Agent<W> {
|
||||
tool_call_metrics: Vec::new(),
|
||||
ui_writer,
|
||||
is_autonomous,
|
||||
quiet,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -922,6 +947,11 @@ The tool will execute immediately and you'll receive the result (success or erro
|
||||
|
||||
/// Save the entire context window to a per-session file
|
||||
fn save_context_window(&self, status: &str) {
|
||||
// Skip logging if quiet mode is enabled
|
||||
if self.quiet {
|
||||
return;
|
||||
}
|
||||
|
||||
let timestamp = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
@@ -1314,6 +1344,7 @@ The tool will execute immediately and you'll receive the result (success or erro
|
||||
last_prompt,
|
||||
self.session_id.clone(),
|
||||
self.context_window.used_tokens,
|
||||
self.quiet,
|
||||
)
|
||||
.with_request(
|
||||
serde_json::to_string(&request)
|
||||
|
||||
Reference in New Issue
Block a user