Set process title to agent name in agent mode

When running g3 --agent butler, the process title is now "g3 [butler]"
which shows up in ps, Activity Monitor, top, etc.

Uses the proctitle crate for cross-platform support.
This commit is contained in:
Dhanji R. Prasanna
2026-01-16 14:37:58 +05:30
parent 1f6a5671b2
commit 4c6878a63d
3 changed files with 16 additions and 0 deletions

12
Cargo.lock generated
View File

@@ -1361,6 +1361,7 @@ dependencies = [
"hex", "hex",
"indicatif", "indicatif",
"once_cell", "once_cell",
"proctitle",
"rand", "rand",
"ratatui", "ratatui",
"regex", "regex",
@@ -2763,6 +2764,17 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "proctitle"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "924cd8a0de90723d63fed19c5035ea129913a0bc998b37686a67f1eaf6a2aab5"
dependencies = [
"lazy_static",
"libc",
"winapi",
]
[[package]] [[package]]
name = "qoi" name = "qoi"
version = "0.4.1" version = "0.4.1"

View File

@@ -31,6 +31,7 @@ regex = "1.10"
syntect = "5.3" syntect = "5.3"
once_cell = "1.19" once_cell = "1.19"
rand = "0.8" rand = "0.8"
proctitle = "0.1.1"
[dev-dependencies] [dev-dependencies]
tempfile = "3.8" tempfile = "3.8"

View File

@@ -29,6 +29,9 @@ 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;
// Set process title to agent name (shows in ps, Activity Monitor, etc.)
proctitle::set_title(format!("g3 [{}]", agent_name));
// Initialize logging // Initialize logging
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()