Skip to content

fix(agent): add debug logging to silent exception fallbacks in four agent modules - #58358

Closed
MDGChamomile wants to merge 4 commits into
NousResearch:mainfrom
MDGChamomile:pr/c2-exception-observability
Closed

fix(agent): add debug logging to silent exception fallbacks in four agent modules#58358
MDGChamomile wants to merge 4 commits into
NousResearch:mainfrom
MDGChamomile:pr/c2-exception-observability

Conversation

@MDGChamomile

Copy link
Copy Markdown

What does this PR do?

Makes four silent exception-swallow sites in agent/ observable by adding debug-level logging, without changing catch breadth, fallback values, or any control flow. Today these paths hide real failures (e.g. a broken verify-hook config or a failed jiter preload) with no trace in logs, which makes field debugging unnecessarily hard.
Per module:
agent/tool_result_classification.py — log when a tool result payload fails JSON parsing and falls back to plain-text classification.
agent/verify_hooks.py — log when verify-hook configuration loading fails and silently falls back (previously a genuinely error-hiding path).
agent/message_content.py — log when message content extraction hits its exception fallback.
agent/jiter_preload.py — log when the optional jiter native parser preload fails; the stored preload error (_JITER_PRELOAD_ERROR) is preserved unchanged.
All logging is logger.debug(..., exc_info=True) style — zero noise at default log levels, full traceback available when debugging.
This is the same direction as other open observability fixes for swallowed exceptions (e.g. #44018, #53336, #44834), applied to four small core agent modules with focused tests.

Related Issue

No single tracking issue; this addresses the "error-hiding silent except" class also targeted by #44018 / #53336 / #44834.

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • agent/tool_result_classification.py (+11/−1) — debug log on non-JSON fallback

  • agent/verify_hooks.py (+10/−1) — debug log on config load fallback

  • agent/message_content.py (+11/−1) — debug log on extraction fallback

  • agent/jiter_preload.py (+8/−0) — debug log on preload failure

  • tests/agent/test_tool_result_classification.py (+15) — pins fallback behavior + log emission

  • tests/agent/test_verify_hooks.py (+22) — pins fallback behavior + log emission

  • tests/agent/test_message_content.py (+24) — pins fallback behavior + log emission

  • tests/agent/test_jiter_preload.py (+29) — pins fallback behavior + log emission

  • Total: 8 files, +127/−3. One commit per module for reviewable, revertible units.

How to Test

  1. scripts/run_tests.sh tests/agent/test_tool_result_classification.py tests/agent/test_verify_hooks.py tests/agent/test_message_content.py tests/agent/test_jiter_preload.py -q
  2. All new tests assert both the preserved fallback behavior (return values / catch breadth unchanged) and the new debug log emission (caplog).
  3. Behavior check: no public API, return value, or exception-propagation change in any of the four modules — the diffs are logging additions only.

Checklist

Code

Documentation & Housekeeping

  • Documentation — N/A (debug-level logging only, no user-facing behavior change)
  • cli-config.yaml.example — N/A (no config keys)
  • CONTRIBUTING.md / AGENTS.md — N/A (no architecture change)
  • Cross-platform impact — N/A (pure-Python logging, no platform primitives)
  • Tool descriptions/schemas — N/A (no tool behavior change)

Screenshots / Logs

$ scripts/run_tests.sh tests/agent/test_tool_result_classification.py
tests/agent/test_verify_hooks.py tests/agent/test_message_content.py
tests/agent/test_jiter_preload.py -q

=== Per-file subprocess time distribution ===
Files: 4
Total subprocess CPU-wall: 1.7s (runner wall: 0.4s, parallelism: 16x)
<1s: 4 files (100%) <2s: 4 files (100%)
0.43s tests/agent/test_message_content.py
0.42s tests/agent/test_tool_result_classification.py
0.42s tests/agent/test_verify_hooks.py
0.42s tests/agent/test_jiter_preload.py

exit code: 0 (all passed, 0 failures)

Add debug-level logging when a tool result payload fails JSON parsing
and falls back to plain-text classification. No behavior change:
catch breadth and return values are preserved.
Add debug-level logging when verify hook configuration loading falls
back after a swallowed exception. This path previously hid config
errors silently. No behavior change: catch breadth and fallback
values are preserved.
Add debug-level logging when message content extraction hits its
exception fallback path. No behavior change: catch breadth and
return values are preserved.
Add debug-level logging when the optional jiter native parser preload
fails and the import falls back. The stored preload error is preserved
unchanged. No behavior change.
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jul 4, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused observability improvement. The premise remains valid on current main: the four exception fallbacks are still silent at agent/tool_result_classification.py:30, agent/verify_hooks.py:53, agent/message_content.py:47, and agent/jiter_preload.py:27.

The diff preserves the existing catch scope and fallback results while adding module-local logger.debug(..., exc_info=True) diagnostics and focused caplog coverage. It adds no tool, configuration, hook, or prompt/cache surface.

Since the PR base, only agent/tool_result_classification.py and its test changed among the eight paths, via separate helpers added in a0a6cd80; this looks mechanically salvageable with possible minor context resolution.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 15, 2026
@MDGChamomile
MDGChamomile deleted the pr/c2-exception-observability branch August 14, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants