hermes - 💡(How to fix) Fix hermes-lcm engine.py:1245 — unreachable condition due to prior return

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…

Error Message

Context: This is in _caller_is_auxiliary_agent_frame() which determines whether a caller's stack frame belongs to an auxiliary (subagent) session or the main session. The function already correctly identifies auxiliary frames via log_prefix, toolsets, memory_origin, etc. The line 1245 addition appears to be either a logic error or dead code introduced during one of the auxiliary session isolation PRs.

Code Example

log_prefix = str(getattr(caller_self, "log_prefix", "") or "").strip()
if log_prefix.startswith("[subagent-"):
    return True

---

if getattr(caller_self, "ephemeral_system_prompt", None) and log_prefix.startswith("[subagent-"):
    return True

---

# Change line 1245 to check ephemeral_system_prompt independently:
if getattr(caller_self, "ephemeral_system_prompt", None):
    return True
RAW_BUFFERClick to expand / collapse

File: hermes-lcm/engine.py:1245

Severity: Medium

Problem: engine.py:1245 contains a condition that can never be True when reached through the normal execution path.

Lines 1234-1236:

log_prefix = str(getattr(caller_self, "log_prefix", "") or "").strip()
if log_prefix.startswith("[subagent-"):
    return True

Line 1245 (unreachable):

if getattr(caller_self, "ephemeral_system_prompt", None) and log_prefix.startswith("[subagent-"):
    return True

If log_prefix starts with "[subagent-", line 1235 returns True immediately. Line 1245 is only reachable when log_prefix does NOT start with "[subagent-" — but line 1245 ALSO requires log_prefix.startswith("[subagent-") to be True. Contradiction makes the condition always False.

Two interpretations:

  1. Dead code (simple fix): Remove line 1245
  2. Wrong logic (if intent was different): ephemeral_system_prompt without [subagent- prefix should also return True as a standalone auxiliary signal

Recommended fix (dead code interpretation — conservative): Remove line 1245 entirely.

Recommended fix (if logic was intended differently — more aggressive):

# Change line 1245 to check ephemeral_system_prompt independently:
if getattr(caller_self, "ephemeral_system_prompt", None):
    return True

Context: This is in _caller_is_auxiliary_agent_frame() which determines whether a caller's stack frame belongs to an auxiliary (subagent) session or the main session. The function already correctly identifies auxiliary frames via log_prefix, toolsets, memory_origin, etc. The line 1245 addition appears to be either a logic error or dead code introduced during one of the auxiliary session isolation PRs.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING