Lightweight coding agent that runs in your terminal
Rust
chore: preserve one more schema layer during large tool compaction (#27084)
Celia Chen6042e5810e70
diff --git a/codex-rs/tools/src/json_schema.rs b/codex-rs/tools/src/json_schema.rsindex 528bb3adf8..acffb78b11 100644--- a/codex-rs/tools/src/json_schema.rs+++ b/codex-rs/tools/src/json_schema.rs@@ -220,7 +220,7 @@ fn deserialize_tool_input_schema(input_schema: JsonValue) -> Result<JsonSchema,// Use compact normalized JSON bytes as a cheap local proxy for the 1k-token// schema budget.const MAX_COMPACT_TOOL_SCHEMA_BYTES: usize = 4_000;-const MAX_COMPACT_TOOL_SCHEMA_DEPTH: usize = 2;+const MAX_COMPACT_TOOL_SCHEMA_DEPTH: usize = 3;/// Shrink unusually large tool schemas while preserving the top-level argument/// surface. Compaction is best-effort rather than a hard cap: it runs onlydiff --git a/codex-rs/tools/src/json_schema_tests.rs b/codex-rs/tools/src/json_schema_tests.rsindex 1f245c6a6b..3011c54f93 100644--- a/codex-rs/tools/src/json_schema_tests.rs+++ b/codex-rs/tools/src/json_schema_tests.rs@@ -1300,7 +1300,12 @@ fn collapse_deep_schema_objects_traverses_schema_children() {"complex": {"type": "object","properties": {- "leaf": { "type": "string" }+ "nested": {+ "type": "object",+ "properties": {+ "leaf": { "type": "string" }+ }+ }}},"scalar": {@@ -1313,7 +1318,12 @@ fn collapse_deep_schema_objects_traverses_schema_children() {"items": {"type": "object","properties": {- "leaf": { "type": "string" }+ "nested": {+ "type": "object",+ "properties": {+ "leaf": { "type": "string" }+ }+ }}}},@@ -1322,7 +1332,12 @@ fn collapse_deep_schema_objects_traverses_schema_children() {"additionalProperties": {"type": "object","properties": {- "leaf": { "type": "string" }+ "nested": {+ "type": "object",+ "properties": {+ "leaf": { "type": "string" }+ }+ }}}},@@ -1331,7 +1346,12 @@ fn collapse_deep_schema_objects_traverses_schema_children() {{"type": "object","properties": {- "leaf": { "type": "string" }+ "nested": {+ "type": "object",+ "properties": {+ "leaf": { "type": "string" }+ }+ }}},{ "type": "string" }@@ -1350,7 +1370,12 @@ fn collapse_deep_schema_objects_traverses_schema_children() {"object_parent": {"type": "object","properties": {- "complex": {},+ "complex": {+ "type": "object",+ "properties": {+ "nested": {}+ }+ },"scalar": {"type": "string"}@@ -1358,15 +1383,30 @@ fn collapse_deep_schema_objects_traverses_schema_children() {},"array_parent": {"type": "array",- "items": {}+ "items": {+ "type": "object",+ "properties": {+ "nested": {}+ }+ }},"map_parent": {"type": "object",- "additionalProperties": {}+ "additionalProperties": {+ "type": "object",+ "properties": {+ "nested": {}+ }+ }},"union_parent": {"anyOf": [- {},+ {+ "type": "object",+ "properties": {+ "nested": {}+ }+ },{ "type": "string" }]}