Skip to content

Fix/release polish#1

Merged
jackmannx merged 7 commits into
mainfrom
fix/release-polish
Jun 28, 2026
Merged

Fix/release polish#1
jackmannx merged 7 commits into
mainfrom
fix/release-polish

Conversation

@jackmannx

Copy link
Copy Markdown
Owner

Summary

This PR prepares Sawtooth Memory for a 0.2.1 release by fixing several usability bugs, tightening runtime diagnostics, and aligning docs/examples with the current API.

  • Auto-route background_model — Setting background_model="gpt-4o-mini" (or other cloud model names) now automatically configures the correct CloudConfig backend and resolves API keys from environment variables. Local model names still route to Ollama. Includes infer_cloud_provider() / resolve_cloud_api_key() helpers and a new tests/test_config.py suite.
  • Multi-agent pool sync on start()ContextManager.start() now calls _sync_pool_state_from_storage() when pool_id is configured, so pooled agents load shared L1.5/L2 state immediately instead of only after the first compression cycle.
  • Improved health_check() — Adds compression backend reachability checks via new OllamaCompressor.ping() and CloudCompressor.ping() methods. Reports degraded when Ollama is unreachable or cloud credentials are missing.
  • Optional Redis dependency — Moves redis out of core dependencies into sawtooth-memory[redis]. Adds [langchain] and [all] extras. RedisStorageAdapter raises a clear ImportError with install guidance when redis is not installed.
  • Version bump to 0.2.0 — Syncs __version__ in sawtooth_memory/__init__.py with pyproject.toml.
  • Documentation & examples — Fixes README quickstart (build_prompt(), explain_prompt()), adds explicit CloudConfig example, updates roadmap, documents V2 background_model auto-routing in DOCUMENTATION.md, and rewrites examples/basic_agent.py to match the current API.

Commits

Commit Description
6760397 feat(config): auto-route background_model to cloud or Ollama backends
a1efc0a fix(middleware): sync pool state on start and improve health checks
c081a35 chore: sync package version to 0.2.0
0439baa chore(deps): make redis optional and add langchain extra
f063bb0 docs: fix README quickstart, API names, and roadmap
3681005 docs: document V2 background_model auto-routing
86bdaea docs(examples): update basic_agent to use build_prompt

Test plan

  • pytest — all 195 tests pass locally
  • tests/test_config.py — cloud provider inference and background_model auto-routing (with/without API keys)
  • tests/test_middleware.pyhealth_check() healthy and degraded paths
  • tests/test_multi_agent_pooling.py — pool state synced on start()
  • tests/test_sync_wrapper.py — sync wrapper health check with mocked compressor ping
  • CI passes on this branch (pip install ".[dev,langgraph,redis]")
  • Manual: background_model="gpt-4o-mini" with OPENAI_API_KEY set creates cloud backend
  • Manual: background_model="phi4-mini:latest" routes to Ollama
  • Manual: pip install sawtooth-memory (no redis) — core install works; redis adapter fails with clear message

jackmannx and others added 7 commits June 28, 2026 19:03
Cloud model names now resolve to CloudConfig via environment API keys,
with a clear error when credentials are missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pool L1.5/L2 hydrates during start(), and health_check now reports
backend routing plus Ollama reachability or cloud credential status.

Co-authored-by: Cursor <cursoragent@cursor.com>
Align __version__ with the pyproject.toml release version.

Co-authored-by: Cursor <cursoragent@cursor.com>
Redis moves behind [redis], langchain-core gets a dedicated extra,
and CI installs redis for adapter tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Correct build_prompt and explain_prompt usage, document env-based cloud
routing, optional install extras, and current Phase 3 status.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add shorthand configuration example to the official documentation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove manual entity injection and demonstrate the real prompt pipeline.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jackmannx jackmannx merged commit 60f3856 into main Jun 28, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86bdaeaaa0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sawtooth_memory/config.py

# Cloud model name prefixes used by ``background_model`` auto-routing.
_CLOUD_MODEL_PREFIXES: dict[Provider, tuple[str, ...]] = {
Provider.OPENAI: ("gpt-", "o1", "o3", "chatgpt-"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route o4 models through the OpenAI backend

When a user sets background_model="o4-mini" (or another OpenAI o4-* model) with OPENAI_API_KEY, infer_cloud_provider() returns None because this table only includes o1 and o3. The validator then creates an OllamaConfig, so the context manager tries to call local Ollama instead of CloudCompressor, which makes auto-routing fail for supported OpenAI o-series models outside the hard-coded prefixes.

Useful? React with 👍 / 👎.

Comment on lines +231 to +232
if self._config.pool_id:
await self._sync_pool_state_from_storage()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reattach the entity callback after startup pool sync

With pool_id and events enabled, this new startup sync replaces self._state.l1_5_entities with a freshly loaded EntityLedger; the event callback installed in __init__ stays on the old ledger. Any later compression upserts into the hydrated ledger will update memory, but will not emit l1_5.entity_anchored events or journal entries, so explainability timestamps/origins are lost for pooled agents. Reattach the callback after hydrating pool entities.

Useful? React with 👍 / 👎.

@jackmannx jackmannx deleted the fix/release-polish branch June 28, 2026 12:52
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