Azure / Azure/azure-sdk-for-python
[azure-ai-agents] create_agent returns empty body -> JSONDecodeError
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 193
Description
- **Package Name**: azure-ai-projects
- **Package Version**:
- **Operating System**:
- **Python Version**: 3.13
**Describe the bug**
I try to create an agent using a command
agent = project_client.agents.create_agent(
model=model_deployment_name,
name=random_agent_name,
instructions="", #system_prompt,
#tools=tools,
#tool_resources=tool_resources,
)
The response code is 200 but the response body is empty. That results in an error
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```
File "C:\python_env\workspace\dashboard_ai\src\main.py", line 360, in _create_agent
agent = project_client.agents.create_agent(
model=model_deployment_name,
...<3 lines>...
#tool_resources=tool_resources,
)
File "C:\python_env\App\WinPython\python\Lib\site-packages\azure\core\tracing\decorator.py", line 119, in wrapper_use_tracer
return func(*args, **kwargs)
File "C:\python_env\App\WinPython\python\Lib\site-packages\azure\ai\agents\_patch.py", line 322, in create_agent
new_agent = super().create_agent(
model=model,
...<9 lines>...
**kwargs,
)
File "C:\python_env\App\WinPython\python\Lib\site-packages\azure\core\tracing\decorator.py", line 119, in wrapper_use_tracer
return func(*args, **kwargs)
File "C:\python_env\App\WinPython\python\Lib\site-packages\azure\ai\agents\operations\_operations.py", line 5326, in create_agent
deserialized = _deserialize(_models.Agent, response.json())
~~~~~~~~~~~~~^^
File "C:\python_env\App\WinPython\python\Lib\site-packages\azure\core\rest\_http_response_impl.py", line 331, in json
self._json = loads(self.text())
~~~~~^^^^^^^^^^^^^
File "C:\python_env\App\WinPython\python\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "C:\python_env\App\WinPython\python\Lib\json\decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python_env\App\WinPython\python\Lib\json\decoder.py", line 363, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```
**To Reproduce**
Steps to reproduce the behavior:
Create project client and then try to create an agent.
credential = ClientSecretCredential(
tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret,
)
project_client = AIProjectClient(endpoint=api_endpoint, credential=credential)
agent = project_client.agents.create_agent(
model=model_deployment_name,
name=random_agent_name,
instructions="",
)
**Expected behavior**
Check for empty response body and give a meaningful error message, for example:
"The response body is empty. Lack of proper RBAC can sometimes surface as odd 200 responses with empty body in preview services.
Ensure service principal has “Azure AI Developer” or “Cognitive Services Contributor” on the AI Services account."
or
"The model 'gpt-5-codex' is not supported".
Contributor guide
Assessment
This issue has not been assessed yet.