hermes - ✅(Solved) Fix TUI: /reload-mcp slash command crashes on null ctx.sid [2 pull requests, 3 comments, 3 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#17794Fetched 2026-05-01 05:55:45
View on GitHub
Comments
3
Participants
3
Timeline
10
Reactions
0
Timeline (top)
labeled ×4commented ×3cross-referenced ×2subscribed ×1

Root Cause

In ui-tui/src/app/slash/commands/ops.ts line 81, ctx.sid is string | null but is used as string without null checking.

Fix Action

Fix

Added null guard matching the pattern used by /rollback and /save:

if (!ctx.sid) {
    return ctx.transcript.sys("/reload-mcp requires an active session")
}

PR fix notes

PR #17821: fix(tui): guard /reload-mcp against null ctx.sid

Description (problem / solution / changelog)

What does this PR do?

/reload-mcp declared params.session_id: string but read it directly from ctx.sid, which is typed as string | null. Triggering the command before a session was active crashed the TUI. Mirrors the null-guard pattern that /rollback (and /save) already use — surface a sys message instead of hitting the RPC with a null id.

Related Issue

Fixes #17794

Type of Change

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

Changes Made

  • ui-tui/src/app/slash/commands/ops.ts — early-return with ctx.transcript.sys('/reload-mcp requires an active session') when ctx.sid is null, before constructing params.
  • ui-tui/src/__tests__/createSlashHandler.test.ts:
    • removed the table row that asserted reload.mcp is called with session_id: null (that was the bug — the typed string field was getting null).
    • added a positive test: active sid → RPC routed with the sid.
    • added a regression test: no sid → sys message, RPC not invoked.

How to Test

  1. cd ui-tui && npm install
  2. npm run build --prefix packages/hermes-ink
  3. npx vitest run createSlashHandler — 45 / 45 pass, including the two new cases.
  4. Full TUI suite (npx vitest run) — 539 / 539.
  5. npm run type-check — clean.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • Targeted vitest run + full TUI suite + tsc --noEmit pass locally
  • I've added tests for my changes
  • I've tested on my platform: macOS 15 (Darwin 23.2)

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (no behavior change for users beyond the new sys message)
  • I've updated cli-config.yaml.example — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md — N/A
  • I've considered cross-platform impact — guard is platform-agnostic
  • I've updated tool descriptions/schemas — N/A

Changed files

  • ui-tui/src/__tests__/createSlashHandler.test.ts (modified, +20/-1)
  • ui-tui/src/app/slash/commands/ops.ts (modified, +4/-0)

PR #17822: fix(tui): add null guard for ctx.sid in /reload-mcp slash command

Description (problem / solution / changelog)

Summary

Add a null guard for ctx.sid in the /reload-mcp slash command handler, matching the existing pattern used by /rollback and /save.

Problem

When ctx.sid is null (no active session), /reload-mcp crashes because it passes null as session_id: string to the reload.mcp RPC call. The TypeScript type for params.session_id is string, but ctx.sid is string | null.

Fix

Added an early-return null check at the top of the run handler, before building the RPC params:

if (!ctx.sid) {
  return ctx.transcript.sys("/reload-mcp requires an active session")
}

This matches the guard pattern already used by /rollback (line 193) and /save in the same file.

Changed Files

  • ui-tui/src/app/slash/commands/ops.ts — 3 lines added

Closes #17794

Changed files

  • ui-tui/src/app/slash/commands/ops.ts (modified, +3/-0)

Code Example

if (!ctx.sid) {
    return ctx.transcript.sys("/reload-mcp requires an active session")
}
RAW_BUFFERClick to expand / collapse

Bug Description

The /reload-mcp slash command in the TUI crashes when ctx.sid is null. The parameter params.session_id is typed as string, but ctx.sid has type string | null. Other slash commands (/rollback, /save) include a null guard at the top, but /reload-mcp was missing it.

Steps to Reproduce

  1. Start hermes --tui
  2. Type /reload-mcp in a session where ctx.sid is null
  3. Observe crash

Root Cause

In ui-tui/src/app/slash/commands/ops.ts line 81, ctx.sid is string | null but is used as string without null checking.

Fix

Added null guard matching the pattern used by /rollback and /save:

if (!ctx.sid) {
    return ctx.transcript.sys("/reload-mcp requires an active session")
}

Environment

  • Hermes Agent git-installed
  • TUI (Ink/React terminal UI)

extent analysis

TL;DR

Add a null guard to check if ctx.sid is null before using it in the /reload-mcp command.

Guidance

  • Verify that ctx.sid is indeed null when the crash occurs by adding a console log or debugger statement before the line that crashes.
  • Check if other parts of the code also assume ctx.sid is always a string and add null guards as needed.
  • Consider adding a type guard to ensure ctx.sid is a string before using it as one.
  • Review the code for any other potential null pointer exceptions.

Example

if (!ctx.sid) {
    return ctx.transcript.sys("/reload-mcp requires an active session")
}

This code snippet adds a null guard to check if ctx.sid is null before using it.

Notes

This fix assumes that the crash is indeed caused by the null ctx.sid value. If the issue persists after adding the null guard, further debugging may be necessary.

Recommendation

Apply the workaround by adding a null guard to the /reload-mcp command, as it is a straightforward fix that addresses the identified root cause.

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

hermes - ✅(Solved) Fix TUI: /reload-mcp slash command crashes on null ctx.sid [2 pull requests, 3 comments, 3 participants]