"""No-key check of the approval pause, using a scripted stand-in model. The stand-in asks for close_ticket(7) on its first turn and then replies with text. Nothing is sent to OpenAI: tracing is turned off and no API key is read. Run it twice: answer n, then y, and compare the state. """ import asyncio import sys from openai.types.responses import ( ResponseFunctionToolCall, ResponseOutputMessage, ResponseOutputText, ) from agents import set_tracing_disabled from agents.items import ModelResponse from agents.models.interface import Model from agents.usage import Usage import tool_agent set_tracing_disabled(True) class ScriptedModel(Model): def __init__(self): self.turn = 0 async def get_response(self, *args, **kwargs) -> ModelResponse: self.turn += 1 if self.turn == 1: out = [ResponseFunctionToolCall( type="function_call", call_id="call_1", name="close_ticket", arguments='{"ticket_id": 7}', id="fc_1", status="completed")] else: out = [ResponseOutputMessage( type="message", id="msg_1", role="assistant", status="completed", content=[ResponseOutputText(type="output_text", text="Done.", annotations=[])])] return ModelResponse(output=out, usage=Usage(), response_id=None) def stream_response(self, *args, **kwargs): raise NotImplementedError if __name__ == "__main__": answer = sys.argv[1] if len(sys.argv) > 1 else "n" agent = tool_agent.build_agent(model=ScriptedModel()) out = asyncio.run(tool_agent.run(agent, "Close ticket 7.", decide=lambda _i: answer)) print("final output:", out) print("ticket state:", tool_agent.TICKETS[7]["state"])