# NousResearch/hermes-agent · TUI cleanup UnboundLocalError before history snapshot

## Open now

- 1 issue, 1 PR open on GitHub.
- #84685: \[Bug\] TUI turn cleanup raises UnboundLocalError (history.clear) when an exception fires before the history snapshot
- PR #84970: fix(tui): guard prompt cleanup before history snapshot

A bug where TUI turn cleanup raises an UnboundLocalError because the history variable is referenced before assignment when an exception fires early. The members cover the bug report and two fixes that pre-bind or guard the history reference before the try block.

## TL;DR

- 3 member(s): 1 open issue(s), 0 closed issue(s), 1 open PR(s), 0 merged PR(s), 1 PR(s) closed without merging.
- No fix has been merged to main; one or more PRs were attempted (see below).
- **Recommended:** review the prior/competing PR(s) below. A fix was attempted but not merged; your case may extend or revive that work.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `unresolved`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_SPANNING`): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
- Pairwise link density `0.67`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Open related issues

- #84685: \[Bug\] TUI turn cleanup raises UnboundLocalError (history.clear) when an exception fires before the history snapshot

## Prior & competing PRs

- **#84692: fix(tui): pre-bind history before turn try so cleanup never raises UnboundLocalError**. closed without merge
  - maintainer direction: category `silent_close`; implication `active`
- **#84970: fix(tui): guard prompt cleanup before history snapshot**. open
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`
  - files: `tests/tui_gateway/test_tui_gateway_server.py`, `tui_gateway/prompt_turn.py`

## Fix status

- No merged fix on record.
- Subsystem: `gateway`
