Support separate API key for background agent work

Add agent_api_key config option. When set, all LLM calls (experience-mine,
fact-mine, consolidation, knowledge-loop, digest) use this key via
ANTHROPIC_API_KEY env var on the claude subprocess, keeping daemon token
usage on a separate quota from interactive sessions.

Config: {"config": {"agent_api_key": "sk-ant-..."}}

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kent Overstreet 2026-03-05 22:28:39 -05:00
parent aa24c40a1c
commit 2f3ac1ecb6
2 changed files with 18 additions and 6 deletions

View file

@ -49,6 +49,9 @@ pub struct Config {
pub journal_max: usize,
/// Ordered context groups for session-start loading.
pub context_groups: Vec<ContextGroup>,
/// Separate API key for background agent work (daemon jobs).
/// If set, passed as ANTHROPIC_API_KEY to model calls.
pub agent_api_key: Option<String>,
}
impl Default for Config {
@ -69,6 +72,7 @@ impl Default for Config {
source: ContextSource::Store,
},
],
agent_api_key: None,
}
}
}
@ -122,6 +126,9 @@ impl Config {
if let Some(m) = cfg.get("journal_max").and_then(|v| v.as_u64()) {
config.journal_max = m as usize;
}
if let Some(s) = cfg.get("agent_api_key").and_then(|v| v.as_str()) {
config.agent_api_key = Some(s.to_string());
}
continue;
}