File tree Expand file tree Collapse file tree
src/agents/extensions/experimental/codex
tests/extensions/experiemental/codex Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import asyncio
4+ import copy
45import dataclasses
56import inspect
67import json
@@ -694,7 +695,7 @@ def _resolve_output_schema(
694695 return _build_codex_output_schema (descriptor )
695696
696697 if isinstance (option , Mapping ):
697- schema = dict (option )
698+ schema = copy . deepcopy ( dict (option ) )
698699 if "type" in schema and schema .get ("type" ) != "object" :
699700 raise UserError ('Codex output schema must be a JSON object schema with type "object".' )
700701 return ensure_strict_json_schema (schema )
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import asyncio
4+ import copy
45import dataclasses
56import importlib
67import inspect
@@ -1516,6 +1517,19 @@ def test_codex_tool_resolve_output_schema_validation_errors() -> None:
15161517 codex_tool_module ._resolve_output_schema ({"type" : "string" })
15171518
15181519
1520+ def test_codex_tool_resolve_output_schema_does_not_mutate_input () -> None :
1521+ nested = {"type" : "object" , "properties" : {"y" : {"type" : "string" }}}
1522+ option = {"type" : "object" , "properties" : {"inner" : nested }}
1523+ option_snapshot = copy .deepcopy (option )
1524+
1525+ result = codex_tool_module ._resolve_output_schema (option )
1526+
1527+ assert option == option_snapshot
1528+ assert nested == {"type" : "object" , "properties" : {"y" : {"type" : "string" }}}
1529+ assert result is not None
1530+ assert result ["properties" ]["inner" ] is not nested
1531+
1532+
15191533def test_codex_tool_resolve_output_schema_descriptor () -> None :
15201534 descriptor = {
15211535 "title" : "Report" ,
You can’t perform that action at this time.
0 commit comments