Add bounded conversation context to inbound Inkbox webhooks#39
Add bounded conversation context to inbound Inkbox webhooks#39shreyaskommuri wants to merge 2 commits into
Conversation
Opt inbound subscriptions into recent history while preserving fan-out consumers and existing ContactSession turn and reply semantics. Constraint: Keep context fixed, bounded, and attached only to verified received email, SMS, and iMessage turns. Rejected: Channel-prefix subscription ownership | could overwrite unrelated fan-out consumers Rejected: Request-ID-only email deduplication | Inkbox replays use fresh delivery request IDs Confidence: high Scope-risk: moderate Directive: Preserve exact-URL subscription ownership and local trigger-ID exclusion when extending context schemas. Tested: 135 focused tests; 302 full-suite tests passed with 22 skipped; git diff --check; Python compileall; captured live email replay and live subscription readback Not-tested: Live SMS delivery unavailable; no post-opt-in live iMessage payload was available
|
@shreyaskommuri I like the overall intention of the PR. We recently began to send much richer context in the webhooks, but I am not totally sure that let me know if I am missing something |
|
@dimavrem22 But I agree with your larger point that the next inbound message would still receive recent Inkbox history, so it would not be a completely fresh experience in this plugin. I’m happy to close this PR and adapt the work for Hermes instead, where persistent personal-assistant context seems like a much better fit. |
Summary
This adds bounded recent Inkbox context to inbound email, SMS, and iMessage turns in the Claude Code plugin.
Inkbox can include recent email, text, and call history in
data.context. The bridge now opts supported webhook subscriptions into that context, safely renders selected fields, and appends the result to the existing inboundContactSession._Turn.No new session, memory store, event abstraction, or automatic side effect is introduced.
Problem
Inbound Claude sessions previously received only the current message, even when Inkbox supplied relevant recent history. This was especially noticeable after
/clear, when Claude began a fresh session without seeing recent Inkbox conversation history.Implementation
Safety
The renderer excludes raw headers, attachment URLs, transcript URLs, and unknown fields. It applies item, string, transcript, list, and total-block limits, while preserving the closing delimiter when truncation is required.
Malformed or missing context degrades safely without rejecting the valid inbound message. Empty context arrays are omitted instead of producing an empty block.
Historical content is framed as:
Subscription reconciliation treats a webhook as bridge-owned only when its URL exactly matches the desired bridge URL or an explicitly supplied previous bridge URL. It does not select subscriptions from event-type prefixes. Unrelated CRM, analytics, and fan-out subscriptions are therefore preserved.
Live validation
This change was validated against real Inkbox webhook deliveries.
Confirmed live behavior:
The raw Inkbox payload reports:
threadcontactcontactThis PR does not claim contact-wide or cross-thread email memory.
Compatibility and unchanged behavior
The existing Inkbox dependency floor already supports
context_config.The change preserves webhook authentication, request-level deduplication, contact-based
chat_idselection, unresolved-email thread fallback,ContactSession._Turn, Claude session persistence, thread routing, contact resolution, control commands, send behavior, and automatic reply delivery.General cross-session memory and Hermes issue #8 remain out of scope.
Tests
git diff --check: cleanCoverage includes context ordering and bounds, malformed payloads, field allowlisting, local trigger exclusion for all three channels, stable email replay deduplication and rollback, exact-URL subscription ownership, drift repair, previous-URL migration, 409 race repair, unrelated subscription preservation, and existing authentication, routing, session, and reply behavior.
Remaining limitations
These behaviors are separate from this context-rendering change:
/clearare not recognized when Gmail or Outlook quoted-reply content follows the command. The same behavior is present on upstream.These can be handled through separate issues or follow-up changes rather than expanding this PR's scope.