Skip to content

Commit 4beffef

Browse files
authored
feat(buzz-acp): update base prompt; add buzz context and skills to Pi agents (#7335)
## Summary - launch Pi through a private Buzz wrapper so managed Pi agents receive Buzz's base prompt plus the configured thread/channel session model via `--system-prompt` - load the Buzz workspace skill directory with Pi's repeatable `--skill` flag, making `~/.buzz/.agents/skills/buzz-cli` available alongside Pi's normal global skill discovery - report Pi and `pi-acp` installation states separately so setup guidance points to the missing component `pi-acp` does not currently consume the ACP `session/new` system prompt, but its normal new-session and restore paths do honor `PI_ACP_PI_COMMAND` as the executable used to launch Pi. Buzz reserves that variable and sets it to a private generated launcher. The launcher invokes `pi` from Buzz's effective `PATH`, adds `--system-prompt <file>` and `--skill <workspace>/.agents/skills`, and forwards `pi-acp`'s RPC and session arguments unchanged. This keeps the integration entirely in `block/buzz`, without changes to Pi or `pi-acp`. ### How PI_ACP_PI_COMMAND works in `pi-acp` `PI_ACP_PI_COMMAND` selects one executable; it does not accept arguments. Therefore: ```bash # Does not work PI_ACP_PI_COMMAND="pi --skill ~/.buzz/.agents/skills" ``` Buzz does not expose this variable as user configuration. It creates a private launcher and sets `PI_ACP_PI_COMMAND` only on the `pi-acp` child. Conceptually, that launcher executes: ```sh #!/bin/sh exec pi \ --system-prompt "$PRIVATE_SYSTEM_PROMPT" \ --skill "$HOME/.buzz/.agents/skills" \ "$@" ``` ### Related issue Follow-up to #7208. No duplicate issue or open PR found. ### Testing - `just ci` - `cargo test -p buzz-acp pi_launcher` - `cargo test --manifest-path desktop/src-tauri/Cargo.toml managed_agents::env_vars::tests` - `cargo test --manifest-path desktop/src-tauri/Cargo.toml managed_agents::discovery::presets::tests` - pre-push branch checks No screenshots: the UI change is state-dependent setup guidance only. --- **Update Sep 4, 13:35:** Made `PI_ACP_PI_COMMAND` entirely Buzz-owned. - Managed agent configuration now rejects the variable as a user override. - Buzz always launches `pi` from its effective `PATH` and rejects inherited values before creating its private launcher. - Removed the custom Pi executable discovery path and its internal environment alias. --- **Update Sep 4, 14:03:** Reject inherited `PI_ACP_PI_COMMAND` values instead of replacing them. - Pi startup now fails with an actionable message telling the user to unset the variable. - Removed the Pi-specific exception from the generic ACP environment injection path. Generated with Codex --------- Signed-off-by: Salman Mohammed <[email protected]>
1 parent 4afef86 commit 4beffef

7 files changed

Lines changed: 557 additions & 51 deletions

File tree

‎crates/buzz-acp/src/base_prompt.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
You are operating inside the Buzz platform — a Nostr-based messaging platform for human-agent collaboration. The buzz-acp harness routes channel events to your session.
1+
You are an agent operating inside Buzz — a Nostr-based messaging platform for human-agent collaboration.
2+
Buzz is a desktop and mobile collaboration app organized around channels, conversations, and shared work.
23

34
## Buzz CLI
45

‎crates/buzz-acp/src/lib.rs‎

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod config;
55
mod engram_fetch;
66
mod filter;
77
mod observer;
8+
mod pi_launcher;
89
mod pool;
910
mod pool_lifecycle;
1011
mod prompt_framing;
@@ -2510,6 +2511,49 @@ async fn tokio_main() -> Result<()> {
25102511

25112512
tracing::info!("buzz-acp starting: {}", config.summary());
25122513

2514+
let cwd = current_working_directory()?;
2515+
let base_prompt_content = config.base_prompt_content.take();
2516+
let base_prompt = if config.no_base_prompt {
2517+
None
2518+
} else {
2519+
// Build standing context once under the configured policy, before any
2520+
// agent process starts. Pi consumes this through its native
2521+
// `--system-prompt`; other ACP agents consume the same bytes through
2522+
// session/new or legacy first-turn framing.
2523+
Some(
2524+
config.session_policy.append_session_model(
2525+
base_prompt_content
2526+
.as_deref()
2527+
.unwrap_or(include_str!("base_prompt.md")),
2528+
),
2529+
)
2530+
};
2531+
// PI_ACP_PI_COMMAND is Buzz-owned. Strip stale/user-provided copies from
2532+
// every adapter before optionally installing Buzz's generated Pi launcher.
2533+
config
2534+
.persona_env_vars
2535+
.retain(|(key, _)| !key.eq_ignore_ascii_case(pi_launcher::PI_ACP_PI_COMMAND_ENV));
2536+
let managed_skills_dir = std::path::Path::new(&cwd).join(".agents/skills");
2537+
let inherited_pi_command_is_set =
2538+
std::env::var_os(pi_launcher::PI_ACP_PI_COMMAND_ENV).is_some();
2539+
let (pi_launch_override, base_prompt) = pi_launcher::PiLaunchOverride::prepare(
2540+
&config.agent_command,
2541+
base_prompt,
2542+
&managed_skills_dir,
2543+
inherited_pi_command_is_set,
2544+
)
2545+
.context("failed to prepare Pi launch overrides")?;
2546+
if let Some(prepared) = pi_launch_override.as_ref() {
2547+
config.persona_env_vars.push((
2548+
pi_launcher::PI_ACP_PI_COMMAND_ENV.to_string(),
2549+
prepared.launcher_path().to_string_lossy().into_owned(),
2550+
));
2551+
tracing::info!(
2552+
skills_dir = %managed_skills_dir.display(),
2553+
"configured Pi to consume Buzz standing context and managed skills through native CLI flags"
2554+
);
2555+
}
2556+
25132557
let observer = config
25142558
.relay_observer
25152559
.then(observer::ObserverHandle::in_process);
@@ -2758,8 +2802,6 @@ async fn tokio_main() -> Result<()> {
27582802
);
27592803
}
27602804

2761-
let base_prompt_content = config.base_prompt_content.take();
2762-
let cwd = current_working_directory()?;
27632805
let ctx = Arc::new(PromptContext {
27642806
mcp_servers: build_mcp_servers(&config),
27652807
initial_message: config.initial_message.clone(),
@@ -2770,20 +2812,7 @@ async fn tokio_main() -> Result<()> {
27702812
system_prompt: config.system_prompt.clone(),
27712813
session_title: config.session_title.clone(),
27722814
team_instructions: config.team_instructions.clone(),
2773-
base_prompt: if config.no_base_prompt {
2774-
None
2775-
} else {
2776-
// Build standing context once under the configured policy, before
2777-
// any session/new. Both modern ACP and legacy first-turn framing
2778-
// consume this same assembled base (including custom base files).
2779-
Some(
2780-
config.session_policy.append_session_model(
2781-
base_prompt_content
2782-
.as_deref()
2783-
.unwrap_or(include_str!("base_prompt.md")),
2784-
),
2785-
)
2786-
},
2815+
base_prompt,
27872816
heartbeat_prompt: config.heartbeat_prompt.clone(),
27882817
cwd,
27892818
rest_client: relay.rest_client(),
@@ -4116,6 +4145,10 @@ async fn tokio_main() -> Result<()> {
41164145
// for the background task to finish, rather than aborting immediately (#40).
41174146
relay.shutdown().await;
41184147

4148+
// Pi may restore subprocesses throughout the pool lifetime. Remove its
4149+
// private prompt and launcher only after every adapter has shut down.
4150+
drop(pi_launch_override);
4151+
41194152
tracing::info!("buzz-acp stopped");
41204153
Ok(())
41214154
}
@@ -5208,6 +5241,9 @@ mod agent_draft_prompt_tests {
52085241
#[test]
52095242
fn shared_base_prompt_teaches_portable_agent_drafts() {
52105243
let prompt = include_str!("base_prompt.md");
5244+
assert!(prompt.starts_with(
5245+
"You are an agent operating inside Buzz — a Nostr-based messaging platform for human-agent collaboration.\nBuzz is a desktop and mobile collaboration app organized around channels, conversations, and shared work."
5246+
));
52115247
assert!(prompt.contains("buzz agents draft-create"));
52125248
assert!(prompt.contains("ask for at most two things"));
52135249
assert!(prompt.contains("what it should do day-to-day"));

0 commit comments

Comments
 (0)