1jehuang / 1jehuang/jcode

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

Open
#679 13 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no enhancement priority: medium triage: needs-decision
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 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.