File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,7 +126,8 @@ async def run(
126126 attempt_refusal_text : str | None = None
127127 messages = [m .model_dump (exclude_none = True ) for m in agent_context .to_messages_array ()]
128128 if pending_refusal_retry :
129- messages .append (_refusal_retry_message (is_root = is_root ))
129+ # Sometimes gpt 5.5 randomly refuses requests. We simply need to reprompt it to continue.
130+ messages .append ({"role" : "user" , "content" : "Continue." })
130131 try :
131132 stream = await self ._run_streamed (
132133 agent = sdk_agent , input = messages , context = run_context
@@ -193,18 +194,3 @@ async def run(
193194 raise EngineAgentExhaustedError (
194195 f"agent { agent_execution .agent_id } exhausted after { MAX_CONSECUTIVE_LLM_FAILURES } consecutive failures"
195196 ) from last_exc
196-
197-
198- def _refusal_retry_message (* , is_root : bool ) -> dict [str , str ]:
199- if is_root :
200- content = (
201- "The previous model response was a refusal. Retry the request using the "
202- "available context and tools. If you can answer, provide the final answer "
203- "and end it with <final/>."
204- )
205- else :
206- content = (
207- "The previous model response was a refusal. Retry the delegated task using "
208- "the available context and tools. Return a concise answer. Do not emit <final/>."
209- )
210- return {"role" : "user" , "content" : content }
Original file line number Diff line number Diff line change @@ -132,11 +132,7 @@ async def noop_compactor(_):
132132 assert calls [1 ] == [
133133 {
134134 "role" : "user" ,
135- "content" : (
136- "The previous model response was a refusal. Retry the request using the "
137- "available context and tools. If you can answer, provide the final answer "
138- "and end it with <final/>."
139- ),
135+ "content" : "Continue." ,
140136 }
141137 ]
142138 assert len (events ) == 1
@@ -190,11 +186,7 @@ async def noop_compactor(_):
190186 events = [e async for e in bus .stream ()]
191187 retry_message = {
192188 "role" : "user" ,
193- "content" : (
194- "The previous model response was a refusal. Retry the request using the "
195- "available context and tools. If you can answer, provide the final answer "
196- "and end it with <final/>."
197- ),
189+ "content" : "Continue." ,
198190 }
199191 assert len (calls ) == 3
200192 assert calls [1 ] == [retry_message ]
@@ -355,11 +347,7 @@ async def noop_compactor(_):
355347 },
356348 {
357349 "role" : "user" ,
358- "content" : (
359- "The previous model response was a refusal. Retry the request using the "
360- "available context and tools. If you can answer, provide the final answer "
361- "and end it with <final/>."
362- ),
350+ "content" : "Continue." ,
363351 },
364352 ]
365353 assert [event .item .role for event in events ] == ["assistant" , "tool" , "assistant" ]
You can’t perform that action at this time.
0 commit comments