Skip to content

fix(processor): Design step 'model produced invalid content' — retry + max_tokens (ADO #43771)#245

Open
Shreyas-Microsoft wants to merge 1 commit into
devfrom
psl-sw/43771-workbook-and-design-fix
Open

fix(processor): Design step 'model produced invalid content' — retry + max_tokens (ADO #43771)#245
Shreyas-Microsoft wants to merge 1 commit into
devfrom
psl-sw/43771-workbook-and-design-fix

Conversation

@Shreyas-Microsoft
Copy link
Copy Markdown
Collaborator

@Shreyas-Microsoft Shreyas-Microsoft commented May 18, 2026

Purpose

Surgical fix for ADO #43771 — [Demo] [Container-Migration] - Design step fails with "The model produced invalid content".

The fix is 2 production files, 11 net lines.

Root cause

The Design step's ResultGenerator agent produces a complex nested JSON schema (Design_ExtendedBooleanResult). The previous max_tokens=12_000 cap was truncating that output mid-stream, which causes Azure OpenAI's own response-validation to reject it with the message "The model produced invalid content". The orchestrator's retry decorator wasn't recognising that error as transient, so the Design step failed outright.

Change

File Change
src/processor/src/libs/agent_framework/azure_openai_response_retry.py _looks_like_rate_limit() now also returns True for messages containing "model produced invalid content" / "invalid content". This causes AzureOpenAIResponseClientWithRetry._inner_get_response() (and its streaming variant) to retry on this transient AOAI response-validation failure instead of bubbling it up. Up to 8 retries with exponential backoff + jitter (configurable via AOAI_429_* env vars).
src/processor/src/libs/base/orchestrator_base.py ResultGenerator agent's max_tokens bumped from 12_00025_000 to give the nested-JSON serialiser headroom and prevent the truncation that triggers the error in the first place.

Verification

  • Live REPL against the new predicate:
    • _looks_like_rate_limit("The model produced invalid content")True
    • _looks_like_rate_limit("Invalid content was returned")True
    • _looks_like_rate_limit("429 Too Many Requests")True (unchanged) ✅
    • _looks_like_rate_limit("Some random error")False (no over-retry) ✅
  • ResultGenerator flows through orchestrator_base.py:189 for the Design step (src/processor/src/steps/design/orchestration/design_orchestrator.py:233), so the max_tokens bump applies exactly where the failure occurs.
  • Backend unit tests: 585 passed, 93.28% coverage (gate 82%).
  • Processor unit tests: 812 passed, 87.43% coverage (gate 82%).

Commit

  • edf076b — fix(processor): retry 'model produced invalid content' and bump ResultGenerator max_tokens (Bug #43771)

Does this introduce a breaking change?

  • Yes
  • No (the retry predicate gains an extra transient-error case but never loses one; the max_tokens bump is a per-agent ceiling increase only)

Golden Path Validation

  • Backend tests: 585 passed, 93.28% coverage (gate 82%)
  • Processor tests: 812 passed, 87.43% coverage (gate 82%)

Deployment Validation

  • Not applicable — code-only change to the processor. No infrastructure or deployment changes.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

…tGenerator 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>
Copilot AI review requested due to automatic review settings May 18, 2026 13:47
@Shreyas-Microsoft Shreyas-Microsoft force-pushed the psl-sw/43771-workbook-and-design-fix branch from 765bb4e to edf076b Compare May 18, 2026 13:53
@Shreyas-Microsoft Shreyas-Microsoft changed the title fix(processor)+feat(infra): Design step 'invalid content' retry + bundled App Insights workbook (ADO #43771) fix(processor): Design step 'model produced invalid content' — retry + max_tokens (ADO #43771) May 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
TOTAL309720893% 
report-only-changed-files is enabled. No files were changed during this commit :)

Tests Skipped Failures Errors Time
588 0 💤 0 ❌ 0 🔥 22.990s ⏱️

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

Coverage

Processor Coverage Report •
FileStmtsMissCoverMissing
src/processor/src/libs/agent_framework
   azure_openai_response_retry.py36313263%87, 197, 205, 227, 253, 263–265, 389, 396–399, 401–403, 409–411, 428, 449–450, 455–458, 461–464, 466–469, 471, 481–483, 485–488, 490–493, 495–499, 501, 509–511, 513, 529–531, 536, 540–543, 547, 550, 558–559, 565–566, 571, 573, 594, 600–602, 606–607, 618, 620–623, 627, 630, 638–639, 645–647, 649–652, 654–665, 668, 675–676, 701–702, 709–710, 712, 716, 719–720, 724–725, 727–729, 737, 739–741, 743–745, 747–748, 758
src/processor/src/libs/base
   orchestrator_base.py1654970%62, 68, 71–74, 80–81, 83–84, 127, 138, 143, 148–149, 153, 161, 163, 165, 172–173, 180, 182, 189, 193, 202, 206, 211, 213–214, 216, 315–317, 320, 326, 333–335, 362–364, 367, 374, 381–383, 434–435
TOTAL572772087% 

Tests Skipped Failures Errors Time
812 0 💤 0 ❌ 0 🔥 19.944s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant