Add code-mode output truncation protocol contracts (#57272)

## What changed

Add session options for client- or server-owned output truncation and optional `max_output_tokens` budgets for wait and terminate observations. Introduce `TerminateRequest` and update session implementations and callers to use it.

Extend the stdio and gRPC schemas with optional truncation settings and budgets, and define the `bounded-output-v1` capability. Existing sessions retain client-side truncation; providers reject server mode by default. This change defines the contracts without enabling server-side truncation.

## Testing

Extend protocol serialization coverage for `outputTruncation: "server"` while preserving existing wire shapes when optional fields are absent.

GitOrigin-RevId: 22145897ea16d385c5ba9e7549109f7a669fceb4
This commit is contained in:
Sean Huang
2026-10-26 21:36:35 +00:00
committed by copyberry
parent 7077b1edb9
commit e963cab11a
38 changed files with 329 additions and 55 deletions
+2 -2
View File
@@ -158,7 +158,7 @@ impl CodeModeService {
&self,
cell_id: CellId,
) -> Result<codex_code_mode::WaitOutcome, String> {
self.session().await?.terminate(cell_id).await
self.session().await?.terminate(cell_id.into()).await
}
pub(crate) async fn interrupt_active_cells(&self) {
@@ -170,7 +170,7 @@ impl CodeModeService {
.active_cell_ids()
.into_iter()
.map(|cell_id| async move {
if let Err(error) = session.terminate(cell_id.clone()).await {
if let Err(error) = session.terminate(cell_id.clone().into()).await {
tracing::warn!(%cell_id, %error, "failed to terminate interrupted code-mode cell");
}
}),
@@ -140,6 +140,7 @@ impl CodeModeWaitHandler {
codex_code_mode::WaitRequest {
cell_id: cell_id.clone(),
yield_time_ms: args.yield_time_ms,
max_output_tokens: None,
},
step_context.preempt.clone(),
)