litellm/tests/test_litellm/llms
michelligabriele c47f77a348
fix(agentcore): handle JSON responses from agents using sync return (#23165)
* fix(agentcore): handle JSON responses from agents using sync return

BedrockAgentCoreApp agents that use synchronous `return` (instead of
async `yield`) respond with Content-Type: application/json instead of
text/event-stream. The streaming parser only handles SSE format, silently
discarding the JSON body and returning empty content to the client.

This adds Content-Type detection in both sync and async streaming
wrappers — when application/json is received, the response is parsed
and converted to a single-chunk stream. Also extends _parse_json_response
with a fallback chain supporting multiple agent response schemas (standard
AgentCore, Strands framework, plain string, raw JSON fallback).

* fix(agentcore): add dict-type guard to _parse_json_response

Prevent AttributeError when json.loads() returns a non-dict
(e.g. JSON array or primitive) by adding an isinstance check
at the top of _parse_json_response. Non-dict values fall back
to raw JSON string content.

* fix(agentcore): handle malformed JSON and split streaming chunks

- Wrap json.loads() in try/except in both sync and async streaming
  wrappers so malformed JSON bodies raise a structured BedrockError
  instead of a raw JSONDecodeError
- Split the JSON-fallback streaming path into two chunks (content
  chunk with finish_reason=None, then stop sentinel with empty delta)
  to match the SSE path convention

* fix(agentcore): catch IO errors in streaming JSON path + async error test

- Broaden except clause to catch both json.JSONDecodeError and IO-level
  exceptions (httpx.ReadError, etc.) from response.read()/aread(), so
  all failures surface as structured BedrockError
- Add async malformed-JSON test to mirror the sync test coverage
2026-03-09 10:22:36 -07:00
..
amazon_nova/chat
anthropic fix(proxy): do not forward Authorization header to LLM provider when used for LiteLLM proxy auth 2026-03-06 18:20:48 +05:30
azure Exclude aresponses_websocket from Azure SDK client init test 2026-03-04 11:13:57 -03:00
azure_ai feat(azure_ai): add router flat cost when response contains actual model 2026-03-06 18:18:06 +05:30
baseten/chat
bedrock fix(agentcore): handle JSON responses from agents using sync return (#23165) 2026-03-09 10:22:36 -07:00
bedrock_mantle feat(provider): add Amazon Bedrock Mantle as a first-class provider 2026-03-05 00:03:40 -05:00
bytez/chat
chat test(bedrock): add unit tests for region extraction from bedrock/{region}/{model} path 2026-03-02 11:06:27 +05:30
chatgpt test(chatgpt): restore gpt-5.2 codex transformation coverage 2026-03-05 17:00:49 -05:00
cohere
cometapi/chat
compactifai
custom_httpx [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
dashscope fix: remove list-to-str transformation from dashscope 2026-02-19 07:30:13 +00:00
databricks Address Greptile review: fix SDK auth fallback and remove unused imports 2026-02-18 15:57:50 +09:00
datarobot
deepgram
deepinfra
docker_model_runner
featherless_ai/chat fix(tests): use monkeypatch for env var isolation in featherless tests 2026-03-01 23:46:15 +01:00
fireworks_ai
gemini
github_copilot
heroku
hosted_vllm CircleCI test stability (#23055) 2026-03-07 15:19:39 -08:00
huggingface fix: improve test isolation for parallel execution 2026-02-17 21:28:23 -03:00
jina_ai/embedding
lemonade
litellm_proxy/chat
llamafile/chat
lm_studio
manus
meta_llama fix: add missing OpenAI chat completion params to OPENAI_CHAT_COMPLETION_PARAMS (#21360) 2026-02-16 20:31:21 -08:00
minimax
mistral
moonshot fix(moonshot): preserve image_url blocks in multimodal messages 2026-02-19 16:44:38 -03:00
nebius
novita/chat
nscale/chat
oci/chat
ocr Add OCR guardrail_translation handler and support (#22145) 2026-02-28 17:39:36 -08:00
ollama fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
openai feat(openai): drop reasoning_effort for gpt-5.4 when tools present 2026-03-06 22:20:47 +05:30
openai_like fix(proxy): fix master key rotation Prisma validation errors (#21330) 2026-02-16 15:13:05 -08:00
openrouter CircleCI test stability (#23055) 2026-03-07 15:19:39 -08:00
ovhcloud
perplexity feat(perplexity): add embedding support for pplx-embed-v1 models (#22610) 2026-03-02 17:37:50 -08:00
pg_vector/vector_stores
publicai fix: add missing OpenAI chat completion params to OPENAI_CHAT_COMPLETION_PARAMS (#21360) 2026-02-16 20:31:21 -08:00
ragflow/chat
recraft
runwayml
s3_vectors
sagemaker
sambanova
sap fix(sap provider layer): enable response-format for anthropic models and improve compatibility for GPT models via LangChain (#22804) 2026-03-04 16:03:59 -08:00
snowflake
stability
vercel_ai_gateway
vertex_ai revert: undo PR #22589 and follow-up vertex anyOf fixes (#23083) 2026-03-07 17:49:49 -08:00
volcengine
voyage/rerank
wandb
watsonx [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
xai
zai
test_cache_control_and_reasoning.py
test_lifecycle_fix.py
test_oom_fixes.py