Skip to content

Commit 3dfa183

Browse files
fix(processor): retry 'model produced invalid content' and bump ResultGenerator max_tokens (Bug #43771)
Two-part fix for the Design step failure 'The model produced invalid content': 1. Add 'model produced invalid content' / 'invalid content' to the transient-error patterns recognised by _looks_like_rate_limit so that AzureOpenAIResponseClientWithRetry retries instead of failing. 2. Increase the ResultGenerator agent's max_tokens from 12_000 to 25_000 in OrchestratorBase to prevent truncation of large nested JSON schemas (the underlying cause of the 'invalid content' error). ADO #43771 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 70bdb85 commit 3dfa183

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/processor/src/libs/agent_framework/azure_openai_response_retry.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ def _looks_like_rate_limit(error: BaseException) -> bool:
7878
if isinstance(status, int) and 500 <= status < 600:
7979
return True
8080

81+
# "The model produced invalid content" is a transient error from Azure OpenAI
82+
# when the model output fails content/schema validation — worth retrying.
83+
if any(
84+
s in msg
85+
for s in ["model produced invalid content", "invalid content"]
86+
):
87+
return True
88+
8189
cause = getattr(error, "__cause__", None)
8290
if cause and cause is not error:
8391
return _looks_like_rate_limit(cause)

src/processor/src/libs/base/orchestrator_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,12 @@ async def create_agents(
188188
)
189189
elif agent_info.agent_name == "ResultGenerator":
190190
# Structured JSON generation; deterministic and bounded.
191+
# Use 25_000 to prevent truncation of complex nested JSON schemas
192+
# which causes "model produced invalid content" errors.
191193
builder = (
192194
builder
193195
.with_temperature(0.0)
194-
.with_max_tokens(12_000)
196+
.with_max_tokens(25_000)
195197
.with_tool_choice("none")
196198
)
197199

0 commit comments

Comments
 (0)