Skip to content

feat: Add EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES env var#58

Open
n0n0x wants to merge 3 commits intoobra:mainfrom
n0n0x:feat/claude-code-setting-sources
Open

feat: Add EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES env var#58
n0n0x wants to merge 3 commits intoobra:mainfrom
n0n0x:feat/claude-code-setting-sources

Conversation

@n0n0x
Copy link

@n0n0x n0n0x commented Feb 5, 2026

Add EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES environment variable to allow the summarizer to load Claude Code configuration when making SDK calls (needed for awsCredentialExport for example).

The default is undefined (no settings loaded), which preserves existing behavior. Users must explicitly set EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES=user (or project, or both) to enable loading settings.

This setting also enables a lot of functionalities that might alter the summarization output quality. As it will cause the SDK to read the ~/.claude/CLAUDE.md, ~/.claude/agents/*.md, ~/.claude/skills/*/SKILL.md, ~/.claude/commands/*.md and MCP servers from ~/.claude.json.

Here's a list:

  │  Value  │        Settings File        │                                                                    Also Loads                                                                    │
  ├─────────┼─────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ user    │ ~/.claude/settings.json     │ ~/.claude/CLAUDE.md, ~/.claude/agents/*.md, ~/.claude/skills/*/SKILL.md, ~/.claude/commands/*.md, MCP servers from ~/.claude.json                │
  ├─────────┼─────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ project │ .claude/settings.json       │ CLAUDE.md / .claude/CLAUDE.md at project root, .claude/agents/*.md, .claude/skills/*/SKILL.md, .claude/commands/*.md, MCP servers from .mcp.json │
  ├─────────┼─────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ local   │ .claude/settings.local.json │ CLAUDE.local.md                                                                                                                                  │
  └─────────┴─────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  Default (omitted/undefined): SDK isolation mode — nothing from the filesystem is loaded.

Sources:
https://platform.claude.com/docs/en/agent-sdk/migration-guide#settings-sources-no-longer-loaded-by-default
https://platform.claude.com/docs/en/agent-sdk/typescript#setting-source

Motivation and Context

I use claude code with bedrock and explicitly make use of awsCredentialExport setting to load AWS credentials. Episodic memory summarization was not working for me and filling my project's conversation history with the summarization prompt and an API Key Error. I am adding EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES so the SDK loads the AWs credentials from awsCredentialExport (source)

How Has This Been Tested?

  • Tested locally with ./cli/episodic-memory.js sync command
  • Verified SDK calls succeed with settingSources passed
  • Confirmed default behavior (no env var set) maintains backward compatibility (breaks in my case)

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Usage:

EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES=user episodic-memory sync

The env var accepts a comma-separated list of setting sources (e.g., `user, project`). When set to user, the SDK will load settings from the user's Claude Code configuration file (`~/.claude/settings.json`)

Summary by CodeRabbit

  • Chores
    • Updated Claude API configuration loading to support additional settings sources via environment variable configuration.

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES and a helper getSettingSources() to parse it; passes the parsed settingSources into Claude API calls from callClaude. getApiEnv() docs updated and README documents the new environment variable and its effects.

Changes

Cohort / File(s) Summary
Claude configuration code
src/summarizer.ts
Add getSettingSources() to parse EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES; include settingSources in options when invoking Claude via callClaude; preserve existing model selection, resume, systemPrompt, and fallback behavior.
Documentation
README.md
Document new EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES env var, list possible values (user, project, local), provide examples and guidance, and add "What's Affected" notes about loaded settings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I nibbled env vars, found a tasty clue,
Split commas like carrots, crisp and true,
I whispered to Claude where settings dwell,
Now code hops smarter — isn't that swell? 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding the EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES environment variable. It is concise, specific, and clearly summarizes the primary addition to the codebase.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Allows loading Claude Code configuration when making SDK calls for
summarization. This enables the SDK to pick up user settings like
custom API configurations.

Usage: EPISODIC_MEMORY_CLAUDE_CODE_SETTING_SOURCES=user

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@n0n0x n0n0x force-pushed the feat/claude-code-setting-sources branch from 259f57b to 7a36c14 Compare February 5, 2026 11:48
n0n0x and others added 2 commits February 6, 2026 11:12
Add table of accepted values (user, project, local) with settings file
paths, descriptions, and usage examples for the setting sources env var.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Recommend leaving empty or using 'user' only, warn that project/local
sources load CLAUDE.md and MCP servers which can affect summary quality.

Co-Authored-By: Claude Opus 4.6 (1M context) <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