1919from typing import Any , Dict , List , Optional , Tuple , Union
2020
2121# Import the base policy and types for proper recording functionality
22- from openai . types import CompletionUsage
22+ from typing import Optional as _Optional
2323
2424from ..playback_policy import PlaybackPolicyBase
2525from ..types import MCPToolCall
@@ -73,7 +73,7 @@ async def _generate_live_tool_calls(
7373 tool_schemas : List [Dict ],
7474 env_index : int ,
7575 conversation_history : List [Dict [str , Any ]],
76- ) -> Tuple [List [MCPToolCall ], CompletionUsage , str ]:
76+ ) -> Tuple [List [MCPToolCall ], Optional [ Dict [ str , int ]], Optional [ str ] ]:
7777 """
7878 Generate tool calls in live mode using the static action sequence.
7979
@@ -105,7 +105,7 @@ async def _generate_live_tool_calls(
105105
106106 logger .debug (f"🎮 Env { env_index } step { step_count } : { action } " )
107107
108- usage_stats = CompletionUsage ( prompt_tokens = 0 , completion_tokens = 0 , total_tokens = 0 )
108+ usage_stats : Optional [ Dict [ str , int ]] = { " prompt_tokens" : 0 , " completion_tokens" : 0 , " total_tokens" : 0 }
109109 return [tool_call ], usage_stats , None
110110
111111 def add_tool_response (
@@ -116,7 +116,7 @@ def add_tool_response(
116116 conversation_history : List [Dict [str , Any ]],
117117 reward : float = 0.0 ,
118118 terminated : bool = False ,
119- info : Dict [str , Any ] = None ,
119+ info : Optional [ Dict [str , Any ] ] = None ,
120120 ):
121121 """Add tool call and response to conversation history for recording."""
122122
@@ -220,7 +220,7 @@ async def _generate_live_tool_calls(
220220 tool_schemas : List [Dict ],
221221 env_index : int ,
222222 conversation_history : List [Dict [str , Any ]],
223- ) -> Tuple [List [MCPToolCall ], CompletionUsage , str ]:
223+ ) -> Tuple [List [MCPToolCall ], Optional [ Dict [ str , int ]], Optional [ str ] ]:
224224 """
225225 Generate random tool calls in live mode.
226226
@@ -240,7 +240,7 @@ async def _generate_live_tool_calls(
240240
241241 logger .debug (f"🎲 Env { env_index } : { action } " )
242242
243- usage_stats = CompletionUsage ( prompt_tokens = 0 , completion_tokens = 0 , total_tokens = 0 )
243+ usage_stats : Optional [ Dict [ str , int ]] = { " prompt_tokens" : 0 , " completion_tokens" : 0 , " total_tokens" : 0 }
244244 return [tool_call ], usage_stats , None
245245
246246 def add_tool_response (
@@ -251,7 +251,7 @@ def add_tool_response(
251251 conversation_history : List [Dict [str , Any ]],
252252 reward : float = 0.0 ,
253253 terminated : bool = False ,
254- info : Dict [str , Any ] = None ,
254+ info : Optional [ Dict [str , Any ] ] = None ,
255255 ):
256256 """Add tool call and response to conversation history for recording."""
257257
0 commit comments