Persist inbound platform reply metadata - #73399
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the ordinary, proxy, queued-follow-up, and early-failure persistence paths. The underlying gap remains on current main: gateway/run.py:16656 forwards only event_message_id, gateway/session.py:3085 persists only the platform message ID, and the canonical messages schema at hermes_state_common.py:192 has no structured platform-metadata column.
Problems
hermes_state.py:7196carries replacement metadata in a map keyed only byplatform_message_id. Because the proposed metadata contains platform and chat scope, duplicate IDs from different scopes can overwrite one another duringreplace_messages()and restore the wrong reply target.
Suggested changes
- Preserve by a scoped identity such as
(platform, chat_id, message_id)rather than message ID alone. - Salvage against the current state-schema, portability, and
TurnContextseams; GitHub currently reports this branch conflicting and 865 commits behind main.
This is an automated hermes-sweeper review.
| # Transcript rewrites built from that replay shape must not erase | ||
| # durable reply-correlation metadata. Carry it forward by stable | ||
| # platform id without mutating the caller's message dictionaries. | ||
| existing_platform_metadata: Dict[str, Dict[str, str]] = {} |
There was a problem hiding this comment.
This carry-forward map is keyed only by platform_message_id, although the metadata is explicitly platform/chat scoped. A duplicate ID from another chat or platform can overwrite this entry and restore the wrong reply correlation during replace_messages(); please use a scoped key or retain row-specific metadata.
Summary
Persist inbound platform correlation metadata alongside user transcript rows so gateway features can reliably resolve native replies after a restart.
Each inbound
MessageEventcan now persist:platform_message_idremains a separate indexed column for deduplication and lookup.Implementation
messages.platform_metadataJSON/TEXT column through the existing declarative schema reconcilerTests
tests/test_hermes_state.py: 470 passed, 1 skippedgit diff --check: passedA full
scripts/run_tests.shrun was also attempted locally. It reported 27 failures in unrelated macOS/system-integration suites. The four agent/auth failures inspected separately reproduce unchanged on a clean upstream worktree; none involve the files or behavior changed here.