Praison AI
Enterprise
Agents
Bot
Use Cases
University
Docs
Middleware that validates or blocks risky tool calls
Run
from praisonai import Agent, HooksConfig blocked = [] def issue_refund(order_id: str, amount_usd: float) -> str: """Issue a refund up to the $100 autonomous cap.""" if amount_usd > 100: blocked.append((order_id, amount_usd)) return f'DENIED: ${amount_usd} exceeds $100 cap — escalate to finance.' return f'Refunded ${amount_usd} for {order_id}.' def log_call(event): print('HOOK SAW:', event.tool_name, event.arguments) agent = Agent( name='RefundBot', instructions='Always call issue_refund and relay the exact tool verdict.', tools=[issue_refund], hooks=HooksConfig(on_tool_call=log_call), output='silent', ) print('Reply :', agent.start('Refund $250 for order ORD-7')) print('Blocked:', blocked)
Press Run. The result appears here.
Esc
Search in
All
Docs
University