Skip to content

fix(agent): forward platform kwarg at compression boundary to context engine - #42679

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/compression-boundary-platform-kwarg
Closed

fix(agent): forward platform kwarg at compression boundary to context engine#42679
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/compression-boundary-platform-kwarg

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Forwards the platform kwarg at the compression boundary on_session_start call, so plugin context engines (e.g. hermes-lcm) that track per-session source lineage retain the correct platform attribution after context rotation.

Related Issue

Fixes #27633

Type of Change

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

Changes Made

  • agent/conversation_compression.py: Add platform=getattr(agent, "platform", None) or "cli" to the compression boundary on_session_start call (line 567), matching the initial session start at agent_init.py:1599 which already passes platform correctly.
  • tests/agent/test_compression_boundary_platform.py: 3 regression tests verifying platform is forwarded (discord), defaults to "cli" when empty, and preserves platform name through the compression boundary.

How to Test

  1. Run pytest tests/agent/test_compression_boundary_platform.py -v — all 3 tests should pass
  2. Run pytest tests/gateway/test_compress_*.py -v — existing compression tests should still pass
  3. For manual testing: use a plugin context engine (e.g. hermes-lcm), start a Telegram/Discord session, trigger compression via context pressure, then check lcm_status — source lineage should show the correct platform (not "unknown") for messages after the compression boundary

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

Code Intelligence

  • Analyzed: agent/conversation_compression.py:compress_context (compression boundary on_session_start call)
  • Compared: agent/agent_init.py:1596 (initial session start — correctly passes platform)
  • Blast radius: LOW — single kwarg addition, no control flow change, built-in ContextCompressor ignores kwargs
  • Related patterns: The initial on_session_start at agent_init.py:1596 already passes platform=agent.platform or "cli". This fix ensures the compression boundary matches that pattern.

… engine

When Hermes rotates session_id during context compression, the
on_session_start call at the compression boundary omitted `platform`.
Plugin engines (e.g. hermes-lcm) that track per-session source lineage
via `_session_platform` got it reset to "" → "unknown". All messages
ingested after the compression boundary were attributed to
source='unknown' instead of the actual platform (discord, telegram, etc.).

Fix: add `platform=getattr(agent, "platform", None) or "cli"` to the
compression boundary on_session_start call, matching the initial session
start at agent_init.py which already passes platform correctly.

Fixes NousResearch#27633
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Jun 9, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #49772 — your authorship is preserved as a co-author trailer on the squashed/rebased commit. This combined cluster fix incorporates the platform-kwarg-at-compression-boundary fix from this PR. Thanks for the contribution! #49772

@teknium1 teknium1 closed this Jun 21, 2026
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 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.

bug: compression boundary drops platform kwarg, causing source=unknown on all subsequent LCM messages

3 participants