Preserve recent Inkbox context across fresh Hermes sessions - #62
Open
shreyaskommuri wants to merge 6 commits into
Open
Preserve recent Inkbox context across fresh Hermes sessions#62shreyaskommuri wants to merge 6 commits into
shreyaskommuri wants to merge 6 commits into
Conversation
Request bounded webhook history and render it as explicitly untrusted data so a fresh Hermes session can recover recent channel continuity without adding a separate memory store. Harden replay deduplication, burst handling, and subscription reconciliation around that boundary. Constraint: Preserve exact command semantics, unrelated webhook consumers, and fixed local safety limits. Rejected: Reuse Claude Code's session behavior unchanged | Claude PR inkbox-ai#39 established that completely fresh /clear semantics conflict with restored history there. Confidence: high Scope-risk: moderate Directive: Keep trigger exclusion, exact-URL subscription ownership, and untrusted framing when extending the context schema. Tested: 258 passed, 24 skipped; 17 focused context tests; Ruff; Python compile; git diff --check; live fresh-session email validation against Inkbox. Not-tested: Live SMS and iMessage unavailable on the configured Hermes identity.
Make overlapping deliveries retry-safe, require server-declared context scope, preserve exact commands, and select the newest burst snapshot without weakening the bounded untrusted-data boundary. Constraint: Preserve completed-delivery deduplication and compatibility with Inkbox 0.4.20. Rejected: Acknowledge in-flight duplicates | a later failure would permanently lose the event. Confidence: high Scope-risk: moderate Directive: Retry responses must roll back both transport and event-level dedup reservations. Tested: 262 passed, 24 skipped; 53 focused tests on Inkbox 0.4.20; Ruff; Python compile; git diff --check; independent diff review. Not-tested: Live SMS and iMessage remain unavailable on the configured identity.
shreyaskommuri
marked this pull request as ready for review
July 14, 2026 21:03
_dedup_begin and _begin_dedup_response duplicated the same prune/lookup/reserve sequence against _seen_request_ids and _inflight_request_ids. Extract _dedup_claim as the single source of truth so the two call sites can't drift out of sync.
Selection was pure recency (last N items). Overfetch a 3x window from Inkbox (still capped at the SDK's 50-per-class max) and, within that window, prefer items whose subject/snippet/text/transcript overlaps the triggering message over ones that don't — so an older but on-topic item can survive against a run of newer small talk. Degrades to exactly the old last-N behavior whenever there's no overlap signal (empty trigger text, or no shared tokens), since position is the sole tiebreaker at that point — verified by every pre-existing webhook-context test passing unchanged. Cross-channel sections (email:/texts:/calls:) are left as separate blocks rather than merged into one interleaved timeline: that format is what the scope/security tests already pin down, and grouping by kind keeps provenance legible for the "untrusted background data" framing.
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.
Summary
This adds bounded recent Inkbox context to inbound email, SMS, and iMessage turns in Hermes so a fresh Hermes session can recover recent channel continuity without introducing another memory store.
Inkbox can include recent email, text, and call history in
data.context. The plugin requests that history on its owned webhook subscriptions, accepts only server-declared thread/conversation/contact scopes, renders selected fields inside strict local bounds, removes the triggering message, and appends the result as explicitly untrusted background data.Background
This work originated in inkbox-ai/claude-code-plugin#39. That implementation worked technically, but review identified a product-boundary mismatch: Claude Code's
/clearexperience is intended to start completely fresh, whereas Hermes is treated as a persistent assistant even when its model session rotates.Production hardening
Validation
git diff --check: cleanLive fresh-session validation
Validated against real Inkbox email delivery using the configured Hermes identity:
Temporary runtime and subscription changes were restored afterward.
Remaining validation gap
The configured identity has no SMS number and iMessage is disabled, so those channels are covered by handler, command, replay, scoping, and burst regression tests rather than live delivery.