Skip to content

[improvement] Configurable memory sidecar backend (auto/openai/claude/provider) #679

Description

@alecuba16

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 via complete_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 - new memory_sidecar_backend field in AgentsConfig
  • crates/jcode-base/src/sidecar.rs - backend selection logic respects config override
  • crates/jcode-base/src/config/env_overrides.rs - JCODE_MEMORY_SIDECAR_BACKEND env var
  • crates/jcode-base/src/config/default_file.rs - documented in default config template
  • crates/jcode-base/src/config/display_summary.rs - shows backend in config summary
  • README.md - new ### Memory sidecar backend section with config table and examples

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: noNeeds your brain: a product/design decision is required before anyone acts.enhancementNew feature or requestpriority: mediumP2 - normal prioritytriage: needs-decisionNeeds maintainer decision/design thought

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions