Skip to content

fix: improve robustness of memory writer, embeddings, and search handler#29

Open
ZenAlexa wants to merge 2 commits intomainfrom
zenalexa/fix-high-priority-issues
Open

fix: improve robustness of memory writer, embeddings, and search handler#29
ZenAlexa wants to merge 2 commits intomainfrom
zenalexa/fix-high-priority-issues

Conversation

@ZenAlexa
Copy link
Collaborator

Summary

This PR addresses several high-priority engineering issues found during code review:

  • MemoryWriterConfig: Add default model value (openai/gpt-4o-mini) so SQRL_STRONG_MODEL env var is optional instead of causing immediate crash
  • Embeddings: Add retry logic with exponential backoff for transient API failures (rate limits, timeouts, connection errors)
  • SearchMemoriesHandler: Add proper warning logging and response metadata when search is not configured

Changes

src/sqrl/memory_writer/writer.py

  • Add DEFAULT_STRONG_MODEL = "openai/gpt-4o-mini" constant
  • Add ConfigurationError exception class
  • Make SQRL_STRONG_MODEL optional (uses default if not set)
  • Add from_explicit() class method for programmatic config
  • Add validation for SQRL_MAX_MEMORIES_PER_EPISODE env var

src/sqrl/embeddings.py

  • Add retry logic with configurable attempts (default: 3)
  • Add exponential backoff between retries
  • Add _is_retryable_error() helper to identify transient failures
  • New env vars: SQRL_EMBEDDING_MAX_RETRIES, SQRL_EMBEDDING_RETRY_DELAY, SQRL_EMBEDDING_RETRY_BACKOFF

src/sqrl/ipc/handlers.py

  • SearchMemoriesHandler now logs warning (once) when no search_fn configured
  • Response includes search_backend and warning metadata fields

Test plan

  • All existing tests pass (64 tests)
  • Python syntax validation passes
  • IPC handler tests (20 tests) pass
  • Embedding tests (14 tests) pass
  • CR-Memory tests (23 tests) pass

🤖 Generated with Claude Code

ZenAlexa and others added 2 commits December 16, 2025 20:49
- Add default model (openai/gpt-4o-mini) to MemoryWriterConfig, making
  SQRL_STRONG_MODEL env var optional instead of required
- Add ConfigurationError exception class for better error handling
- Add from_explicit() class method for explicit config creation
- Add retry logic with exponential backoff to embedding service
- Add _is_retryable_error() helper to identify transient failures
- Add configurable retry settings via env vars (SQRL_EMBEDDING_MAX_RETRIES,
  SQRL_EMBEDDING_RETRY_DELAY, SQRL_EMBEDDING_RETRY_BACKOFF)
- Improve SearchMemoriesHandler with proper warning when no search_fn
  configured, and add metadata to response (search_backend, warning)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…Router)

Change default model from openai/gpt-4o-mini to
openrouter/deepseek/deepseek-r1-distill-qwen-32b which is:
- Free on OpenRouter (no API cost)
- 64K context window
- Strong reasoning capabilities (state-of-art for dense models)

Add RECOMMENDED_MODELS dict documenting best models by use case:
- free_best: deepseek-r1-distill-qwen-32b (free, strong reasoning)
- free_long_context: deepseek-chat-v2.5 (free, 128K)
- budget: deepseek-r1-0528-qwen3-8b ($0.02/$0.10 per M tokens)
- json_best: claude-3.5-haiku ($0.80/$4, best structured output)
- reasoning: deepseek-r1 ($0.30/$1.20, o1-level reasoning)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant