Skip to content

feat(hooks): emit session:compress lifecycle event - #41624

Closed
WolframRavenwolf wants to merge 1 commit into
NousResearch:mainfrom
WolframRavenwolf:feat/session-compress-event-callback
Closed

WolframRavenwolf wants to merge 1 commit into
NousResearch:mainfrom
WolframRavenwolf:feat/session-compress-event-callback

Conversation

@WolframRavenwolf

Copy link
Copy Markdown
Contributor

Summary

Adds an event_callback hook on AIAgent and wires gateway agents to emit a structured session:compress lifecycle event when context compression splits/continues a session.

Motivation

External integrations that mirror, index, or observe Hermes sessions need a reliable event when compression changes the active session lineage. Scraping logs or polling the database is brittle; a callback gives gateway hooks a direct synchronization point.

Verification

  • python3 -m py_compile agent/agent_init.py agent/conversation_compression.py gateway/run.py run_agent.py
  • Constructor smoke for AIAgent(..., event_callback=...) and direct callback invocation

Notes

This branch was rebuilt on current upstream/main and preserves existing notice callbacks while adding the event callback.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery labels Jun 8, 2026
@WolframRavenwolf
WolframRavenwolf force-pushed the feat/session-compress-event-callback branch 4 times, most recently from d799a9f to 40fbcba Compare June 15, 2026 22:40
@WolframRavenwolf
WolframRavenwolf force-pushed the feat/session-compress-event-callback branch from 40fbcba to 7a1fed6 Compare June 16, 2026 00:38
teknium1 added a commit that referenced this pull request Jun 16, 2026
Follow-up to salvaged PR #41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
teknium1 added a commit that referenced this pull request Jun 16, 2026
Follow-up to salvaged PR #41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
@teknium1

Copy link
Copy Markdown
Collaborator

Merged via #47252 — your commit was cherry-picked onto current main with your authorship preserved in git log (rebase-merge).

The event_callback on AIAgent and the session:compress lifecycle event (with old_session_id/session_id/compression_count) are in, bridged to the gateway hook bus alongside the existing session:* / agent:* events. Follow-up on top: dropped a stray unused urllib import the branch carried, and added tests covering the emit + the no-callback and throwing-handler safety paths. Thanks!

@teknium1 teknium1 closed this Jun 16, 2026
alanbratu pushed a commit to alanbratu/hermes-agent that referenced this pull request Jun 17, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
al3xar pushed a commit to al3xar/hermes-agent that referenced this pull request Jun 17, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
Follow-up to salvaged PR NousResearch#41624:
- Remove stray urllib.parse import in run_agent.py (cherry-pick cruft, unused)
- Add tests: session:compress emits with correct context, no-callback is
  safe, and a callback exception does not break compression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants