Add optional names to untrusted additional context (#57181)

## What changed

- Add an optional `name` to `AdditionalContextEntry` across the protocol, app-server schemas, and generated clients.
- Accept names matching `[a-z][a-z0-9_]{0,63}` only for `untrusted` context. Reject invalid names and names on `application` context before admitting turn input, returning invalid-request errors from `turn/start` and `turn/steer`.
- Preserve existing model-input rendering and deduplicate context when only its name changes.

## Testing

Add coverage for valid name boundaries, callers that omit `name`, invalid-name rejection without admitting input, and deduplication across name changes.

GitOrigin-RevId: 2caffa6fddd40ddb178733b335f520f317239edd
This commit is contained in:
Alex Kira
2026-10-26 18:23:07 +00:00
committed by copyberry
parent 457441bca9
commit 8ebd272491
21 changed files with 371 additions and 102 deletions
+2 -2
View File
@@ -2262,14 +2262,14 @@ mod tests {
continue;
}
// Only allow "?: T | null" in objects representing JSON-RPC requests,
// which we assume are called "*Params".
// Allow "?: T | null" in JSON-RPC request objects and nested request types.
let allow_optional_nullable = path
.file_stem()
.and_then(|stem| stem.to_str())
.is_some_and(|stem| {
stem.ends_with("Params")
|| stem == "InitializeCapabilities"
|| stem == "AdditionalContextEntry"
|| matches!(
stem,
"CollabAgentRef"
@@ -116,6 +116,9 @@ pub enum AdditionalContextKind {
pub struct AdditionalContextEntry {
pub value: String,
pub kind: AdditionalContextKind,
/// Optional name for untrusted context, used to label its tool output.
#[ts(optional = nullable)]
pub name: Option<String>,
}
/// Requested cyber treatment for an OpenAI model turn.