@@ -106,4 +106,79 @@ describe("anthropic tool input_schema normalization", () => {
106106 } ,
107107 } ) ;
108108 } ) ;
109+
110+ test ( "strips Codex's Responses-only encrypted marker from collaboration schemas" , ( ) => {
111+ const inputSchema = toolSchema ( {
112+ type : "object" ,
113+ properties : {
114+ message : { type : "string" , encrypted : true } ,
115+ } ,
116+ required : [ "message" ] ,
117+ } ) ;
118+
119+ expect ( JSON . stringify ( inputSchema ) ) . not . toContain ( '"encrypted"' ) ;
120+ expect ( inputSchema . properties ) . toEqual ( { message : { type : "string" } } ) ;
121+ expect ( inputSchema . required ) . toEqual ( [ "message" ] ) ;
122+ } ) ;
123+
124+ test ( "preserves a property literally named encrypted" , ( ) => {
125+ expect ( toolSchema ( {
126+ type : "object" ,
127+ properties : { encrypted : { type : "boolean" } } ,
128+ } ) . properties ) . toEqual ( { encrypted : { type : "boolean" } } ) ;
129+ } ) ;
130+
131+ test ( "strips the marker under items, nested properties, and flattened root anyOf branches" , ( ) => {
132+ const inputSchema = toolSchema ( {
133+ type : "object" ,
134+ properties : {
135+ list : { type : "array" , items : { type : "string" , encrypted : true } } ,
136+ outer : {
137+ type : "object" ,
138+ properties : { nested : { type : "number" , encrypted : true } } ,
139+ } ,
140+ } ,
141+ anyOf : [
142+ { type : "object" , properties : { fromBranch : { type : "boolean" , encrypted : true } } } ,
143+ ] ,
144+ } ) ;
145+
146+ const properties = inputSchema . properties as Record < string , Record < string , unknown > > ;
147+ expect ( ( properties . list . items as Record < string , unknown > ) . encrypted ) . toBeUndefined ( ) ;
148+ expect ( ( ( properties . outer . properties as Record < string , Record < string , unknown > > ) . nested ) . encrypted ) . toBeUndefined ( ) ;
149+ expect ( properties . fromBranch . encrypted ) . toBeUndefined ( ) ;
150+ } ) ;
151+
152+ test ( "preserves literal encrypted values, required names, and encrypted definition names" , ( ) => {
153+ const inputSchema = toolSchema ( {
154+ type : "object" ,
155+ default : { encrypted : true } ,
156+ required : [ "encrypted" ] ,
157+ $defs : { encrypted : { type : "string" } } ,
158+ properties : {
159+ constant : { const : { encrypted : true } } ,
160+ choices : { enum : [ { encrypted : true } ] } ,
161+ } ,
162+ } ) ;
163+
164+ expect ( inputSchema . default ) . toEqual ( { encrypted : true } ) ;
165+ expect ( inputSchema . required ) . toEqual ( [ "encrypted" ] ) ;
166+ expect ( inputSchema . $defs ) . toEqual ( { encrypted : { type : "string" } } ) ;
167+ expect ( inputSchema . properties ) . toEqual ( {
168+ constant : { const : { encrypted : true } } ,
169+ choices : { enum : [ { encrypted : true } ] } ,
170+ } ) ;
171+ } ) ;
172+
173+ test ( "does not mutate the input schema" , ( ) => {
174+ const schema = {
175+ type : "object" ,
176+ properties : { message : { type : "string" , encrypted : true } } ,
177+ } ;
178+ const before = structuredClone ( schema ) ;
179+
180+ toolSchema ( schema ) ;
181+
182+ expect ( schema ) . toEqual ( before ) ;
183+ } ) ;
109184} ) ;
0 commit comments