Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/buzz-agent/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::time::Duration;
pub const PROTOCOL_VERSION: u32 = 2;

pub const MAX_PROMPT_BYTES: usize = 1024 * 1024;
pub const MAX_SYSTEM_PROMPT_BYTES: usize = 512 * 1024;
/// Ceiling on the combined system prompt (harness prompt + persona + hints).
/// Raised from 512 KiB to 1 MiB to fit large discovered skill/AGENTS.md hint
/// sections; matches `MAX_PROMPT_BYTES`.
pub const MAX_SYSTEM_PROMPT_BYTES: usize = 1024 * 1024;
/// Total per-result byte ceiling (text + images). Sized for image-bearing
/// results — view_image can legitimately return multi-MiB base64 payloads.
/// Text is governed by the much smaller `BUZZ_AGENT_MAX_TOOL_RESULT_TEXT_BYTES`.
Expand Down
2 changes: 1 addition & 1 deletion crates/buzz-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async fn session_new(app: &Arc<App>, id: Value, params: Value, wire_tx: &WireSen
} else {
format!("{base}\n\n{hints}")
};
// Reject combined prompts exceeding 512KB.
// Reject combined prompts exceeding MAX_SYSTEM_PROMPT_BYTES.
if prompt.len() > MAX_SYSTEM_PROMPT_BYTES {
return reject(
wire_tx,
Expand Down
10 changes: 5 additions & 5 deletions crates/buzz-agent/tests/fake_llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ async fn rejects_oversized_line() {

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn session_new_rejects_oversized_system_prompt() {
// A systemPrompt exceeding 512KB must produce a JSON-RPC error, not a panic.
// A systemPrompt exceeding 1 MiB must produce a JSON-RPC error, not a panic.
let url = spawn_fake_llm(vec![]).await;
let mut h = Harness::spawn(&url).await;
h.send(
Expand All @@ -434,8 +434,8 @@ async fn session_new_rejects_oversized_system_prompt() {
let r = h.recv().await;
assert_eq!(r["result"]["protocolVersion"], 2);

// 600KB payload — exceeds the 512KB limit.
let big_prompt = "x".repeat(600 * 1024);
// 1100KB payload — exceeds the 1 MiB limit.
let big_prompt = "x".repeat(1100 * 1024);
let id = h
.send(
"session/new",
Expand All @@ -449,8 +449,8 @@ async fn session_new_rejects_oversized_system_prompt() {
);
let err_msg = r["error"]["message"].as_str().unwrap_or("");
assert!(
err_msg.contains("512KB limit"),
"error message should mention 512KB limit, got: {err_msg}"
err_msg.contains("1024KB limit"),
"error message should mention 1024KB limit, got: {err_msg}"
);
h.shutdown().await;
}
Expand Down
Loading