Azure / Azure/azure-sdk-for-python

Hosted agent on foundry: Unable to send response to the paused conversation

Open
#46,439 2 comments 0 reactions 2 assignees Claimed by @lusu-msft View on GitHub
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

- **Package Name**: azure-ai-agentserver-agentframework
- **Package Version**: 1.0.0b17
- **Operating System**: Foundry
- **Python Version**: Foundry

**Describe the bug**
I have a hosted agent on Foundry that implements a multi-agent workflow. As part of the workflow, there is a step that requires human input, during which the flow pauses and waits for a response.

I’m able to test this successfully in the foundry playground, where I can provide the required input after the pause and the workflow resumes as expected.

However, I’m facing an issue when trying to do this programmatically. When I send the response after the flow pauses, it is treated as a new input, and a new conversation is started, instead of resuming the existing workflow.

Below is my client code.

`from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

PROJECT_ENDPOINT = "https://xxx.services.ai.azure.com/api/projects/xxx-aifoundry"
AGENT_NAME = "agent-with-mcp"
AGENT_VERSION = "35"

def main():
client = AIProjectClient(
endpoint=PROJECT_ENDPOINT,
credential=DefaultAzureCredential(),
)

openai_client = client.get_openai_client()

# 1. Trigger the flow
print("🚀 Starting agent flow...")

start_response = openai_client.responses.create(
input=[
{
"role": "user",
"content": "Investigate HRMS production outage and remediate."
}
],
extra_body={
"agent_reference": {
"name": AGENT_NAME,
"version": AGENT_VERSION,
"type": "agent_reference"
}
}
)

print("Response ID:", start_response.id)
print(start_response.output_text)

# 2. Detect HITL pause (FIXED)
paused = any(
getattr(item, "type", None) in ("mcp_approval_request", "tool_call")
for item in start_response.output
)

if not paused:
print("✅ Flow completed without approval.")
return

print("⏸️ Flow paused for approval.")

# 3. Send approval
approval_response = openai_client.responses.create(
previous_response_id=start_response.id,
input=[
{
"role": "user",
"content": "APPROVED"
}
],
extra_body={
"agent_reference": {
"name": AGENT_NAME,
"version": AGENT_VERSION,
"type": "agent_reference"
}
}
)

print("✅ Flow resumed and completed.")
print(approval_response.output_text)

if __name__ == "__main__":
main()`

**To Reproduce**
Steps to reproduce the behavior:
1. Create a multi-agent workflow with HITL and host it on Microsoft foundry
2. Trigger the agent from external system
3. Agent pauses for human input
4. Send back the human response from external system

**Expected behavior**
Should be able to send the response back to the same conversation from external system

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.