Skip to content

fix: log exceptions instead of silently swallowing in cron scheduler#716

Merged
teknium1 merged 2 commits into
NousResearch:mainfrom
0xbyt4:fix/cron-silent-exception-swallowing
Mar 11, 2026
Merged

fix: log exceptions instead of silently swallowing in cron scheduler#716
teknium1 merged 2 commits into
NousResearch:mainfrom
0xbyt4:fix/cron-silent-exception-swallowing

Conversation

@0xbyt4

@0xbyt4 0xbyt4 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Two except Exception: pass blocks in cron/scheduler.py silently swallow errors
  • Line 140: mirror_to_session failure means the user's cron job output is never mirrored to their session -- no log, no trace, no indication of failure
  • Line 192: config.yaml parse failure causes the agent to silently fall back to the default model instead of the user's configured model

Changes

  • Replace except Exception: pass with except Exception as e: logger.warning(...) at both locations
  • The logger is already used extensively in the same file (18 times) -- these two were the only silent catches

Test plan

  • 2 new tests added to tests/cron/test_scheduler.py
  • test_mirror_failure_is_logged: verifies mirror_to_session exception produces a warning log
  • test_bad_config_yaml_is_logged: verifies malformed config.yaml produces a warning log
  • All 7 existing + new tests pass

0xbyt4 added 2 commits March 9, 2026 00:06
Two 'except Exception: pass' blocks silently hide failures:
- mirror_to_session failure: user's message never gets mirrored, no trace
- config.yaml parse failure: wrong model used silently

Replace with logger.warning so failures are visible in logs.
asyncio.run() closes the event loop after execution, which breaks
subsequent tests using asyncio.get_event_loop() (test_send_image_file).
@teknium1 teknium1 merged commit be2e259 into NousResearch:main Mar 11, 2026
1 check passed
teknium1 added a commit that referenced this pull request Mar 11, 2026
Follow-up to PR #716 (0xbyt4):
- Log the third remaining silent except-pass in scheduler (prefill
  messages JSON parse failure)
- Fix test mock: run → run_conversation (matches actual agent API)
- Remove unused imports (asyncio, AsyncMock)
- Add test for prefill_messages parse failure logging
@teknium1

Copy link
Copy Markdown
Contributor

Merged in 03a4f18 — thanks again @0xbyt4! Great catch on those silent exceptions.

Follow-up cleanup in 2dddfce:

  • Fixed the third remaining except Exception: pass you noted (prefill messages parse failure)
  • Fixed test mock method name (runrun_conversation)
  • Removed unused test imports (asyncio, AsyncMock)
  • Added test for the prefill parse failure logging

All 2919 tests pass. 🙏

lmsanch added a commit to lmsanch/hermes-agent that referenced this pull request Apr 22, 2026
…play protection (NousResearch#718) (#6)

Operationalizes the A2A cryptographic identity spec in
docs/strategic/A2A_CRYPTO_IDENTITY.md (filed as toryx-private#820).
This is the module downstream issues NousResearch#801, NousResearch#802, and NousResearch#812 integrate
against; it replaces the env-var trust shim in research_mcp whitelist.

New module `tools/agent_identity.py`:

- generate_identity(profile_name, force=False)
  Writes an Ed25519 private key (PKCS8 PEM) to
  ~/.hermes/profiles/<profile>/keys/ed25519_private.pem (chmod 600) and
  registers the raw public key in ~/.hermes/identity_registry.yaml.
  Refuses overwrite without force=True so rotation is explicit.

- sign_envelope(profile_name, recipient, body, host=None)
  Canonical-JSON envelope per spec §4: sender_agent, sender_host,
  recipient_agent, nonce (128 bit hex), timestamp (ISO8601 UTC),
  body_sha256, body, signature. Signature covers everything except the
  signature field itself.

- verify_envelope(envelope)
  Per spec §5 verification flow: missing-fields check → timestamp window
  (5 min) → body_sha256 integrity → nonce LRU replay (10k entries) →
  pubkey lookup → Ed25519 verify. On ANY failure returns non-valid
  result — callers drop silently, no reply (prevents loop amplification
  + reply-ack exfil per NousResearch#716 lessons).

- canonical_json(obj)
  Exposed utility — sorted keys, UTF-8, no whitespace. Same shape as the
  toryx-openratings anchor payload canonical form.

Tests:
- Round-trip sign/verify
- Replay rejection (same nonce twice)
- Timestamp-out-of-window rejection
- Unknown sender rejection
- Bad signature rejection
- Tampered body rejection (body_sha256 integrity catch)
- Missing fields rejection
- Canonical JSON is deterministic across key orderings
- Two-agent talk (cross-identity verification)
- Nonce LRU eviction semantics

Not in scope (v2):
- Key rotation with 30-day pubkey overlap
- HSM-backed private key storage
- Transport bindings (telegram X-header, email header, consult_colleague
  inline field) — those land in each platform adapter

Closes lmsanch/toryx-private#718
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…allowing in cron scheduler

Authored by 0xbyt4. Replaces two except-Exception-pass blocks with
logger.warning() calls and adds tests for both paths.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
Follow-up to PR NousResearch#716 (0xbyt4):
- Log the third remaining silent except-pass in scheduler (prefill
  messages JSON parse failure)
- Fix test mock: run → run_conversation (matches actual agent API)
- Remove unused imports (asyncio, AsyncMock)
- Add test for prefill_messages parse failure logging
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…allowing in cron scheduler

Authored by 0xbyt4. Replaces two except-Exception-pass blocks with
logger.warning() calls and adds tests for both paths.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Follow-up to PR NousResearch#716 (0xbyt4):
- Log the third remaining silent except-pass in scheduler (prefill
  messages JSON parse failure)
- Fix test mock: run → run_conversation (matches actual agent API)
- Remove unused imports (asyncio, AsyncMock)
- Add test for prefill_messages parse failure logging
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…allowing in cron scheduler

Authored by 0xbyt4. Replaces two except-Exception-pass blocks with
logger.warning() calls and adds tests for both paths.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
Follow-up to PR NousResearch#716 (0xbyt4):
- Log the third remaining silent except-pass in scheduler (prefill
  messages JSON parse failure)
- Fix test mock: run → run_conversation (matches actual agent API)
- Remove unused imports (asyncio, AsyncMock)
- Add test for prefill_messages parse failure logging
lmsanch added a commit to lmsanch/hermes-agent that referenced this pull request May 23, 2026
…play protection (NousResearch#718) (#6)

Operationalizes the A2A cryptographic identity spec in
docs/strategic/A2A_CRYPTO_IDENTITY.md (filed as toryx-private#820).
This is the module downstream issues NousResearch#801, NousResearch#802, and NousResearch#812 integrate
against; it replaces the env-var trust shim in research_mcp whitelist.

New module `tools/agent_identity.py`:

- generate_identity(profile_name, force=False)
  Writes an Ed25519 private key (PKCS8 PEM) to
  ~/.hermes/profiles/<profile>/keys/ed25519_private.pem (chmod 600) and
  registers the raw public key in ~/.hermes/identity_registry.yaml.
  Refuses overwrite without force=True so rotation is explicit.

- sign_envelope(profile_name, recipient, body, host=None)
  Canonical-JSON envelope per spec §4: sender_agent, sender_host,
  recipient_agent, nonce (128 bit hex), timestamp (ISO8601 UTC),
  body_sha256, body, signature. Signature covers everything except the
  signature field itself.

- verify_envelope(envelope)
  Per spec §5 verification flow: missing-fields check → timestamp window
  (5 min) → body_sha256 integrity → nonce LRU replay (10k entries) →
  pubkey lookup → Ed25519 verify. On ANY failure returns non-valid
  result — callers drop silently, no reply (prevents loop amplification
  + reply-ack exfil per NousResearch#716 lessons).

- canonical_json(obj)
  Exposed utility — sorted keys, UTF-8, no whitespace. Same shape as the
  toryx-openratings anchor payload canonical form.

Tests:
- Round-trip sign/verify
- Replay rejection (same nonce twice)
- Timestamp-out-of-window rejection
- Unknown sender rejection
- Bad signature rejection
- Tampered body rejection (body_sha256 integrity catch)
- Missing fields rejection
- Canonical JSON is deterministic across key orderings
- Two-agent talk (cross-identity verification)
- Nonce LRU eviction semantics

Not in scope (v2):
- Key rotation with 30-day pubkey overlap
- HSM-backed private key storage
- Transport bindings (telegram X-header, email header, consult_colleague
  inline field) — those land in each platform adapter

Closes lmsanch/toryx-private#718
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…allowing in cron scheduler

Authored by 0xbyt4. Replaces two except-Exception-pass blocks with
logger.warning() calls and adds tests for both paths.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
Follow-up to PR NousResearch#716 (0xbyt4):
- Log the third remaining silent except-pass in scheduler (prefill
  messages JSON parse failure)
- Fix test mock: run → run_conversation (matches actual agent API)
- Remove unused imports (asyncio, AsyncMock)
- Add test for prefill_messages parse failure logging
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.

2 participants