diff --git a/harnessed_agent/llm_client.py b/harnessed_agent/llm_client.py index 79d7393..f349029 100644 --- a/harnessed_agent/llm_client.py +++ b/harnessed_agent/llm_client.py @@ -229,6 +229,19 @@ async def _post_chat_completions( } } + # Check content type before parsing JSON + content_type = resp.content_type + if 'json' not in content_type: + err_text = await resp.text() + return { + 'error': { + 'message': f'LLM API returned non-JSON response (Content-Type: {content_type}). URL may be incorrect or blocked.', + 'type': 'content_type_error', + 'code': resp.status, + 'detail': err_text[:500], + } + } + return await resp.json() except asyncio.TimeoutError: