Back to Prompt Library
planning

OpenAI Agents SDK Setup for Sentiment Analysis

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

Linked challenge: Secure AI Policy Agent with OpenAI Agents SDK and Llama 4 Maverick

Format
Code-aware
Lines
3
Sections
1
Linked challenge
Secure AI Policy Agent with OpenAI Agents SDK and Llama 4 Maverick

Prompt source

Original prompt text with formatting preserved for inspection.

3 lines
1 sections
No variables
1 code block
Initialize an agent using the OpenAI Agents SDK that specializes in 'Sentiment Analysis'. This agent should be able to process textual input (e.g., social media posts, news headlines) and output a structured sentiment score and key themes. Provide the Python code for initializing this agent and defining its `run_task` method. ```python
from openai import OpenAI client = OpenAI() def run_sentiment_analysis_agent(public_sentiment_data: list[dict]): # Example agent assistant creation with tool calling enabled (if needed) # For simplicity, let's assume a direct LLM call here, or tool for external sentiment API response = client.chat.completions.create( model="llama-4-maverick", # Use actual Llama 4 Maverick deployment ID messages=[ {"role": "system", "content": "You are a sentiment analyst. Analyze the provided texts for sentiment regarding AI's impact on employment. Output a summary and key themes."}, {"role": "user", "content": f"Analyze: {public_sentiment_data}"} ] ) return response.choices[0].message.content # This function will be called by an orchestrating agent/workflow
```

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.