Skip to content

Conversation

@JiehoonKwak
Copy link

Problem

OpenRouter/Gemini APIs are stateless—they don't return session IDs. This breaks the FK constraint, causing observations to fail silently.

Fixes #591

Fix

Generate synthetic memorySessionId before first API call. 21 lines across 3 files.

Testing

  • Verified MEMORY_ID_GENERATED in logs
  • Observations store correctly
  • No regressions

OpenRouter/Gemini APIs don't return session IDs.
Generate synthetic IDs to satisfy FK constraint.
- Add setting to SettingsDefaults interface and defaults (false)
- Add to settingKeys and booleanSettings arrays in SettingsRoutes
- Add early return check in updateFolderClaudeMdFiles()

Folder CLAUDE.md generation now disabled by default.
Equivalent to PR thedotmack#672.
@denjzs
Copy link

denjzs commented Jan 15, 2026

LGTM... @thedotmack can approve?

RPirruccio added a commit to RPirruccio/claude-mem that referenced this pull request Jan 17, 2026
…r, Gemini)

OpenRouter and Gemini are stateless APIs that do not return session IDs.
This causes a race condition where hooks fire before memorySessionId is set,
leading to NULL foreign keys and crash loops.

Generate synthetic IDs immediately after API key validation to ensure
memorySessionId is always available before any database operations.

Pattern: {provider}-{contentSessionId}-{timestamp}

Fixes the root cause of issue thedotmack#591 and implements PR thedotmack#615 approach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenRouter agent fails to capture memorySessionId for sessions with empty prompt history

2 participants