-
Notifications
You must be signed in to change notification settings - Fork 48.1k
fix(honcho): prevent orphan sessions + restore gateway_session_key #8424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3356,6 +3356,7 @@ async def _handle_message_with_agent(self, event, source, _quick_key: str): | |||||
| model=_hyg_model, | ||||||
| max_iterations=4, | ||||||
| quiet_mode=True, | ||||||
| skip_memory=True, | ||||||
| enabled_toolsets=["memory"], | ||||||
| session_id=session_entry.session_id, | ||||||
| ) | ||||||
|
|
@@ -5758,6 +5759,7 @@ async def _handle_compress_command(self, event: MessageEvent) -> str: | |||||
| model=model, | ||||||
| max_iterations=4, | ||||||
| quiet_mode=True, | ||||||
| skip_memory=True, | ||||||
|
||||||
| skip_memory=True, | |
| skip_memory=False, |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -422,16 +422,18 @@ def resolve_session_name( | |||||||||
| cwd: str | None = None, | ||||||||||
| session_title: str | None = None, | ||||||||||
| session_id: str | None = None, | ||||||||||
| gateway_session_key: str | None = None, | ||||||||||
| ) -> str | None: | ||||||||||
| """Resolve Honcho session name. | ||||||||||
|
|
||||||||||
| Resolution order: | ||||||||||
| 1. Manual directory override from sessions map | ||||||||||
| 2. Hermes session title (from /title command) | ||||||||||
| 3. per-session strategy — Hermes session_id ({timestamp}_{hex}) | ||||||||||
| 4. per-repo strategy — git repo root directory name | ||||||||||
| 5. per-directory strategy — directory basename | ||||||||||
| 6. global strategy — workspace name | ||||||||||
| 3. Gateway session key (stable per-chat identifier from gateway platforms) | ||||||||||
| 4. per-session strategy — Hermes session_id ({timestamp}_{hex}) | ||||||||||
| 5. per-repo strategy — git repo root directory name | ||||||||||
| 6. per-directory strategy — directory basename | ||||||||||
| 7. global strategy — workspace name | ||||||||||
| """ | ||||||||||
| import re | ||||||||||
|
|
||||||||||
|
|
@@ -451,6 +453,16 @@ def resolve_session_name( | |||||||||
| return f"{self.peer_name}-{sanitized}" | ||||||||||
| return sanitized | ||||||||||
|
|
||||||||||
| # Gateway session key: stable per-chat identifier passed by the gateway | ||||||||||
| # (e.g. "agent:main:telegram:dm:8439114563"). Sanitize colons to hyphens | ||||||||||
| # for Honcho session ID compatibility. This takes priority over strategy- | ||||||||||
| # based resolution because gateway platforms need per-chat isolation that | ||||||||||
| # cwd-based strategies cannot provide. | ||||||||||
| if gateway_session_key: | ||||||||||
| sanitized = re.sub(r'[^a-zA-Z0-9_-]', '-', gateway_session_key).strip('-') | ||||||||||
| if sanitized: | ||||||||||
|
||||||||||
| if sanitized: | |
| if sanitized: | |
| if self.session_peer_prefix and self.peer_name: | |
| return f"{self.peer_name}-{sanitized}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip_memory=Trueprevents the built-inMemoryStoreand memory provider plugins from initializing, but_compress_context()always callsflush_memories()before compression. Withskip_memory=True,flush_memories()will always hitMemoryStore is Noneand the pre-compression memory flush becomes a no-op.If the intent is to still preserve memory before truncating the transcript, consider initializing/reusing a
MemoryStorefor this temp agent (without initializing Honcho), or alternatively avoid_compress_context()and callcontext_compressor.compress()directly when you explicitly want compression to have zero memory side effects.