fix(agent): persist display_metadata for every user message, derived from source - #96081
Open
TwoRobotsinaTrenchcoat wants to merge 1 commit into
Open
TwoRobotsinaTrenchcoat wants to merge 1 commit into
TwoRobotsinaTrenchcoat wants to merge 1 commit into
Conversation
…from source The display_metadata field existed but was nested inside the display_kind check, so it was dropped for every normal (non-summary) user message. Un-nest the persistence and derive origin attribution from the message source when not explicitly provided. Tests use synthetic fixture values (no real user/chat IDs). Co-authored-by: Hermes Contributor <contrib@users.noreply.github.com>
fix(agent): persist display_metadata for every user message, derived from source — closes silent attribution drop.
|
2 tasks
Author
|
Coordination check: v0.21.0 added native If the native path is intended to generalize to gateway messages, happy to re-scope or withdraw; if not, this PR remains complementary. Which is it? @teknium1 |
Closed
13 tasks
This branch has not been deployed
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?
Fixes a bug where
display_metadatawas silently dropped for every normal user message.In
agent/turn_context.py,display_metadatawas only persisted inside theif display_kind:block. Normal user messages (roleuser, nodisplay_kind) never entered that branch, so theirdisplay_metadata— attribution likeorigin,platform,chat_id— was never written to the session store. This breaks downstream consumers that rely on per-message attribution (e.g. session search, annotation rendering, the HUD footer).The fix un-nests the persistence so it runs for every message, and derives
origin/platformattribution from the messagesourcewhen not explicitly provided (mirroring how the gateway already computes these).Related Issue
No open issue exists for this bug. Symptom verified locally: a
[Replying to: ...]reply-composite row instate.dbcarried nodisplay_metadatawhile a sibling message did.Type of Change
Changes Made
agent/turn_context.py: moveddisplay_metadatapersistence out of thedisplay_kindguard; added_derive_source_annotation(agent, content)helper that readsplatform/chat_id/ etc. off the source and returns a minimal attribution dict. Every user message now persists attribution.tests/agent/test_turn_context.py: added tests covering (a) message with explicitdisplay_metadata, (b) message with source-derived attribution, (c) CLI message (platform=cli) gets at leastplatform+origin.How to Test
display_kind).state.dbmessages—display_metadatashould be present withorigin/platform.display_metadatawas absent for that row.Checklist
pytest tests/agent/test_turn_context.pypasses (22 tests)Companion PR (read path)
This PR is the write path — it persists
display_metadataonto every user message. The read path (makingsession_searchactually surface that column) is #97523. Merged together, per-message attribution survives compaction end-to-end; either alone is incomplete.