hermes - ✅(Solved) Fix [Bug]: JSONDecodeError bypasses retry logic due to ValueError inheritance [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14782Fetched 2026-04-24 06:14:45
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Error Message

json.JSONDecodeError inherits from ValueError, but in run_agent.py the error classification treats ValueError as a local validation error (non-retryable). When a provider returns malformed JSON (transient parse failure), the agent fails immediately instead of retrying, causing unnecessary session failures on provider hiccups. JSONDecodeError should be excluded from the local validation error classification and treated as a retryable transient error.

Fix Action

Fixed

PR fix notes

PR #14778: fix(agent): exclude JSONDecodeError from local validation error classification

Description (problem / solution / changelog)

What does this PR do?

json.JSONDecodeError inherits from ValueError but represents a transient provider parse failure, not a local programming bug. Without this exclusion it bypasses retry logic and fails immediately, causing unnecessary session failures on provider hiccups.

Related Issue

Fixes #14782

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • run_agent.py: Added JSONDecodeError exclusion to validation error classification
  • tests/run_agent/test_json_decode_error_retry.py: 5 tests verifying retry behavior

How to Test

python -m pytest -o 'addopts=' tests/run_agent/test_json_decode_error_retry.py -v

Result: 5 passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS 15 (Darwin 24.6.0), Python 3.14.2

Documentation & Housekeeping

  • N/A for all documentation items

Changed files

  • run_agent.py (modified, +1/-1)
  • tests/run_agent/test_json_decode_error_retry.py (added, +50/-0)
RAW_BUFFERClick to expand / collapse

Describe the bug

json.JSONDecodeError inherits from ValueError, but in run_agent.py the error classification treats ValueError as a local validation error (non-retryable). When a provider returns malformed JSON (transient parse failure), the agent fails immediately instead of retrying, causing unnecessary session failures on provider hiccups.

Steps to reproduce

  1. Use a provider that occasionally returns malformed JSON responses
  2. Observe that the agent fails immediately with no retry instead of retrying the request

Expected behavior

JSONDecodeError should be excluded from the local validation error classification and treated as a retryable transient error.

Environment

  • Hermes Agent version: current main
  • OS: any

extent analysis

TL;DR

Update the error classification in run_agent.py to treat json.JSONDecodeError as a retryable transient error instead of a local validation error.

Guidance

  • Review the error handling logic in run_agent.py to identify where ValueError is classified as a non-retryable error.
  • Update the classification to exclude json.JSONDecodeError from ValueError or create a separate handling path for json.JSONDecodeError to allow retries.
  • Verify that the agent now retries requests when encountering malformed JSON responses from providers.
  • Test the updated error handling with a provider that occasionally returns malformed JSON to ensure the agent behaves as expected.

Example

except json.JSONDecodeError as e:
    # Treat as retryable transient error
    retry_request()
except ValueError as e:
    # Handle other ValueError cases as non-retryable
    handle_local_validation_error(e)

Notes

This fix assumes that the json.JSONDecodeError exception is properly caught and handled in the run_agent.py script. If the issue persists, further debugging may be required to identify other potential causes.

Recommendation

Apply workaround: Update the error classification in run_agent.py to treat json.JSONDecodeError as a retryable transient error, as this directly addresses the identified issue and allows for a more robust handling of transient errors.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

JSONDecodeError should be excluded from the local validation error classification and treated as a retryable transient error.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING