Skip to content

Conversation

rm-openai
Copy link
Collaborator

@rm-openai rm-openai commented Jun 24, 2025

Resolves #889

@seratch seratch added bug Something isn't working enhancement New feature or request feature:core labels Jun 25, 2025
Copy link
Contributor

github-actions bot commented Jul 6, 2025

This PR is stale because it has been open for 10 days with no activity.

Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Jul 13, 2025
@seratch seratch reopened this Aug 11, 2025
@seratch seratch added skip-stale and removed stale labels Aug 11, 2025
@seratch
Copy link
Member

seratch commented Aug 11, 2025

@rm-openai do you think this approach is still good to go? If not, we may want to think of a solution for #889 and #991

Copy link
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions bot added the stale label Aug 25, 2025
@lionelchg
Copy link

lionelchg commented Aug 29, 2025

Hi @seratch, just checked out on the PR and tried the following script (a shorter version of the quickstart script) - it still does not block the call.

  • this is the script:
from agents import Agent, InputGuardrail, GuardrailFunctionOutput, Runner
from agents.exceptions import InputGuardrailTripwireTriggered
from pydantic import BaseModel
import asyncio

class HomeworkOutput(BaseModel):
    is_homework: bool
    reasoning: str

guardrail_agent = Agent(
    name="Guardrail check",
    instructions="Check if the user is asking about homework.",
    output_type=HomeworkOutput,
)

math_tutor_agent = Agent(
    name="Math Tutor",
    handoff_description="Specialist agent for math questions",
    instructions="You provide help with math problems. Explain your reasoning at each step and include examples",
)

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,
    )

triage_agent = Agent(
    name="Triage Agent",
    instructions="You determine which agent to use based on the user's homework question",
    handoffs=[math_tutor_agent],
    input_guardrails=[
        InputGuardrail(guardrail_function=homework_guardrail),
    ],
)

async def main():
    # Example: General/philosophical question
    try:
        result = await Runner.run(triage_agent, "What is the meaning of life?")
        print(result.final_output)
    except InputGuardrailTripwireTriggered as e:
        print("Guardrail blocked this input:", e)

if __name__ == "__main__":
    asyncio.run(main())
  • this is my screenshot of the logs (you can see that the second call passes even though is_homework is False):
Screenshot 2025-08-30 at 01 01 04

I might try a fix this week-end will keep you posted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request feature:core skip-stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileSearchTool runs despite InputGuardrailTripwireTriggered
3 participants