fix(runtime): output cap 4096 -> 32768 (one shared constant); /v1/status omits a null prefix_cache
The Codex tic-tac-toe run (job 943) ended after 4 minutes: the model wrote the whole index.html in one tool call, hit the runtime's 4096-token output cap three times (tool call unterminated -> response.failed 'tool parameter is incomplete', then 'incomplete: max_output_tokens' -> turn.failed -> Codex exit 1). The Original server has no such cap (max_tokens 0 = the rest of the context). RuntimeServer, the engine request check, strata-next's runtime default, the leleka-deploy generated config and the examples now use leleka_backend_api::MAX_OUTPUT_TOKENS = 32768. /v1/status keeps the Python server's key set when no prefix cache exists (http_surface golden regressed with the prefix-cache merge). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
0e7e621cfe
commit
505f3ee70f
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<f64>, default: f64) -> Result<Duration, String> {
|
||||
let value = value.unwrap_or(default);
|
||||
|
||||
@@ -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`.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -80,7 +80,7 @@ cat >"$STATE/strata.json" <<EOF
|
||||
"runtime":{"address":"127.0.0.1:18766","token_env":"LELEKA_RUNTIME_TOKEN","tokenizer_dir":"$TOK/tokenizer",
|
||||
"model":{"family":"qwen4exp","architecture":"qwen4exp","weight_format":"gguf:iq3_s",
|
||||
"artifact_digest":"sha256:80d5e3333801cedbca81a5c19c24ed6bb48fd56977acd190318f66b23a1766a3"},
|
||||
"mode":{"type":"mtp","profile_id":"qwen4exp-kar-ple-mtp-v1"},"max_context":262144,"max_output_tokens":4096}}
|
||||
"mode":{"type":"mtp","profile_id":"qwen4exp-kar-ple-mtp-v1"},"max_context":262144,"max_output_tokens":32768}}
|
||||
EOF
|
||||
|
||||
PID_INF= PID_DAE= PID_STR=
|
||||
|
||||
@@ -18,7 +18,7 @@ cat >"$OUT/strata.json" <<JSON
|
||||
{"bind":"127.0.0.1:18081","api_key_file":"$KEY","model":"qwen-iq3","shutdown_grace_s":0,
|
||||
"runtime":{"address":"$ADDR","token_env":"FAKE_RUNTIME_TOKEN","tokenizer_dir":"$TOK",
|
||||
"model":{"family":"fixture_family","architecture":"fixture_arch","weight_format":"fixture:stdio","artifact_digest":"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"},
|
||||
"mode":{"type":"native"},"max_context":262144,"max_output_tokens":4096,"attach_retry_s":0.1,"health_interval_s":0.5}}
|
||||
"mode":{"type":"native"},"max_context":262144,"max_output_tokens":32768,"attach_retry_s":0.1,"health_interval_s":0.5}}
|
||||
JSON
|
||||
"$SN" serve --config "$OUT/strata.json" >"$OUT/strata-next.log" 2>&1 &
|
||||
SPID=$!
|
||||
|
||||
Reference in New Issue
Block a user