feat(reasoning): opt-in remote endpoints for distillation LLM and embedder (3.9.0) - #202
Merged
Merged
Conversation
…edder reasoning_training gains allow_remote_endpoints (default false, env SURREAL_MEMORY_REASONING_ALLOW_REMOTE). With the flag off nothing changes: non-loopback endpoints still resolve to no namer and no embedder, so reasoning traces never leave the machine. With the flag on, the naming LLM endpoint, the distiller's embedding provider and the stop hook's semantic dedup accept a configured remote http(s) gateway instead of loopback-only servers; non-http(s) schemes stay refused either way and the unconfigured probe fallback stays strict. The naming request now authenticates: SURREAL_MEMORY_LLM_API_KEY is sent as a Bearer header when set, loopback servers keep going keyless with no Authorization header, and a remote endpoint without a key warns at namer build time instead of failing. Bump 3.9.0.
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
reasoning_training.allow_remote_endpoints(defaultfalse, envSURREAL_MEMORY_REASONING_ALLOW_REMOTE): an explicit opt-in that lets the distillation LLM endpoint (pattern naming), the distiller's embedding provider, and the stop hook's semantic dedup use a configured remote http(s) gateway (e.g. LiteLLM) instead of loopback-only servers.SURREAL_MEMORY_LLM_API_KEYis sent asAuthorization: Bearerwhen set; loopback servers keep going keyless with no header; a remote endpoint allowed by the opt-in without a key warns at namer build time instead of failing.to_dict/from_dict/TOML save-load and is overridable via env; emitted in_reasoning_toml_linesafterdistill_llm_endpoint;docs/reference/config.mdregenerated.scripts/pre_ship.py --only versions), CHANGELOG entry.Why
The reasoning pipeline's loopback-only invariant exists so raw model thinking never leaves the machine by accident. That invariant also made it impossible to run the pipeline against a remote OpenAI-compatible gateway — the smem stack is moving off Titan onto k3s (run 010), where embeddings/rerank/LLM are served by LiteLLM over the network. This PR keeps the default byte-for-byte identical (opt-in off ⇒ no remote endpoint is ever used, exactly as before) while letting an operator widen the gate deliberately. The opt-in widens where traces may be sent, never what counts as a URL: non-http(s) schemes are refused either way, and the unconfigured probe fallback stays loopback-only regardless of the flag.
Test plan
pytest tests/ -m "not stress" -n auto— 7334 passed, 4 skipped, 1 xfailed (new tests intest_reasoning_naming.py,test_reasoning_distiller.py,test_stop_hook.py,test_unified_config.py; TDD RED→GREEN)ruff check src/ tests/clean;ruff formatcleanmypy src/ --ignore-missing-importsclean (354 files)python scripts/pre_ship.py --only versions— every version-bearing file at 3.9.0python scripts/gen_config_docs.py --check— reference up-to-datesmem doctorgreen against the existing stack (default config ⇒ behavior unchanged)Verified by
@acidkill