Azure / Azure/azure-sdk-for-python

agent_framework_input_converters rejects nested message format from official documentation

Aperta
#44,994 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
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.0b10
- **Operating System**: Windows
- **Python Version**: 3.12.10

**Describe the bug**
The `agent_framework_input_converters.py` module rejects the nested message format (`{"messages": [...]}`) shown in the official Microsoft documentation, causing a TypeError when using the documented payload structure for local testing.

Error:
> TypeError: Unsupported input type:

Traceback:
> Traceback (most recent call last):
> File "C:\Users\\OneDrive\Documents\VSCode Hosted Agent Test2\hostedagenttest\.venv\Lib\site-packages\azure\ai\agentserver\agentframework\models\agent_framework_input_converters.py", line 137, in _transform_input_internal
> raise TypeError(f"Unsupported input type: {type(input)}")
> TypeError: Unsupported input type:

**To Reproduce**
Steps to reproduce the behavior:

1. Create a hosted agent using Agent Framework following [the official documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?view=foundry):

2. Run the agent locally:
```python
from azure.ai.agentserver.agentframework import from_agent_framework

if __name__ == "__main__":
from_agent_framework(agent).run() # localhost:8088
```
3. Send a POST request using the documented payload format:
```bash
curl -X POST http://localhost:8088/responses \
-H "Content-Type: application/json" \
-d '{
"input": {
"messages": [
{
"role": "user",
"content": "Where is Seattle?"
}
]
}
}'
```
4. Result:
> {"code":"server_error","message":"Error processing messages: Unsupported input type: "}

**Expected behavior**
The converter should accept the nested format shown in [the official documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?view=foundry#wrap-your-agent-code-with-the-hosting-adapter-and-test-locally):
```
POST {{baseUrl}}/responses
Content-Type: application/json

{
"input": {
"messages": [
{
"role": "user",
"content": "Where is Seattle?"
}
]
}
}
```
**Screenshots**
N/A

**Additional context**

Current workaround:
The only working format is flattened (removing the messages wrapper):
```JSON
{
"input": [
{
"role": "user",
"content": "Where is Seattle?"
}
]
}
```

Root cause:
In `agent_framework_input_converters.py` (line 63-66), the type hint only accepts `str | List[Dict] | None:`
```Python
def _transform_input_internal(
self,
input: str | List[Dict] | None,
) -> str | ChatMessage | list[str] | list[ChatMessage] | None:
```
Line 137 explicitly rejects dict type:
```Python
raise TypeError(f"Unsupported input type: {type(input)}")
```

Impact:
- Documentation/implementation mismatch causes confusion for developers
- Local testing requires a different payload format than what is documented
- Unclear whether production deployment behavior differs from local testing

Questions:
- Is this intentional behavior? If so, why does the official documentation show a different format?
- Should the documentation be updated to reflect the flattened format, or should the implementation support the nested format?
- Does the production Foundry Responses API (when deployed to Azure) accept the nested format, or does it also require the flattened format?

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da agent_framework_input_converters.py, in particolare dall’annotazione del tipo di _transform_input_internal intorno alle righe 63-66 e dal rifiuto alla riga 137. Confronta il payload annidato documentato con il payload appiattito funzionante e determina il contratto di input previsto; il lavoro è completato quando implementazione e documentazione concordano e la richiesta locale documentata non produce più il TypeError segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.