Python: Replaced obsolete create_response method in samples (#3542)

* Replaced obsolete create_response method in samples

* Addressed PR comments
This commit is contained in:
Dmytro Struk
2026-01-30 14:22:00 -08:00
committed by GitHub
Unverified
parent f3e0be9555
commit 493891620d
12 changed files with 46 additions and 48 deletions
@@ -66,7 +66,7 @@ async def handle_approvals(query: str, agent: "AgentProtocol") -> AgentResponse:
# Add the user's approval response
new_inputs.append(
ChatMessage(role="user", contents=[user_input_needed.create_response(user_approval.lower() == "y")])
ChatMessage(role="user", contents=[user_input_needed.to_function_approval_response(user_approval.lower() == "y")])
)
# Run again with all the context
@@ -116,7 +116,7 @@ async def handle_approvals_streaming(query: str, agent: "AgentProtocol") -> None
# Add the user's approval response
new_inputs.append(
ChatMessage(role="user", contents=[user_input_needed.create_response(user_approval.lower() == "y")])
ChatMessage(role="user", contents=[user_input_needed.to_function_approval_response(user_approval.lower() == "y")])
)
# Update input with all the context for next iteration
@@ -54,7 +54,7 @@ async def approval_example() -> None:
print(f" Decision: {'Approved' if approved else 'Rejected'}")
# Step 2: Send approval response
approval_response = request.create_response(approved=approved)
approval_response = request.to_function_approval_response(approved=approved)
result = await agent.run(ChatMessage(role="user", contents=[approval_response]), thread=thread)
print(f"Agent: {result}\n")
@@ -87,7 +87,7 @@ async def rejection_example() -> None:
print(" Decision: Rejected")
# Send rejection response
rejection_response = request.create_response(approved=False)
rejection_response = request.to_function_approval_response(approved=False)
result = await agent.run(ChatMessage(role="user", contents=[rejection_response]), thread=thread)
print(f"Agent: {result}\n")