Skip to content

Latest commit

 

History

History
91 lines (50 loc) · 6.21 KB

File metadata and controls

91 lines (50 loc) · 6.21 KB
graph LR
    src_agents_guardrail_InputGuardrail["src.agents.guardrail.InputGuardrail"]
    src_agents_guardrail_OutputGuardrail["src.agents.guardrail.OutputGuardrail"]
    src_agents_guardrail_decorator["src.agents.guardrail.decorator"]
    src_agents_run__run_input_guardrails["src.agents.run._run_input_guardrails"]
    src_agents_run__run_output_guardrails["src.agents.run._run_output_guardrails"]
    src_agents_realtime_session__run_output_guardrails["src.agents.realtime.session._run_output_guardrails"]
    src_agents_tracing_create_guardrail_span["src.agents.tracing.create.guardrail_span"]
    src_agents_guardrail_decorator -- "applies" --> src_agents_guardrail_InputGuardrail
    src_agents_guardrail_decorator -- "applies" --> src_agents_guardrail_OutputGuardrail
    src_agents_run__run_input_guardrails -- "invokes" --> src_agents__run_impl_run_single_input_guardrail
    src_agents_run__run_output_guardrails -- "invokes" --> src_agents__run_impl_run_single_output_guardrail
    src_agents__run_impl_run_single_input_guardrail -- "triggers" --> src_agents_tracing_create_guardrail_span
    src_agents__run_impl_run_single_output_guardrail -- "triggers" --> src_agents_tracing_create_guardrail_span
    src_agents_realtime_session__run_output_guardrails -- "manages" --> src_agents_guardrail_OutputGuardrail
Loading

CodeBoardingDemoContact

Details

The Guardrail subsystem in openai-agents-python is designed to enforce validation policies on agent inputs and outputs, ensuring adherence to predefined safety and compliance standards. It comprises core InputGuardrail and OutputGuardrail definitions, a decorator for declarative policy application, and orchestration components (_run_input_guardrails, _run_output_guardrails) that manage their execution. A specialized RealtimeAgentSession handles guardrails in real-time contexts, while guardrail_span provides crucial observability through tracing. This modular design allows for flexible and robust validation within the agent's lifecycle.

src.agents.guardrail.InputGuardrail

Defines the structure and rules for validating agent inputs. It encapsulates the policies that must be satisfied before an agent processes information. This is fundamental for an SDK to allow developers to specify input constraints.

Related Classes/Methods:

src.agents.guardrail.OutputGuardrail

Defines the structure and rules for validating agent outputs. It encapsulates the policies that must be satisfied after an agent generates a response. Essential for ensuring agent outputs adhere to safety and compliance standards.

Related Classes/Methods:

src.agents.guardrail.decorator

A higher-order function (decorator) that provides a declarative way for developers to attach InputGuardrail and OutputGuardrail policies to agent functions or methods. It acts as the primary interface for guardrail configuration, crucial for an extensible SDK.

Related Classes/Methods:

src.agents.run._run_input_guardrails

Orchestrates the execution of all configured input guardrails during the agent's standard execution flow. It ensures that pre-processing validation is systematically applied, acting as a key control point in the agent's pipeline.

Related Classes/Methods:

src.agents.run._run_output_guardrails

Orchestrates the execution of all configured output guardrails during the agent's standard execution flow, after an agent produces a response. It ensures post-processing validation, completing the enforcement cycle.

Related Classes/Methods:

src.agents.realtime.session._run_output_guardrails

Manages and applies output guardrails specifically within the context of a real-time agent session. It integrates with the real-time event system to process guardrail checks asynchronously, addressing specific requirements of real-time agent interactions.

Related Classes/Methods:

src.agents.tracing.create.guardrail_span

Creates and manages tracing spans for guardrail operations. This component is vital for observability in an SDK, enabling detailed monitoring, debugging, and performance analysis of guardrail execution within the overall agent trace.

Related Classes/Methods: