fix: prevent panic when tracing subscriber already initialized
Use try_init() instead of init() for tracing subscriber setup to gracefully handle cases where a global subscriber is already set. This fixes a panic in the scout agent subprocess when spawned by the research tool, where a dependency may have already initialized tracing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,17 +26,17 @@ pub async fn run_agent_mode(
|
|||||||
use g3_core::find_incomplete_agent_session;
|
use g3_core::find_incomplete_agent_session;
|
||||||
use g3_core::get_agent_system_prompt;
|
use g3_core::get_agent_system_prompt;
|
||||||
|
|
||||||
// Initialize logging
|
// Initialize logging (use try_init to avoid panic if subscriber already set by a dependency)
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||||
let filter = EnvFilter::from_default_env()
|
let filter = EnvFilter::from_default_env()
|
||||||
.add_directive("g3_core=info".parse().unwrap())
|
.add_directive("g3_core=info".parse().unwrap())
|
||||||
.add_directive("g3_cli=info".parse().unwrap())
|
.add_directive("g3_cli=info".parse().unwrap())
|
||||||
.add_directive("llama_cpp=off".parse().unwrap())
|
.add_directive("llama_cpp=off".parse().unwrap())
|
||||||
.add_directive("llama=off".parse().unwrap());
|
.add_directive("llama=off".parse().unwrap());
|
||||||
tracing_subscriber::registry()
|
let _ = tracing_subscriber::registry()
|
||||||
.with(tracing_subscriber::fmt::layer())
|
.with(tracing_subscriber::fmt::layer())
|
||||||
.with(filter)
|
.with(filter)
|
||||||
.init();
|
.try_init();
|
||||||
|
|
||||||
let output = SimpleOutput::new();
|
let output = SimpleOutput::new();
|
||||||
|
|
||||||
|
|||||||
@@ -169,8 +169,8 @@ pub fn initialize_logging(verbose: bool) {
|
|||||||
.add_directive("llama=off".parse().unwrap())
|
.add_directive("llama=off".parse().unwrap())
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing_subscriber::registry()
|
let _ = tracing_subscriber::registry()
|
||||||
.with(tracing_subscriber::fmt::layer())
|
.with(tracing_subscriber::fmt::layer())
|
||||||
.with(filter)
|
.with(filter)
|
||||||
.init();
|
.try_init();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user