Repository navigation
context-graph: propagate resolved Memgraph/LLM config to the reconcile subprocess - #253
Merged
Merged
Conversation
…e subprocess SessionsGraphConnector spawns a detached `sessions-graph reconcile` subprocess on SESSION_END for auto-reconciliation, via a bare subprocess.Popen with no explicit env=. Per ADR 0002, the parent hook process resolves Memgraph credentials from config.toml purely as constructor kwargs, never writing them to os.environ, so the spawned subprocess silently fell back to Memgraph defaults and had no path at all to an LLM API key (LightRAG needs OPENAI_API_KEY/ANTHROPIC_API_KEY). Extend the config-file resolution (agent_context_graph.adapters._identity) with an [llm] section and resolve_llm_env(), and have the spawn site build an explicit env for the child by overlaying resolved Memgraph + LLM config onto ambient os.environ. sessions-graph reconcile also does the same best-effort fill-in at startup so standalone/cron invocations behave the same way.
This was referenced Aug 11, 2026
…context-graph-reconcile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SessionsGraphConnector._spawn_reconciliationspawns a detachedsessions-graph reconcilesubprocess onSESSION_END(whenauto_reconcileis on) via a baresubprocess.Popenwith no explicitenv=. Per ADR 0002, the parent hook process resolves Memgraph credentials from~/.config/context-graph/config.tomlpurely as constructor kwargs — never writing them toos.environ— so the spawned subprocess silently fell back to Memgraph defaults, and had no path at all to an LLM API key (LightRAG's defaultllm_model_funcreadsOPENAI_API_KEYfromos.environand raises if it's missing).[llm]section (openai_api_key,anthropic_api_key) andresolve_llm_env(), mirroringresolve_memgraph_env().bootstrapcapturesOPENAI_API_KEY/ANTHROPIC_API_KEYfrom the environment into the config file the same way it already does for Memgraph credentials._spawn_reconciliationnow builds an explicitenv=for the child: ambientos.environoverlaid with non-empty resolved Memgraph + LLM values, so the detached subprocess gets what the hook process resolved regardless of the harness's own ambient environment.sessions-graph reconcile(run standalone via cron/manually) does the same best-effort fill-in at startup via an optional import, so it behaves consistently whether spawned by the hook or invoked directly.agent-context-graph config set/get/showanddoctorgain the newllm.*keys;command-hooks.mddocuments them.Test plan
uv run --package agent-context-graph --extra test pytest tests/ -v— 83 passeduv run --package sessions-graph --extra test --extra agent-context-graph --extra reconciliation pytest tests/ -v— 50 passed, 1 skipped (live-Memgraph e2e test)ruff check/ruff format --checkon changed filesagent-context-graph config set llm.openai_api_key,config show,config get, anddoctorall reflect the new[llm]section correctly in an isolated$HOME