[improvement] Configurable memory sidecar backend (auto/openai/claude/provider)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Memory sidecar backend is hardcoded to OpenAI/Claude, ignoring user's active provider
Problem
The memory sidecar auto-selects its LLM backend with this priority: OpenAI (if Codex credentials exist) > Claude > active provider. When Codex OAuth tokens are present but expired, the sidecar picks the OpenAI backend and every call fails with "OpenAI SSE error: unknown error". Memory extraction stops silently. No new memories are created. The user gets no warning.
This happens on any non-OpenAI provider (custom OpenAI-compatible gateways, Copilot, Gemini, Cursor, etc.) because the sidecar prefers stale Codex tokens over the user's actual working provider.
Root cause
In crates/jcode-base/src/sidecar.rs, auto_select_backend() checks auth::codex::load_credentials().is_ok() first. If Codex tokens exist (even expired), it picks OpenAI. The memory_model config only routes to OpenAI or Claude models. Any other model value falls back to auto_select_backend(), which still picks OpenAI.
There is no way to force the sidecar to use the active provider when Codex or Claude credentials exist.
Solution
Add a memory_sidecar_backend config option to [agents] in config.toml:
"auto"(default): current behavior, auto-select OpenAI > Claude > provider"openai": force OpenAI Responses API"claude": force Claude Messages API"provider": dispatch through the active agent provider viacomplete_simple
This lets users on custom gateways (or any non-OpenAI/Claude provider) use their own model for memory extraction and relevance judging.
Config example
[agents]
memory_sidecar_backend = "provider"
Env override: JCODE_MEMORY_SIDECAR_BACKEND
Implementation
Available at: https://github.com/alecuba16/jcode/tree/feature/memory-sidecar-provider
Files changed (6 files, +132/-18):
crates/jcode-config-types/src/lib.rs- newmemory_sidecar_backendfield inAgentsConfigcrates/jcode-base/src/sidecar.rs- backend selection logic respects config overridecrates/jcode-base/src/config/env_overrides.rs-JCODE_MEMORY_SIDECAR_BACKENDenv varcrates/jcode-base/src/config/default_file.rs- documented in default config templatecrates/jcode-base/src/config/display_summary.rs- shows backend in config summaryREADME.md- new### Memory sidecar backendsection with config table and examples
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with crates/jcode-base/src/sidecar.rs and trace how AgentsConfig is loaded and how environment overrides are applied. Review the six files listed in the issue, then verify that the four backend values, the JCODE_MEMORY_SIDECAR_BACKEND override, the default config, summary output, and README documentation are consistent and support provider dispatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100