Ensure session reuse is disabled for tooling contexts, include tool config in cache keys, and stabilize tool event merge/routing with expanded bridge tests.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add SessionCache (LRU + TTL, per-API-key scoped) mapping
conversation-prefix hash -> upstream Lingma sessionId.
- Hash only user/system/developer turns so client-side
assistant reformatting doesn't invalidate the key.
- On cache hit: reuse sessionId, send only the latest user
message with isReply=true, and stick the request to the
instance that originally served it.
- LingmaGatewayClient.chat_complete/chat_stream accept
session_id/is_reply and report the real finish.sessionId
via out_meta so we persist what Lingma actually allocated.
- Invalidate cache on non-stream failure; skip writes on
cancelled/partial streams.
- Expose cache stats in /internal/stats and /metrics.
- Configurable via SESSION_REUSE_ENABLED / SESSION_CACHE_MAX_ENTRIES
/ SESSION_CACHE_TTL_SEC (documented in README + .env.example).
Made-with: Cursor