Skip to content

Conversation

@IdkwhatImD0ing
Copy link
Contributor

This pull request adds support for input and output guardrails to the agent workflows and OpenAI provider interfaces, enabling validation and control over agent inputs and outputs. It introduces a sample "spaghetti" input guardrail in the tutorial workflow and updates both function signatures and agent instantiation logic to accept and pass guardrail objects throughout the stack.

Guardrail Integration

  • Added InputGuardrail and OutputGuardrail parameters to all OpenAI provider agent run methods (run_agent, run_agent_auto_send, run_agent_streamed, run_agent_streamed_auto_send) in src/agentex/lib/adk/providers/_modules/openai.py and src/agentex/lib/core/services/adk/providers/openai.py, including updates to docstrings and argument passing. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Updated agent instantiation logic to correctly forward guardrail objects to the Agent constructor if provided. [1] [2] [3]

Tutorial Workflow Enhancements

  • Added a sample input guardrail function check_spaghetti_guardrail and a corresponding TemporalInputGuardrail instance (SPAGHETTI_GUARDRAIL) to the tutorial agent chat workflow, demonstrating how to block or flag user inputs containing the word "spaghetti".
  • Updated the agent workflow's event send logic to include the new input guardrail in the call to run_agent_streamed_auto_send, ensuring the guardrail is enforced during agent interaction.

Code Quality and Documentation

  • Improved code comments and docstrings to clarify the purpose and usage of guardrail parameters and agent workflow logic. [1] [2] [3] [4] [5] [6]

These changes collectively make it possible to add custom validation logic at both input and output stages of agent workflows, improving safety and reliability.

@smoreinis
Copy link
Contributor

Also, not sure if I'm missing something but it looks like run_agent and run_agent_auto_send in src/agentex/lib/adk/providers/_modules/openai.py still doesn't have input or output guardrails. I believe the plan (from the PR description) is to add these as well to plumb them through to src/agentex/lib/core/services/adk/providers/openai.py, right?

@IdkwhatImD0ing IdkwhatImD0ing merged commit 38f882b into main Sep 2, 2025
6 of 8 checks passed
@IdkwhatImD0ing IdkwhatImD0ing deleted the bill/guardrails branch September 2, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants