Skip to content

Commit 734f75b

Browse files
feat(api): expose reasoning input transformations on responses (#4268)
## Summary Adds the optional `input_transformations` attribute to responses. ## Changes - Read the original reasoning item ID and removal reason from each reported transformation. Co-authored-by: marcuswood-oai <[email protected]>
1 parent 141a89a commit 734f75b

5 files changed

Lines changed: 113 additions & 7 deletions

File tree

‎.castiron.stats.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schema_version: 1
2-
generation_id: a358570b-482e-447e-998d-4f5425c5d316
3-
openapi_spec_hash: 632d949bd61b801d58c87dcda5ddc605
4-
openapi_transformed_spec_hash: 9a761f59f8f8e5095ea94652ff2f91d6
2+
generation_id: a703ecb8-183a-4c22-8e77-18203e398b8f
3+
openapi_spec_hash: 52d15bd95ffcc576831a8ca7e180916c
4+
openapi_transformed_spec_hash: 77b815b67f6981a5aa066591d9dac163
55
config_hash: 01f2d28b82141ac460c9d9e8cc45ee74
6-
codegen_sha: 3a7ad42a6b1bb5cac701b1d6621307e5fadd0b3f
7-
codegen_hash: 908930605be8cf176da37b24e4f5ab6d063001b3d7eb8467e5d1c6a0b2b2b208
6+
codegen_sha: 1b8f9204c450821b2b1348d998e8dff20643c92a
7+
codegen_hash: 0c31d87d7acc6add6f5302e2333d8b49f1bb678b7187c171e8b00dbe8ca2e4ea

‎api_reference/openapi.transformed.yml‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65613,6 +65613,39 @@ components:
6561365613
- id
6561465614
- summary
6561565615
- type
65616+
InputRemovalReason:
65617+
type: string
65618+
enum:
65619+
- organization_mismatch
65620+
- end_user_mismatch
65621+
- model_mismatch
65622+
- prefix_mismatch
65623+
- turn_boundary
65624+
ReasoningInputTransformation:
65625+
properties:
65626+
type:
65627+
type: string
65628+
enum:
65629+
- reasoning
65630+
default: reasoning
65631+
x-stainless-const: true
65632+
id:
65633+
type: string
65634+
description: The original reasoning item ID.
65635+
action:
65636+
type: string
65637+
enum:
65638+
- removed
65639+
default: removed
65640+
x-stainless-const: true
65641+
reason:
65642+
$ref: '#/components/schemas/InputRemovalReason'
65643+
type: object
65644+
required:
65645+
- type
65646+
- id
65647+
- action
65648+
- reason
6561665649
Response:
6561765650
title: The response object
6561865651
allOf:
@@ -65700,6 +65733,11 @@ components:
6570065733
- content_filter
6570165734
- steered
6570265735
- type: 'null'
65736+
input_transformations:
65737+
type: array
65738+
description: Reasoning inputs withheld from the model, in input order.
65739+
items:
65740+
$ref: '#/components/schemas/ReasoningInputTransformation'
6570365741
output:
6570465742
type: array
6570565743
description: |
@@ -107920,6 +107958,39 @@ components:
107920107958
},
107921107959
"sequence_number": 1
107922107960
}
107961+
BetaReasoningInputTransformation:
107962+
properties:
107963+
type:
107964+
type: string
107965+
enum:
107966+
- reasoning
107967+
default: reasoning
107968+
x-stainless-const: true
107969+
id:
107970+
type: string
107971+
description: The original reasoning item ID.
107972+
action:
107973+
type: string
107974+
enum:
107975+
- removed
107976+
default: removed
107977+
x-stainless-const: true
107978+
reason:
107979+
$ref: '#/components/schemas/BetaInputRemovalReason'
107980+
type: object
107981+
required:
107982+
- type
107983+
- id
107984+
- action
107985+
- reason
107986+
BetaInputRemovalReason:
107987+
type: string
107988+
enum:
107989+
- organization_mismatch
107990+
- end_user_mismatch
107991+
- model_mismatch
107992+
- prefix_mismatch
107993+
- turn_boundary
107923107994
BetaResponse:
107924107995
title: The response object
107925107996
allOf:
@@ -108007,6 +108078,11 @@ components:
108007108078
- content_filter
108008108079
- steered
108009108080
- type: 'null'
108081+
input_transformations:
108082+
type: array
108083+
description: Reasoning inputs withheld from the model, in input order.
108084+
items:
108085+
$ref: '#/components/schemas/BetaReasoningInputTransformation'
108010108086
output:
108011108087
type: array
108012108088
description: |

‎scripts/castiron/generated-files.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,7 +2503,7 @@
25032503
},
25042504
"src/openai/types/beta/beta_response.py": {
25052505
"mode": "100644",
2506-
"sha256": "7b0a8482b950312722f54bc6a33177977b2a47961f934378855331f434679025"
2506+
"sha256": "860132575fca6b8f5e1a11f56ee733657e3ddc4754c6bafa0f1d86b0ac204563"
25072507
},
25082508
"src/openai/types/beta/beta_response_apply_patch_tool_call.py": {
25092509
"mode": "100644",
@@ -6143,7 +6143,7 @@
61436143
},
61446144
"src/openai/types/responses/response.py": {
61456145
"mode": "100644",
6146-
"sha256": "8a7779a4d70816c1cb2ce8d90295423b252e319422e7a677309e82671c072944"
6146+
"sha256": "9937ed8b5c0f63c842a83d7e7871327e607da852dae0dbe146468e654f2b1d8a"
61476147
},
61486148
"src/openai/types/responses/response_apply_patch_tool_call.py": {
61496149
"mode": "100644",

‎src/openai/types/beta/beta_response.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"ToolChoiceBetaSpecificProgrammaticToolCallingParam",
3232
"Conversation",
3333
"Image",
34+
"InputTransformation",
3435
"Moderation",
3536
"ModerationInput",
3637
"ModerationInputModerationResult",
@@ -104,6 +105,17 @@ class Image(BaseModel):
104105
"""Effective image context optimization policy."""
105106

106107

108+
class InputTransformation(BaseModel):
109+
id: str
110+
"""The original reasoning item ID."""
111+
112+
action: Literal["removed"]
113+
114+
reason: Literal["organization_mismatch", "end_user_mismatch", "model_mismatch", "prefix_mismatch", "turn_boundary"]
115+
116+
type: Literal["reasoning"]
117+
118+
107119
class ModerationInputModerationResult(BaseModel):
108120
"""A moderation result produced for the response input or output."""
109121

@@ -725,6 +737,9 @@ class BetaResponse(BaseModel):
725737

726738
image: Optional[Image] = None
727739

740+
input_transformations: Optional[List[InputTransformation]] = None
741+
"""Reasoning inputs withheld from the model, in input order."""
742+
728743
max_output_tokens: Optional[int] = None
729744
"""
730745
An upper bound for the number of tokens that can be generated for a response,

‎src/openai/types/responses/response.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"ToolChoiceSpecificProgrammaticToolCallingParam",
3535
"Conversation",
3636
"Image",
37+
"InputTransformation",
3738
"Moderation",
3839
"ModerationInput",
3940
"ModerationInputModerationResult",
@@ -106,6 +107,17 @@ class Image(BaseModel):
106107
"""Effective image context optimization policy."""
107108

108109

110+
class InputTransformation(BaseModel):
111+
id: str
112+
"""The original reasoning item ID."""
113+
114+
action: Literal["removed"]
115+
116+
reason: Literal["organization_mismatch", "end_user_mismatch", "model_mismatch", "prefix_mismatch", "turn_boundary"]
117+
118+
type: Literal["reasoning"]
119+
120+
109121
class ModerationInputModerationResult(BaseModel):
110122
"""A moderation result produced for the response input or output."""
111123

@@ -482,6 +494,9 @@ class Response(BaseModel):
482494

483495
image: Optional[Image] = None
484496

497+
input_transformations: Optional[List[InputTransformation]] = None
498+
"""Reasoning inputs withheld from the model, in input order."""
499+
485500
max_output_tokens: Optional[int] = None
486501
"""
487502
An upper bound for the number of tokens that can be generated for a response,

0 commit comments

Comments
 (0)