Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: move --provider/--model flags before -p prompt in pi spawn

louis0301951777987ae28e
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index 0e94cf14c..459f19f00 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -291,10 +291,11 @@ impl PiExecutor {
) -> Result<AgentOutput> {
let mut cmd = build_async_command(pi_path);
cmd.current_dir(working_dir);
- cmd.arg("-p").arg(prompt);
+ // Flags MUST come before -p on Windows (see spawn_pi_streaming comment)
cmd.arg("--no-session");
cmd.arg("--provider").arg(resolved_provider);
cmd.arg("--model").arg(model);
+ cmd.arg("-p").arg(prompt);
if let Some(ref token) = self.user_token {
cmd.env("SCREENPIPE_API_KEY", token);
@@ -378,11 +379,14 @@ impl PiExecutor {
) -> Result<AgentOutput> {
let mut cmd = build_async_command(pi_path);
cmd.current_dir(working_dir);
- cmd.arg("-p").arg(prompt);
+ // Flags MUST come before -p on Windows: cmd.exe /C passes everything
+ // as a single string, and the long prompt text can break arg parsing
+ // if flags come after it.
cmd.arg("--mode").arg("json");
cmd.arg("--no-session");
cmd.arg("--provider").arg(resolved_provider);
cmd.arg("--model").arg(model);
+ cmd.arg("-p").arg(prompt);
if let Some(ref token) = self.user_token {
cmd.env("SCREENPIPE_API_KEY", token);