Skip to content

fix(gateway): skip finalize hook without prior session#23255

Open
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:codex/12176-skip-empty-finalize
Open

fix(gateway): skip finalize hook without prior session#23255
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:codex/12176-skip-empty-finalize

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

What does this PR do?

This fixes #12176 with a narrow bugfix that keeps the affected path aligned with the current Hermes behavior without widening the change surface.

Related Issue

Fixes #12176

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

  • skip on_session_finalize when /reset or /new does not have an old session entry to finalize
  • add a session-boundary regression test so empty resets stop firing finalize hooks with missing state
  • Files: gateway/run.py, tests/gateway/test_session_boundary_hooks.py

How to Test

  1. Run uv run --frozen pytest -q -o addopts='' tests/gateway/test_session_boundary_hooks.py -k 'reset_without_old_session_skips_finalize_hook or reset_fires_finalize_hook or finalize_before_reset'
  2. Run uv run --frozen ruff check gateway/run.py tests/gateway/test_session_boundary_hooks.py
  3. Confirm the affected workflow in /new emits on_session_finalize(session_id=None) when no prior session exists #12176 now follows the expected behavior.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

Screenshots / Logs

Gateway session-boundary regression tests and Ruff checks passed locally on macOS.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists labels May 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #12184 — same on_session_finalize guard for #12176.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/new emits on_session_finalize(session_id=None) when no prior session exists

2 participants