Azure / Azure/azure-sdk-for-python

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

Aperta
#46,439 2 commenti 0 reazioni 2 assegnatari Rivendicata da @lusu-msft Vedi su GitHub
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g
PR unite (30g)
217

Descrizione

- **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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.