Summary
In writing a guardrail function using the Runner.run(...) method, I noticed that the agent parameter is passed to the function but not used. Instead, a guardrail_agent is being used, which can cause confusion and bugs. Moreover, the guardrail function named homework_guardrail is being called from triage_agent.
Code snippet:
async def homework_guardrail(ctx, agent, input_data):
result = await Runner.run(guardrail_agent, input_data, context=ctx.context)
final_output = result.final_output_as(HomeworkOutput)
return GuardrailFunctionOutput(
output_info=final_output,
tripwire_triggered=not final_output.is_homework,
)
### Suggested Fix
Change this line: result = await Runner.run(guardrail_agent, input_data, context=ctx.context)
To : result = await Runner.run(agent, input_data, context=ctx.context)
### Expected behavior
I expect that the passed agent should be used instead of guardrail_agent.