Back to Prompt Library
planning

Agent Setup and Tool Definition

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: AI Policy Audit Agent with OpenAI Agents

Format
Code-aware
Lines
60
Sections
9
Linked challenge
AI Policy Audit Agent with OpenAI Agents

Prompt source

Original prompt text with formatting preserved for inspection.

60 lines
9 sections
No variables
1 code block
Initialize your OpenAI Agent using `OpenAI Agents SDK`. Define a tool named `policy_retriever` that can query the Supabase vector database for relevant policy documents based on a search query. Also, define a tool named `mem0_saver` to persist critical audit findings or contextual information to Mem0 for long-term memory. Your agent should be configured to use `GPT-4o` as its underlying model.

```python
from openai import OpenAI
import os

# Assume Supabase client and Mem0 client are initialized elsewhere
# from supabase_client import get_policy_documents
# from mem0_client import save_to_mem0

client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))

def policy_retriever(query: str):
    # This function would interact with your Supabase Vector DB
    print(f"Searching Supabase for policies related to: {query}")
    # Example: return get_policy_documents(query)
    return ["Policy A: Data retention policies.", "Policy B: Consent guidelines."]

def mem0_saver(key: str, value: str):
    # This function would save information to Mem0
    print(f"Saving to Mem0: {key} = {value}")
    # Example: save_to_mem0(key, value)
    return {"status": "success"}

# Tool definitions for OpenAI Agents SDK
tools = [
    {
        "type": "function",
        "function": {
            "name": "policy_retriever",
            "description": "Retrieves relevant policy documents from a vector database based on a search query.",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {"type": "string", "description": "The search query for policy documents."}
                },
                "required": ["query"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "mem0_saver",
            "description": "Persists key-value information into long-term memory via Mem0.",
            "parameters": {
                "type": "object",
                "properties": {
                    "key": {"type": "string", "description": "The key for the information to save."}, 
                    "value": {"type": "string", "description": "The value (content) to save."
                    }
                },
                "required": ["key", "value"]
            }
        }
    }
]

# Initialize the Assistant
assistant = client.beta.assistants.create(
    name="AI Policy Auditor",
    instructions="You are an expert AI policy auditor. Your task is to analyze documents for compliance with ethical guidelines and regulations. Use the provided tools to retrieve relevant policies and save your findings.",
    model="gpt-4o", # Or a specific model like 'gpt-4o'
    tools=tools
)

print(f"Assistant created with ID: {assistant.id}")
```

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Preserve the role framing, objective, and reporting structure so comparison runs stay coherent.

Tune next

Swap in your own domain constraints, anomaly thresholds, and examples before you branch variants.

Verify after

Check whether the prompt asks for the right evidence, confidence signal, and escalation path.