fix(agent): forward platform kwarg at compression boundary to context engine - #42679
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(agent): forward platform kwarg at compression boundary to context engine#42679liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
… 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
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Forwards the
platformkwarg at the compression boundaryon_session_startcall, 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
Changes Made
agent/conversation_compression.py: Addplatform=getattr(agent, "platform", None) or "cli"to the compression boundaryon_session_startcall (line 567), matching the initial session start atagent_init.py:1599which 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
pytest tests/agent/test_compression_boundary_platform.py -v— all 3 tests should passpytest tests/gateway/test_compress_*.py -v— existing compression tests should still passlcm_status— source lineage should show the correct platform (not "unknown") for messages after the compression boundaryChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
agent/conversation_compression.py:compress_context(compression boundary on_session_start call)agent/agent_init.py:1596(initial session start — correctly passes platform)on_session_startatagent_init.py:1596already passesplatform=agent.platform or "cli". This fix ensures the compression boundary matches that pattern.