diff --git a/control-plane/config.runtime.example.json b/control-plane/config.runtime.example.json index 3c86e4ab..3fda5c5c 100644 --- a/control-plane/config.runtime.example.json +++ b/control-plane/config.runtime.example.json @@ -15,6 +15,6 @@ }, "mode": {"type": "mtp", "profile_id": "qwen4exp-kar-ple-mtp-v1"}, "max_context": 262144, - "max_output_tokens": 4096 + "max_output_tokens": 32768 } } diff --git a/control-plane/src/runtime_config.rs b/control-plane/src/runtime_config.rs index 99912d54..66c24187 100644 --- a/control-plane/src/runtime_config.rs +++ b/control-plane/src/runtime_config.rs @@ -81,7 +81,7 @@ impl std::fmt::Debug for RuntimeBackend { } /// The output limit of the runtime gRPC facade today (`RuntimeServer::generate`). -pub const DEFAULT_MAX_OUTPUT_TOKENS: u32 = 4096; +pub const DEFAULT_MAX_OUTPUT_TOKENS: u32 = leleka_backend_api::MAX_OUTPUT_TOKENS; fn seconds(name: &str, value: Option, default: f64) -> Result { let value = value.unwrap_or(default); diff --git a/control-plane/src/server_api.rs b/control-plane/src/server_api.rs index e2b9525a..cad040dd 100644 --- a/control-plane/src/server_api.rs +++ b/control-plane/src/server_api.rs @@ -325,7 +325,7 @@ async fn status_value(state: &AppState) -> Value { value["at"] = json!(now_s()); value }); - json!({ + let mut body = json!({ "service": "strata", "model": state.model, "loaded": is_loaded(&worker), "auto_load": state.control.is_some(), "structured_output": {"formats": ["json_object", "json_schema"], "method": "prompt_and_validate", @@ -342,8 +342,13 @@ async fn status_value(state: &AppState) -> Value { "last_request_at": last_at}, "last_timings": timings, "machine": {"at": now_s(), "gpu": null, "ram": null}, - "prefix_cache": state.prefix_cache.status(), - }) + }); + // Present only when a prefix cache exists: the Python server's status has no such key (golden http_surface). + let prefix = json!(state.prefix_cache.status()); + if !prefix.is_null() { + body["prefix_cache"] = prefix; + } + body } /// `GET /settings`. diff --git a/crates/backend-api/src/lib.rs b/crates/backend-api/src/lib.rs index 96e94fa1..63f4a76b 100644 --- a/crates/backend-api/src/lib.rs +++ b/crates/backend-api/src/lib.rs @@ -17,6 +17,11 @@ pub mod scripted; pub use load_mode::{InferenceMode, KarExpertLoad, KarPrefillMode, LOAD_CONFIG_VERSION}; pub use recent_ids::{DEFAULT_RECENT_IDS, RecentIds}; +/// The most output tokens one generation may ask for. A single agent turn that writes a whole source file in one tool call +/// needs well over the 4,096 this used to be (found by the Codex run of the e2e job 943: three 4,096-token turns in a row +/// ended the session); 32,768 is the default budget of the HTTP layer. +pub const MAX_OUTPUT_TOKENS: u32 = 32_768; + /// Version understood by this crate and advertised in [`BackendIdentity`]. // Version 2 replaces independent capability axes with explicit model tuples. // Version 1 identities must be refused rather than reinterpreted as version 2. diff --git a/crates/deploy/src/config.rs b/crates/deploy/src/config.rs index 698da8a3..63e6eb36 100644 --- a/crates/deploy/src/config.rs +++ b/crates/deploy/src/config.rs @@ -243,7 +243,7 @@ impl RunConfig { }, "mode": {"type": "mtp", "profile_id": MTP_PROFILE}, "max_context": self.profile.context_tokens, - "max_output_tokens": 4096, + "max_output_tokens": 32768, } }) } diff --git a/crates/leleka-runtime/src/backend.rs b/crates/leleka-runtime/src/backend.rs index ccc6f916..7c73376b 100644 --- a/crates/leleka-runtime/src/backend.rs +++ b/crates/leleka-runtime/src/backend.rs @@ -67,7 +67,7 @@ const INTEGER_WINDOWED_EXECUTION: &str = "experimental-native-integer-iq3-native-down-windowed256-retained-gr-native-t1"; const PROMPT_LIMIT: usize = 1024 * 1024; const FRAME_LIMIT: usize = 64 * 1024; -const OUTPUT_LIMIT: u32 = 4096; +const OUTPUT_LIMIT: u32 = leleka_backend_api::MAX_OUTPUT_TOKENS; const QUEUE: usize = 16; const REPLY_TIMEOUT: Duration = Duration::from_secs(1200); // Explicit KAR/MTP files require private copies and complete pinned admission @@ -3290,7 +3290,7 @@ mod tests { fn request_caps_are_checked_before_acceptance() { let mut r = request(); assert!(validate_request(&r).is_ok()); - r.max_output_tokens = 4097; + r.max_output_tokens = OUTPUT_LIMIT + 1; assert!(validate_request(&r).is_err()); r.max_output_tokens = 1; r.temperature_milli = 2001; diff --git a/desktop-core/src/runtime_rpc.rs b/desktop-core/src/runtime_rpc.rs index 0d866c1c..893765f2 100644 --- a/desktop-core/src/runtime_rpc.rs +++ b/desktop-core/src/runtime_rpc.rs @@ -532,7 +532,7 @@ impl proto::runtime_server::Runtime for RuntimeServer { uuid(&command.request_id)?; if command.prompt.len() > 1024 * 1024 || command.max_output_tokens == 0 - || command.max_output_tokens > 4096 + || command.max_output_tokens > api::MAX_OUTPUT_TOKENS { return Err(refusal( tonic::Code::InvalidArgument, @@ -1563,7 +1563,7 @@ mod tests { "epoch_mismatch" ); let mut huge = request(&epoch, &handle, "normal"); - huge.max_output_tokens = 4097; + huge.max_output_tokens = api::MAX_OUTPUT_TOKENS + 1; let rejected = client.generate(huge).await.err().unwrap(); assert_eq!( rejected.metadata().get("x-leleka-accepted").unwrap(), diff --git a/docs/rust-runtime-run.md b/docs/rust-runtime-run.md index cb6e3a2e..cc7e8b18 100644 --- a/docs/rust-runtime-run.md +++ b/docs/rust-runtime-run.md @@ -150,7 +150,7 @@ strata-next wait-ready --url http://127.0.0.1:8081 --model qwen-iq3 --key-file / What a client can rely on, and what it cannot (verified with a scripted engine only; no model has run through this path): -* `max_output_tokens` above `runtime.max_output_tokens` (default 4096, the runtime facade's own cap) is refused with a message; +* `max_output_tokens` above `runtime.max_output_tokens` (default 32768, the runtime facade's own cap, `leleka_backend_api::MAX_OUTPUT_TOKENS`; it was 4096 until the Codex e2e run showed single turns that write a whole file need more) is refused with a message; an omitted value is clamped to that cap instead of the usual 32768. * The runtime keeps a bounded window (16384) of recent generation identities to refuse a replayed id; it no longer ends after 256 generations. * Images, `reasoning_budget_tokens`, `strata_tune` and `experimental_speed_projection` are refused: the text contract cannot carry them. diff --git a/scripts/e2e/run-e2e.sh b/scripts/e2e/run-e2e.sh index 17064ba4..1310675e 100644 --- a/scripts/e2e/run-e2e.sh +++ b/scripts/e2e/run-e2e.sh @@ -80,7 +80,7 @@ cat >"$STATE/strata.json" <"$OUT/strata.json" <"$OUT/strata-next.log" 2>&1 & SPID=$!