Skip to content

Inconsistent use of agent parameter vs guardrail_agent in quardrail function named homework_guardrail in Quickstart Tab of Documentation. #1253

@Zubair-Ahmad-Atd

Description

@Zubair-Ahmad-Atd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions