Files
BoosAPI/desktop/src-tauri/crates/open-agent-sdk/examples/05-custom-system-prompt.rs
T
boos e0a5f57793 feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as
a monorepo subdirectory under desktop/. Source only — node_modules,
dist, Cargo target and the upstream .git history are excluded.

desktop/ keeps its own independent Cargo workspace (desktop/src-tauri
with crates/*); it is not part of the backend boosapi crate, so a
`cargo check` at the metapi root still compiles only the backend. Build
the desktop app from desktop/src-tauri per desktop/README.md.

Note: app icons are still placeholder assets pending the final BoosAPI
logo. The updater signing keys live outside the repo and are not
included.
2026-06-22 11:32:57 +08:00

54 lines
1.5 KiB
Rust

// Example 5: Custom System Prompt
//
// Creates a specialized code reviewer agent with a custom system prompt.
//
// Run: cargo run --example 05-custom-system-prompt
use open_agent_sdk::{Agent, AgentOptions, SDKMessage};
use open_agent_sdk::types;
#[tokio::main]
async fn main() {
println!("--- Example 5: Custom System Prompt ---");
let mut agent = Agent::new(AgentOptions {
system_prompt: Some(
"You are a senior code reviewer. When analyzing code, focus on:\n\
1. Security vulnerabilities\n\
2. Performance issues\n\
3. Maintainability concerns\n\
Be concise and use bullet points."
.to_string(),
),
max_turns: Some(10),
..Default::default()
})
.await
.unwrap();
let (mut rx, handle) = agent
.query("Read src/lib.rs and give a brief code review.")
.await;
while let Some(event) = rx.recv().await {
match event {
SDKMessage::Assistant { message, .. } => {
let text = types::extract_text(&message);
if !text.is_empty() {
print!("{}", text);
}
}
SDKMessage::Result { .. } => {
println!("\n\n--- Done ---");
}
SDKMessage::Error { message } => {
eprintln!("Error: {}", message);
}
_ => {}
}
}
handle.await.unwrap();
agent.close().await;
}