Skip to content

Fix memU memorize failing silently on Bedrock provider - #36

Merged
pufit merged 1 commit into
ClickHouse:mainfrom
groeneai:fix/bedrock-memorize
Apr 7, 2026
Merged

Fix memU memorize failing silently on Bedrock provider#36
pufit merged 1 commit into
ClickHouse:mainfrom
groeneai:fix/bedrock-memorize

Conversation

@groeneai

@groeneai groeneai commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When the Nerve provider is Bedrock (AWS), memorize silently fails with "Connection error" because memU's OpenAISDKClient requires base_url + api_key — both empty under Bedrock (IAM auth)
  • Adds _BedrockLLMClient adapter wrapping AsyncAnthropicBedrock that implements memU's LLM client interface (.chat(), .summarize(), .embed())
  • After MemoryService init, placeholder OpenAISDKClient instances are replaced with real Bedrock-backed clients
  • All 6 LLM client code paths updated: initialize(), _inject_bedrock_clients(), _make_bedrock_client(), _instrument_llm_timeouts(), _probe_api_health(), _reset_llm_clients()

Test plan

  • All 326 existing tests pass
  • Restarted nerve, confirmed Bedrock clients injected (logs: Injected Bedrock LLM client for profile 'default/fast/memorize')
  • memorize call succeeds end-to-end (was: "Failed to memorize", now: "Memorized: ...")
  • memory_recall returns the newly memorized item
  • LLM extraction calls complete in 2-4s via Bedrock (visible in logs)

When the provider is Bedrock (AWS), anthropic_api_base_url and
effective_api_key are both empty — Bedrock uses IAM auth, not API keys.
memU's OpenAISDKClient requires both, so every memorize call failed with
"Connection error" while recall (local SQLite + embeddings) still worked.

Add a _BedrockLLMClient adapter that wraps AsyncAnthropicBedrock and
implements memU's LLM client interface (.chat(), .summarize(), .embed()).
After MemoryService init, placeholder OpenAISDKClient instances are
replaced with real Bedrock-backed clients.

All 6 code paths that touch LLM clients are updated:
- initialize() — detect Bedrock, use placeholder creds for validation
- _inject_bedrock_clients() — replace placeholders post-init
- _make_bedrock_client() — factory using Nerve's provider config
- _instrument_llm_timeouts() — skip httpx Layer 1 for Bedrock
- _probe_api_health() — use adapter's chat() for health checks
- _reset_llm_clients() — re-inject Bedrock clients after eviction

Co-Authored-By: Claude Opus 4.6 <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.

2 participants