From the documentation:
as the simplest check I wrote this code
from agents import function_tool
decorator = function_tool(name_override="Custom function")
print(decorator)
decorator2 = function_tool(needs_approval=True)
First decorator is created, but for the second it returns
decorator2 = function_tool(needs_approval=True)
TypeError: function_tool() got an unexpected keyword argument 'needs_approval'
In the agentsSDK code I can't see this attribute in none of the overloads
When LLM is asked to perform this it suggest something as such
@function_tool
def delete_user(user_id: str) -> str:
"""Delete a user by ID."""
# Real deletion logic would live here
return f"Deleted user {user_id}"
# Mark the tool as approval-gated
delete_user.needs_approval = True
agent = Agent(
name="AdminAssistant",
instructions="Help with admin tasks. Use tools when needed.",
tools=[delete_user],
model=model,
)
async def run_with_optional_approval(prompt: str):
# First run
result = Runner.run_streamed(agent, prompt)
async for _event in result.stream_events():
pass
# Handle approval if needed
if not result.interruptions:
return result
approval_item = result.interruptions[0]
print("Agent requested a sensitive tool call that needs approval.")
decision = input("Approve? (y/n): ").strip().lower()
state = result.to_state()
if decision == "y":
state.approve(approval_item)
else:
state.reject(approval_item)
# Resume execution from the updated state
resumed = Runner.run_streamed(agent, state)
async for _event in resumed.stream_events():
pass
return resumed
Which fails with
AttributeError: 'RunResultStreaming' object has no attribute 'interruptions'
Debug information
- Agents SDK version: (e.g.
v0.7.0). But tested it back for 0.6.0, 0.5.0 and 0.4.0
- Python version (e.g. Python 3.13)
Expected behavior
Please either fix the bug and clarify things in the documentation or provide instructions on HITL
From the documentation:
needs_approvalattribute listedas the simplest check I wrote this code
First decorator is created, but for the second it returns
In the agentsSDK code I can't see this attribute in none of the overloads
When LLM is asked to perform this it suggest something as such
Which fails with
Debug information
v0.7.0). But tested it back for 0.6.0, 0.5.0 and 0.4.0Expected behavior
Please either fix the bug and clarify things in the documentation or provide instructions on HITL