fix(agent): retry on json.JSONDecodeError instead of treating it as a local validation error#15107
Merged
Merged
Conversation
… local validation error
json.JSONDecodeError inherits from ValueError. The agent loop's
non-retryable classifier at run_agent.py ~L10782 treated any
ValueError/TypeError as a local programming bug and short-circuited
retry. Without a carve-out, a transient JSONDecodeError from a
provider that returned a malformed response body, a truncated stream,
or a router-layer corruption would fail the turn immediately.
Add JSONDecodeError to the existing UnicodeEncodeError exclusion
tuple so the classified-retry logic (which already handles 429/529/
context-overflow/etc.) gets to run on bad-JSON errors.
Tests (tests/run_agent/test_jsondecodeerror_retryable.py):
- JSONDecodeError: NOT local validation
- UnicodeEncodeError: NOT local validation (existing carve-out)
- bare ValueError: IS local validation (programming bug)
- bare TypeError: IS local validation (programming bug)
- source-level assertion that run_agent.py still carries the carve-out
(guards against accidental revert)
Closes #14782
nekorytaylor666
pushed a commit
to nekorytaylor666/hermes-agent
that referenced
this pull request
Apr 24, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
justrhoto
pushed a commit
to justrhoto/hermes-agent
that referenced
this pull request
Apr 24, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
This was referenced Apr 27, 2026
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
donald131
pushed a commit
to donald131/hermes-agent
that referenced
this pull request
May 2, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
… local validation error (NousResearch#15107) json.JSONDecodeError inherits from ValueError. The agent loop's non-retryable classifier at run_agent.py ~L10782 treated any ValueError/TypeError as a local programming bug and short-circuited retry. Without a carve-out, a transient JSONDecodeError from a provider that returned a malformed response body, a truncated stream, or a router-layer corruption would fail the turn immediately. Add JSONDecodeError to the existing UnicodeEncodeError exclusion tuple so the classified-retry logic (which already handles 429/529/ context-overflow/etc.) gets to run on bad-JSON errors. Tests (tests/run_agent/test_jsondecodeerror_retryable.py): - JSONDecodeError: NOT local validation - UnicodeEncodeError: NOT local validation (existing carve-out) - bare ValueError: IS local validation (programming bug) - bare TypeError: IS local validation (programming bug) - source-level assertion that run_agent.py still carries the carve-out (guards against accidental revert) Closes NousResearch#14782
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Provider returning malformed JSON now triggers a retry instead of failing the turn.
Root cause
json.JSONDecodeErrorinherits fromValueError. The agent loop's non-retryable classifier atrun_agent.py~L10782 treatsValueError/TypeErroras local programming bugs and short-circuits retry.UnicodeEncodeErrorwas already carved out;JSONDecodeErrorwasn't. A transient JSONDecodeError from a provider (malformed response body, truncated stream, routing layer corruption) bypassed retry and failed the turn.Change
Add
json.JSONDecodeErrorto the existingUnicodeEncodeErrorexclusion tuple. The classified-retry logic (which already handles 429 / 529 / context-overflow / etc.) gets to run on bad-JSON errors.Validation
JSONDecodeErrorUnicodeEncodeErrorValueError/TypeErrortests/run_agent/test_jsondecodeerror_retryable.py— 5/5 pass. Adjacent error-handling suites (anthropic, strict-API, context-overflow, invalid-context-length) — 33/33 pass.Closes #14782