Skip to content

feat(webhook): add opt-in persistent session keys - #90571

Closed
jzOcb wants to merge 6 commits into
NousResearch:mainfrom
jzOcb:feat/webhook-persistent-session-key
Closed

feat(webhook): add opt-in persistent session keys#90571
jzOcb wants to merge 6 commits into
NousResearch:mainfrom
jzOcb:feat/webhook-persistent-session-key

Conversation

@jzOcb

@jzOcb jzOcb commented Aug 20, 2026

Copy link
Copy Markdown

Summary

Adds an opt-in per-route session_key template so conversational webhook sources can reuse a Hermes session instead of creating a fresh delivery-ID session for every POST. Default behavior remains per-delivery.

This supersedes the stale/conflicting implementation path in #57972 and covers the narrower constant-route proposal in #71570. It intentionally does not address cross-session approval routing (#71571).

Safety and behavior

  • A successfully rendered session_key creates a persistent conversation identity; unresolved templates safely fall back to the existing one-shot delivery session and still auto-close.
  • Persistent (session:<key>) and fallback (delivery:<delivery-id>) identities use disjoint namespaces, so a delivery ID cannot collide with, reuse, or auto-close a persistent conversation.
  • Conversation identity is separate from delivery routing: each delivery retains its own rendered deliver_extra, preventing concurrent turns from redirecting another turn’s response.
  • Persistent deliveries use the gateway FIFO rather than the adapter’s single pending slot, so multiple arrivals keep their own turns, delivery IDs, and response targets without text merging, interrupting, or steering.
  • Multiplexed profiles remain separate even if the route and rendered key match.
  • Documentation covers configuration, fallback, lifecycle, ordering, isolation, and sender-controlled key boundaries.

Validation

python -m pytest -o addopts= -q \
  tests/gateway/test_webhook_integration.py \
  tests/gateway/test_webhook_session_close.py \
  tests/gateway/test_multiplex_busy_input_mode.py \
  tests/gateway/test_webhook*.py
# 85 passed

git diff --check
python -m compileall -q gateway/platforms/webhook.py gateway/run.py

The full tests/gateway suite was also exercised locally. The targeted webhook coverage is green; remaining failures are existing macOS/environmental Discord/AF_UNIX/DNS isolation failures outside this diff.

Credit

This branch preserves the authored commits from Gilles Gameiro and Atroci; the additional commits add profile-isolation, multi-delivery FIFO, and persistent-vs-fallback namespace-collision regression coverage.

@jzOcb

jzOcb commented Aug 20, 2026

Copy link
Copy Markdown
Author

Follow-up fix after independent review: persistent and fallback delivery identities now use disjoint namespaces (session:<key> vs delivery:<id>), so a provider delivery ID can never collide with, reuse, or auto-close a persistent conversation. Added a regression reproducing that collision.

Also re-ran the focused webhook/session suite after this commit: 85 passed.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/webhook Webhook / API server area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 20, 2026
@jzOcb

jzOcb commented Aug 20, 2026

Copy link
Copy Markdown
Author

Superseded by #90589. GitHub did not advance this PR\x27s head after the final namespace-collision commit reached the fork branch; #90589 is the verified current tip, including that regression fix.

@jzOcb

jzOcb commented Aug 20, 2026

Copy link
Copy Markdown
Author

Closing in favor of #90589, which contains the verified final branch head.

@jzOcb jzOcb closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/webhook Webhook / API server sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants