Address comments

This commit is contained in:
Tao Chen
2026-05-06 11:34:03 -07:00
Unverified
parent 066e1a291d
commit 3595000cd0
2 changed files with 12 additions and 14 deletions
@@ -1460,25 +1460,23 @@ async def _to_outputs(
elif content.type == "function_approval_request":
function_call: Content = content.function_call # type: ignore
server_label = function_call.additional_properties.get("server_label", "agent_framework")
approval_request_id: str | None = None
request_saved = False
async for event in stream.aoutput_item_mcp_approval_request(
server_label,
function_call.name, # type: ignore
_arguments_to_str(function_call.arguments),
):
if approval_storage is not None and not request_saved:
# Extract the approval request ID generated by the infrastructure
# when the approval request item is added to the stream. Save the
# approval request to the approval storage so it can be retrieved later
# for round trips where the original approval request needs to be looked up.
item = getattr(event, "item", None)
if item is not None and getattr(item, "id", None) is not None:
approval_request_id = cast(str, item.id) # type: ignore
await approval_storage.save_approval_request(approval_request_id, content)
request_saved = True
yield event
# Extract the approval request ID generated by the infrastructure
# when the approval request item is added to the stream
if (
getattr(event, "item", None) is not None
and getattr(event.item, "id", None) is not None # type: ignore
and approval_request_id is None
):
approval_request_id = cast(str, event.item.id) # type: ignore
# Save the approval request to the approval storage so it can be retrieved later
# for round trips where the original approval request needs to be looked up
if approval_request_id is not None and approval_storage is not None:
await approval_storage.save_approval_request(approval_request_id, content)
else:
# Log a warning for unsupported content types instead of raising an error to avoid breaking the response stream.
logger.warning(f"Content type '{content.type}' is not supported yet. This is usually safe to ignore.")
@@ -156,7 +156,7 @@ cd agent-framework/python/samples/04-hosting/foundry-hosted-agents/responses
2. Install dependencies:
```bash
pip install -r requirements.txt
uv pip install -r requirements.txt
```
3. Create a `.env` file with your Foundry configuration following the `env.example` file in the sample.