Skip to main content
Loading navigation
Back to prompt library

OpenAI Agents SDK Setup

Linked challenge: OpenAI Agents SDK Consumer Inflation Analysis Agent

Prompt source

implementation10 lines4 sectionsNo variables0 checklist items
from agents import Agent, Runner, function_tool

@function_tool
def calculate_cpi_yoy(current: float, prev_year: float) -> float:
    return round(((current - prev_year) / prev_year) * 100, 2)

agent = Agent(
    name='MAS Inflation Analyst',
    instructions='You analyze Singapore CPI data and compute core inflation.',
    tools=[calculate_cpi_yoy]
)

# Run agent loop code below