mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Share truncation logic for environment startup errors (#63077)
## What changed Use `ErrorContextBudget` to truncate model-visible startup error details in environment world state and `wait_for_environment` responses. Keep the existing 256-byte limit per detail and 512-byte total for world state error details, with truncation at UTF-8 character boundaries. ## Testing Extend the world state test to cover a multibyte error that cannot fit in the remaining budget, followed by an ASCII error that uses the last two bytes. GitOrigin-RevId: a6296fc854a383186dacaec5576e9f02e179d34c
This commit is contained in:
committed by
copyberry
parent
6fd58416e3
commit
357fe240c9
@@ -3,6 +3,7 @@ use codex_tools::JsonToolOutput;
|
||||
use codex_tools::ResponsesApiTool;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolSpec;
|
||||
use codex_utils_output_truncation::ErrorContextBudget;
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::collections::BTreeMap;
|
||||
@@ -170,10 +171,8 @@ impl ToolExecutor<ToolInvocation> for WaitForEnvironmentHandler {
|
||||
|
||||
impl CoreToolRuntime for WaitForEnvironmentHandler {}
|
||||
|
||||
// Keep failure output small while preserving a UTF-8 boundary.
|
||||
fn environment_failure(environment_id: &str, error: &str) -> FunctionCallError {
|
||||
const MAX_ERROR_BYTES: usize = 256;
|
||||
let reason = &error[..error.floor_char_boundary(MAX_ERROR_BYTES)];
|
||||
let reason = ErrorContextBudget::default().take(error);
|
||||
FunctionCallError::RespondToModel(format!(
|
||||
"Environment `{environment_id}` failed to start: {reason}"
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user