{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreicy76euxslsff4gzxr6ds3ffsystwexlzguqmkxhsdzy3odnjsqpu",
    "uri": "at://did:plc:lk3jfj3zq4k4wxnk474axylu/app.bsky.feed.post/3moojm6fvg272"
  },
  "path": "/t/why-agents-sdk-needs-a-before-tool-call-hook/1384160#post_3",
  "publishedAt": "2026-06-19T22:44:30.000Z",
  "site": "https://community.openai.com",
  "tags": [
    "@input_guardrail"
  ],
  "textContent": "Agree completely — the model shouldn’t own budget enforcement, that’s the core issue with the tool-based approach I showed.\n\nThe guardrail path is cleaner. Something like:\n\n\n    from agents import Agent, Runner, input_guardrail, GuardrailFunctionOutput\n\n\n`@input_guardrail`\n\n`async def spend_guard(ctx, agent, input):`\n\n` approved = check_budget(estimated_cost=0.05) # your policy check`\n\n` return GuardrailFunctionOutput(`\n\n` output_info={\"approved\": approved},`\n\n` tripwire_triggered=not approved,`\n\n` )`\n\n`agent = Agent(`\n\n` name=\"Research Agent\",`\n\n` input_guardrails=[spend_guard],`\n\n` tools=[...],`\n\n`)`\n\nThe hard outer limit is the right safety net — but guardrails give you per-call granularity before the runner even sees it.\n\nIs there a way to pass per-tool cost estimates into guardrails yet, or does it only have access to the full input at that point?",
  "title": "Why Agents SDK needs a before tool call hook"
}