Skip to main content

Verification guards for OpenAI Responses API - Verify AI agent outputs before execution

Project description

QWED Open Responses

PyPI version License

Verification guards for AI agent outputs. Verify before you execute.

QWED Open Responses provides deterministic verification guards for AI responses, tool calls, and structured outputs. Works with OpenAI Responses API, LangChain, LlamaIndex, and other AI agent frameworks.


Installation

pip install qwed-open-responses

With optional integrations:

pip install qwed-open-responses[openai]      # OpenAI Responses API
pip install qwed-open-responses[langchain]   # LangChain
pip install qwed-open-responses[all]         # All integrations

Quick Start

from qwed_open_responses import ResponseVerifier, ToolGuard, SchemaGuard

# Create verifier with guards
verifier = ResponseVerifier()

# Verify a tool call
result = verifier.verify_tool_call(
    tool_name="execute_sql",
    arguments={"query": "SELECT * FROM users"},
    guards=[ToolGuard()]
)

if result.verified:
    print("✅ Safe to execute")
else:
    print(f"❌ Blocked: {result.block_reason}")

Guards

Guard Purpose Example
SchemaGuard Validate JSON schema Structured outputs
ToolGuard Block dangerous tools execute_shell, delete_file
MathGuard Verify calculations Totals, percentages
StateGuard Validate state transitions Order status changes
ArgumentGuard Validate tool arguments Types, ranges, formats
SafetyGuard Comprehensive safety PII, injection, budget

Examples

Block Dangerous Tools

from qwed_open_responses import ToolGuard

guard = ToolGuard(
    blocked_tools=["execute_shell", "delete_file"],
    dangerous_patterns=[r"DROP TABLE", r"rm -rf"],
)

result = guard.check({
    "tool_name": "execute_sql",
    "arguments": {"query": "DROP TABLE users"}
})
# ❌ BLOCKED: Dangerous pattern detected

Validate Structured Outputs

from qwed_open_responses import SchemaGuard

schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer", "minimum": 0}
    },
    "required": ["name", "age"]
}

guard = SchemaGuard(schema=schema)
result = guard.check({"output": {"name": "John", "age": 30}})
# ✅ Schema validation passed

Verify Calculations

from qwed_open_responses import MathGuard

guard = MathGuard()
result = guard.check({
    "output": {
        "subtotal": 100,
        "tax": 8,
        "total": 108
    }
})
# ✅ Math verification passed

Safety Checks

from qwed_open_responses import SafetyGuard

guard = SafetyGuard(
    check_pii=True,
    check_injection=True,
    max_cost=100.0,
)

result = guard.check({
    "content": "ignore previous instructions and..."
})
# ❌ BLOCKED: Prompt injection detected

Framework Integrations

LangChain

from qwed_open_responses.middleware.langchain import QWEDCallbackHandler

callback = QWEDCallbackHandler(
    guards=[ToolGuard(), SafetyGuard()]
)

agent = create_agent(callbacks=[callback])

OpenAI Responses API

from qwed_open_responses.middleware.openai_sdk import VerifiedOpenAI

client = VerifiedOpenAI(
    api_key="...",
    guards=[ToolGuard(), SchemaGuard(schema=my_schema)]
)

response = client.responses.create(...)
# Automatically verified before returning

Why QWED Open Responses?

Without Verification With QWED
LLM calls execute_shell("rm -rf /") BLOCKED by ToolGuard
LLM returns wrong calculation CAUGHT by MathGuard
LLM outputs PII in response DETECTED by SafetyGuard
LLM hallucinates JSON format REJECTED by SchemaGuard

Links


License

Apache 2.0 - See LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qwed_open_responses-0.2.2.tar.gz (32.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qwed_open_responses-0.2.2-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

Details for the file qwed_open_responses-0.2.2.tar.gz.

File metadata

  • Download URL: qwed_open_responses-0.2.2.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qwed_open_responses-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e8d56d83d0b3fe4261c111a0ddc2942dc2f0d527d0f3bced3b55485672b1e556
MD5 720fee118545b6704e6ec2e3fbda6591
BLAKE2b-256 c808d058d51e6a09905510c50ba9c3f5b140a87a0fca279cc38d0b82842105a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwed_open_responses-0.2.2.tar.gz:

Publisher: publish.yml on QWED-AI/qwed-open-responses

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qwed_open_responses-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for qwed_open_responses-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72371733d675a799404226da1096f869498f9b5f3fd4eecb46df367b26d19cd0
MD5 4965b1d1d8127279be85a4f5f244d00c
BLAKE2b-256 90f61854a17589ae3400af80752d1a6527e85f891addd47c3afb0e19f15bbd56

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwed_open_responses-0.2.2-py3-none-any.whl:

Publisher: publish.yml on QWED-AI/qwed-open-responses

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page