2020import types as typing_types
2121from typing import Any
2222from typing import cast
23+ from typing import Final
2324from typing import get_args
2425from typing import get_origin
2526from typing import Optional
@@ -112,6 +113,9 @@ def _apply_nested_descriptions(prop: types.Schema, annotation: Any) -> None:
112113 _apply_nested_descriptions (prop , arg )
113114
114115
116+ _SET_MODEL_RESPONSE_TOOL_NAME : Final [str ] = 'set_model_response'
117+
118+
115119class SetModelResponseTool (BaseTool ):
116120 """Internal tool used for output schema workaround.
117121
@@ -120,6 +124,8 @@ class SetModelResponseTool(BaseTool):
120124 provide its final structured response instead of outputting text directly.
121125 """
122126
127+ NAME : Final [str ] = _SET_MODEL_RESPONSE_TOOL_NAME
128+
123129 def __init__ (self , output_schema : SchemaType ):
124130 """Initialize the tool with the expected output schema.
125131
@@ -213,9 +219,10 @@ def set_model_response() -> str:
213219 setattr (set_model_response , '__signature__' , new_sig )
214220
215221 self .func = set_model_response
222+ self .func .__name__ = self .NAME
216223
217224 super ().__init__ (
218- name = self .func . __name__ ,
225+ name = self .NAME ,
219226 description = self .func .__doc__ .strip () if self .func .__doc__ else '' ,
220227 )
221228
0 commit comments