Skip to content

feat(plugin): add "Sign in with ChatGPT" LLM provider - #2617

Open
jeff-ang92 wants to merge 3 commits into
MemTensor:mainfrom
jeff-ang92:feat/plugin-chatgpt-provider
Open

jeff-ang92 wants to merge 3 commits into
MemTensor:mainfrom
jeff-ang92:feat/plugin-chatgpt-provider

Conversation

@jeff-ang92

Copy link
Copy Markdown

Description

Adds a chatgpt LLM provider to apps/memos-local-plugin so MemOS can run its summarizer and skill-evolver calls on the user's own ChatGPT plan, using OpenAI's Sign in with ChatGPT for open-source and locally hosted apps. No API key is needed for the ChatGPT path. If ChatGPT is unavailable (usage limit, not eligible, signed out, network), the call falls back to the OpenAI-compatible settings already in the same config block (for example OpenRouter), so nothing stops working.

How it works

  • core/llm/chatgpt-auth.ts — OAuth authorization code + PKCE (S256) with a loopback callback on 127.0.0.1. First sign-in registers through dynamic_agent_client and saves the issued client_id. Scopes include offline_access and chatgpt.tokens.use.direct. The ID token is verified (RS256 against OpenAI's JWKS, plus iss/aud/exp/nonce). Tokens are stored owner-only (POSIX chmod 600, Windows icacls) at ~/.config/memos-local/chatgpt-oauth.json (override with MEMOS_CHATGPT_TOKEN_FILE or chatgpt.tokenFile). Refresh runs under a cross-process file lock, so several MemOS processes rotate the refresh token only once. Terminal refresh errors clear the tokens but keep the client_id. Transient errors leave the file untouched. A stable opaque ext_agent_host_id (urn:uuid:<v4>) is created once before sign-in. Nothing logs or throws a token.
  • core/llm/providers/chatgpt.ts — calls POST /v1/responses with store: false and stream: true, and counts a call as successful only on response.completed. System messages go into instructions. temperature and max_output_tokens are not sent, because this route does not accept them. JSON mode asks for text.format: json_object; if the route rejects it, the provider drops it once and relies on the facade's JSON hint and parser. A 401 triggers one forced refresh and retry. 5xx errors retry with bounded backoff that respects the call deadline. A usage limit pauses ChatGPT for 30 minutes, "not eligible" for 6 hours and auth failures for 10 minutes; calls in that window go straight to the fallback. stream() falls back only if no text has reached the caller yet. With chatgpt.fallback: false, errors map to llm_rate_limited, llm_timeout or llm_unavailable.
  • scripts/chatgpt-login.mjs — node scripts/chatgpt-login.mjs signs in; --status shows sign-in state; --models lists the plan's models. It never prints tokens.

Wiring

  • core/llm/types.ts, client.ts, index.ts: new chatgpt provider name, ChatGptProviderConfig, makeProviderFor("chatgpt") and exports.
  • core/config/schema.ts: provider: chatgpt plus an optional chatgpt: block (model, fallback, tokenFile, reasoningEffort) on llm and skillEvolver.
  • core/pipeline/memory-core.ts: passes skillEvolver.chatgpt through. A chatgpt skill evolver with a blank endpoint or apiKey reuses the main llm block's for its fallback; other providers are unchanged.
  • core/logger/channels.ts: llm.chatgpt channel.
  • server/routes/models.ts: the Settings "Test" button no longer throws "unsupported chat provider" for chatgpt. As with host and bedrock, there is nothing to probe from the form.
  • viewer: chatgpt added to the Summarizer and Skill Evolver provider dropdowns, with a short hint (EN and ZH) explaining sign-in and the fallback fields.
  • package.json files: ships scripts/chatgpt-login.mjs.
  • Docs: core/llm/README.md provider table and docs/CONFIG-ADVANCED.md section.

Config example:

llm:
  provider: chatgpt
  endpoint: https://openrouter.ai/api/v1   # fallback
  model: google/gemini-2.5-flash-lite      # fallback model
  apiKey: sk-or-v1-...                     # fallback key
  chatgpt:
    model: ""          # slug from `chatgpt-login.mjs --models`; blank = provider default
    fallback: true

No new dependencies. Existing providers and configs are unaffected unless provider: chatgpt is chosen.

Related Issue (Required): None (new feature, no prior issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

  • Unit Test

  • Test Script Or Test Steps (please provide)

  • New: tests/unit/llm/chatgpt-provider.test.ts (14 tests) covers the request body, streaming, response.completed gating, response.failed / response.incomplete / cut streams, the 401 refresh-and-retry, bounded 503 retry, the usage-limit pause and its expiry, JSON-mode downgrade, the real LlmClient.completeJson facade, stream() fallback before the first delta, the not-signed-in fallback, makeProviderFor and config-schema acceptance.

  • New: tests/unit/llm/chatgpt-auth.test.ts (8 tests) covers refresh near expiry with two parallel callers (one refresh, both tokens rotated), no network for a fresh token, invalid_grant clearing tokens while keeping client_id, transient errors leaving the file untouched, the missing file, the missing plan scope, and host-ID creation and reuse with format checks.

  • Extended: tests/unit/pipeline/bootstrap-llm-config.test.ts (+2) checks that skillEvolver.chatgpt is passed through, and that the main llm endpoint and key are inherited only for provider: chatgpt.

  • All use mocked fetch and SSE streams and synthetic token files. No network, no real credentials.

  • npm run lint (tsc --noEmit) and the viewer type check (tsc -p tsconfig.viewer.json --noEmit) are clean.

  • vitest run tests/unit on Windows: 1614 passed, 43 failed, 12 skipped. Upstream main at 3a16e5f on the same machine gives 1590 passed, 43 failed, 12 skipped. The 43 failures are identical before and after this change (Windows-specific path, install-script and local-embedding tests).

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

🤖 Generated with Claude Code

Adds a `chatgpt` provider to memos-local-plugin that runs summarizer and
skill-evolver calls on the user's ChatGPT plan via OpenAI's Sign in with
ChatGPT (OAuth PKCE, Responses API with store:false and stream:true).
Falls back to the block's openai_compatible settings on usage limits,
eligibility, auth or network failures.

- core/llm/chatgpt-auth.ts: PKCE sign-in, ID token verification,
  owner-only token storage, lock-guarded refresh, stable host ID
- core/llm/providers/chatgpt.ts: Responses streaming, 401 refresh,
  bounded 5xx retry, pause windows, fallback
- scripts/chatgpt-login.mjs: sign in, --status, --models
- config schema, client registry, skillEvolver wiring, log channel,
  model-test route, viewer dropdowns, docs, vitest coverage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Memtensor-AI Memtensor-AI added area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Nov 11, 2026
@Memtensor-AI

Memtensor-AI commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2617
Task: 1a90db6dcd249bc3
Base: main
Head: feat/plugin-chatgpt-provider
Head SHA: 7543d33c235138096a81d962d445844179dddda4

🔍 OpenCodeReview found 20 issue(s) in this PR.

⚠️ Review warnings (7)

  • bounded analysis finalized with explicit task_done after reviewing all group files
  • bounded analysis finalized with explicit task_done after reviewing all group files
  • bounded analysis finalized with explicit task_done after reviewing all group files
  • bounded analysis finalized with explicit task_done after reviewing all group files
  • bounded analysis finalized with explicit task_done after reviewing all group files
  • bounded analysis finalized with explicit task_done after reviewing all group files
  • Filtered 1 low-confidence OCR finding(s) before posting/fix-loop.

1. apps/memos-local-plugin/core/pipeline/memory-core.ts (L167-L172)

endpoint / apiKey are taken raw (no .trim()), so a whitespace-only value in config.yaml (e.g. endpoint: " ") is treated as "configured": the inheritance branch is skipped and the ChatGPT provider gets a blank-but-truthy endpoint instead of the main llm pair. Trim both before the check (and return the trimmed values) to match how the caller already trims model/provider.

Also note the slot is only built when model is non-empty (see the if (evolverModel && evolverProvider) guard above), while chatgpt.model documents "Blank = provider default" — a provider: chatgpt slot with a blank top-level model is silently ignored and falls back to the main llm client. Worth documenting or relaxing the guard when provider === "chatgpt".

💡 Suggested Change

Before:

  const endpoint = slot?.endpoint ?? "";
  const apiKey = slot?.apiKey ?? "";
  const inherit =
    provider === "chatgpt" &&
    !endpoint &&
    !apiKey &&

After:

  const endpoint = (slot?.endpoint ?? "").trim();
  const apiKey = (slot?.apiKey ?? "").trim();
  const inherit =
    provider === "chatgpt" &&
    !endpoint &&
    !apiKey &&

2. apps/memos-local-plugin/server/routes/models.ts (L374-L376)

tokenFile comes straight from the request body and is handed to getAccessToken(), which does real filesystem work on that path: it reads it as the credential file, and — when the token is near expiry / when refresh happens — withFileLock() creates <path>.lock and writeCredentials() writes a temp file + rename()s over it (plus restrictToOwner() chmod). So this endpoint lets any authenticated API caller point the plugin's credential read/refresh at an arbitrary path (e.g. /etc/hosts, a path in another user's home) instead of the path configured on the server. Prefer resolving the token file from the saved config on disk (same place the provider reads it from) and only accepting the request field as a fallback, or at least reject paths outside the configured/default location. Also note that non-ENOENT fs errors (EACCES, EISDIR, …) are re-thrown verbatim by readCredentials() and surfaced to the client as error.message, leaking the server-side absolute path — wrap them in a generic message for this route.


3. apps/memos-local-plugin/server/routes/models.ts (L374)

Two concerns with this credential file resolution:

  1. resolveSecrets() hydrates endpoint / apiKey from the saved config for the other providers, but not chatgpt.tokenFile. Any client that posts provider: "chatgpt" without chatgpt.tokenFile (or with the field missing after a failed config load) silently probes the default path, so a user who configured llm.chatgpt.tokenFile / skillEvolver.chatgpt.tokenFile gets a false "not signed in" result.
  2. tokenFile comes straight from the request body and getAccessToken both reads it and — when the token is near expiry — writes the refreshed credentials plus a <file>.lock back to that same path. Since the server can be bound to a non-loopback host, validate that the path is absolute/~-free (or only accept the value from the saved config) instead of using an arbitrary request-supplied path.

4. apps/memos-local-plugin/core/config/defaults.ts (L65-L66)

reasoningEffort is documented in ChatGptSchema but is missing from all three chatgpt default objects. resolveConfig() feeds DEFAULT_CONFIG into pruneUnknown() as the known-key tree (core/config/index.ts:90, 325), so a user config like llm: { provider: chatgpt, chatgpt: { reasoningEffort: low } } now logs

unknown config key 'llm.chatgpt.reasoningEffort' (kept as-is for forward compatibility)

on every startup, even though the value is valid and honored. The new test "loading a chatgpt block raises no 'unknown config key' warning" (tests/unit/llm/chatgpt-provider.test.ts:412) only covers model/fallback/tokenFile, so it doesn't catch this. Either extend the known-key tree with the schema's optional keys (carefully, since writer.ts seeds new files from stringifyYaml(DEFAULT_CONFIG)) or make pruneUnknown() tolerate keys that the TypeBox schema declares as optional, and add a reasoningEffort case to that test.


5. apps/memos-local-plugin/core/llm/client.ts (L765-L766)

For the chatgpt provider the reported model stays config.model, which is by design the OpenAI-compatible fallback model (llm.model), not the model actually used on the ChatGPT plan (config.chatgpt.model, defaulted in providers/chatgpt.ts). As a result every LlmCompletion.model, onStatus/onError row and completeJson().model will show the fallback slug (or "" for the common chatgpt-only setup where llm.model is blank), and completeJson().provider = "chatgpt" will be paired with an unrelated model name. Consider resolving the display model once, e.g. const displayModel = config.provider === "chatgpt" ? (config.chatgpt?.model || config.model) : config.model;, and using it for completion.model / status notifications so the Overview and Logs views reflect what actually served the call.


6. apps/memos-local-plugin/core/config/schema.ts (L115)

ReasoningEffortSchema was written for the OpenRouter/openai_compatible path (reasoning.effort), but reusing it here also validates chatgpt.reasoningEffort. Values like xhigh / max (and possibly minimal / none) are not accepted by the Responses API reasoning.effort field, so a user config with e.g. chatgpt: { reasoningEffort: xhigh } passes validation and then every request returns a 400 that ChatGptLlmProvider silently routes to the OpenAI-compatible fallback — the user sees no error but ChatGPT is never used. Consider narrowing the list for the ChatGPT field (or validating/normalizing it at request time) so invalid values fail fast at config load instead of degrading silently.


7. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L221-L224)

Stale-lock removal is a TOCTOU race: a peer can delete the stale lock and create a fresh one between this stat and fsp.rm. The rm then deletes the peer's live lock, so two processes enter refreshCredentials with the same rotating refresh token. One gets invalid_grant, which is persisted as reauth_required with empty tokens — wiping a valid sign-in. Re-verify the lock (mtime/content) immediately before deleting it, or use an atomic rename/lock library.

💡 Suggested Change

Before:

      if (Date.now() - st.mtimeMs > LOCK_STALE_MS) {
        await fsp.rm(lock, { force: true });
        continue;
      }

After:

      if (Date.now() - st.mtimeMs > LOCK_STALE_MS) {
        // Re-check right before deleting: a peer may have replaced this stale
        // lock in the meantime, and removing its fresh lock would let two
        // processes refresh (and rotate) the same token concurrently.
        const again = await fsp.stat(lock).catch(() => null);
        if (again && again.mtimeMs === st.mtimeMs) {
          await fsp.rm(lock, { force: true });
        }
        continue;
      }

8. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L59)

LOCK_WAIT_MS (20s) is shorter than the refresh request timeout (AbortSignal.timeout(30_000) in refreshCredentials) plus the credential write. A waiter can therefore throw lock_timeout while the holder is still mid-refresh and about to succeed, causing a spurious provider failure/fallback. Make the wait longer than a worst-case refresh (e.g. 45s) or retry once on lock_timeout.

💡 Suggested Change

Before:

const LOCK_WAIT_MS = 20_000;

After:

const LOCK_WAIT_MS = 45_000;

9. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L466)

This state check is unreachable: waitForCallback only resolves after url.searchParams.get("state") === state. Keeping dead safety checks makes the control flow misleading — either remove it or move the comparison into waitForCallback (where the other callback validations live).


10. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L134-L135)

The credential file shape check validates client_id, scopes and expires_at but not the token fields. A hand-edited/corrupt file with a non-string access_token passes and later produces a malformed Authorization: Bearer ... header or a confusing re-auth loop instead of a clear "malformed file" error. Add string checks (empty strings are fine for the reauth_required record).

💡 Suggested Change

Before:

    !Array.isArray(parsed.scopes) ||
    typeof parsed.expires_at !== "number"

After:

    !Array.isArray(parsed.scopes) ||
    typeof parsed.access_token !== "string" ||
    typeof parsed.refresh_token !== "string" ||
    typeof parsed.expires_at !== "number"

11. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L451)

The previous ID token is handed to the OS URL opener as an argv element (rundll32/open/xdg-open), so it is visible to other local users in the process list — the header comment acknowledges this but it is still a credential exposure. id_token_hint is optional, so consider omitting it (or delivering it via a channel that is not argv) rather than leaking it for account pre-selection.


12. apps/memos-local-plugin/core/llm/providers/chatgpt.ts (L43)

This hardcoded slug is used on every request when chatgpt.model is blank (the documented default), but it is not referenced or validated anywhere else and model availability is plan-specific (docs tell users to pick a slug from listChatGptModels()). If this slug is not available on a user's plan, the zero-config path fails on every call and silently falls back. Prefer resolving a default from listChatGptModels(), or require chatgpt.model instead of embedding an unverified business value.


13. apps/memos-local-plugin/core/llm/providers/chatgpt.ts (L327-L328)

When the internal fallback serves the call, the fallback provider's ProviderCompletion is returned unchanged, so the facade (core/llm/client.ts) stamps the result with provider: "chatgpt", model: config.model (the OpenRouter fallback model) and servedBy: "chatgpt". Logs, model-status and cost/usage attribution then report ChatGPT as the serving provider although the openai_compatible endpoint served it. Consider exposing fallback metadata through ProviderCompletion (e.g. servedBy/fallbackProvider) or handling this fallback in the client like host_fallback.


14. apps/memos-local-plugin/viewer/src/stores/i18n.ts (L923-L924)

The hint's inheritance rule is narrower than the implementation: dedicatedFallbackTarget() in core/pipeline/memory-core.ts inherits the main llm endpoint/apiKey when the Summarizer provider is openai_compatible or chatgpt. Users whose summarizer is provider: chatgpt will read this as "inheritance won't happen" and may duplicate the endpoint/key unnecessarily (or wrongly assume a blank pair is fine). Same wording issue exists in the zh string at line 1803 ("若摘要模型为 OpenAI 兼容").

💡 Suggested Change

Before:

  "settings.chatgpt.hint":
    "Runs on your ChatGPT plan. Sign in once with `node scripts/chatgpt-login.mjs`; Test checks the sign-in. The model, endpoint and API key below are the OpenAI-compatible fallback. Set the ChatGPT model as `{path}` in config.yaml. For the Skill Evolver, the model field must not be blank; leave both endpoint and API key blank to reuse the Summarizer's pair when that one is OpenAI-compatible.",

After:

  "settings.chatgpt.hint":
    "Runs on your ChatGPT plan. Sign in once with `node scripts/chatgpt-login.mjs`; Test checks the sign-in. The model, endpoint and API key below are the OpenAI-compatible fallback. Set the ChatGPT model as `{path}` in config.yaml. For the Skill Evolver, the model field must not be blank; leave both endpoint and API key blank to reuse the Summarizer's pair when that one is OpenAI-compatible or ChatGPT.",

15. apps/memos-local-plugin/scripts/chatgpt-login.mjs (L50-L54)

The definitive success line is printed before the plan scope is validated, so on an incomplete grant the user sees "Signed in to ChatGPT for MemOS." followed by "plan scope: MISSING" and an exit code of 1. Compute planScope first and only print the success banner when the grant is actually usable, so the messaging is not self-contradictory.

💡 Suggested Change

Before:

  const res = await runLogin({ file });
  console.log("");
  console.log("Signed in to ChatGPT for MemOS.");
  console.log(`  account:        ${res.email ?? "(no email claim)"}`);
  const planScope = res.scopes.includes(REQUIRED_PLAN_SCOPE);

After:

  const res = await runLogin({ file });
  const planScope = res.scopes.includes(REQUIRED_PLAN_SCOPE);
  console.log("");
  console.log(
    planScope
      ? "Signed in to ChatGPT for MemOS."
      : "Sign-in completed, but the grant is incomplete.",
  );
  console.log(`  account:        ${res.email ?? "(no email claim)"}`);

16. apps/memos-local-plugin/viewer/src/views/SettingsView.tsx (L483-L485)

The shared settings.chatgpt.hint string bundles instructions that only make sense on the Skill Evolver card. It is rendered on the Summarizer card too, where "For the Skill Evolver, the model field must not be blank; leave both endpoint and API key blank to reuse the Summarizer's pair…" refers to the card the user is looking at in the third person and is misleading. Since the hint is already card-aware (path is chosen by type), gate the skill-evolver sentence the same way (e.g. a separate settings.chatgpt.hint.skillEvolver key) so each card only shows the relevant part.

💡 Suggested Change

Before:

      {block.provider === "chatgpt" && (
        <div style={HINT_STYLE}>
          {t("settings.chatgpt.hint", {

After:

      {block.provider === "chatgpt" && (
        <div style={HINT_STYLE}>
          {t(
            type === "skillEvolver"
              ? "settings.chatgpt.hint.skillEvolver"
              : "settings.chatgpt.hint",
            {

17. apps/memos-local-plugin/viewer/src/views/SettingsView.tsx (L649)

For provider: chatgpt the server probe only checks the sign-in and returns responseChars: 0 (see probeChat in server/routes/models.ts). Because the check is != null, the success banner will read "124ms · 0 chars", which looks like the model returned an empty completion. Only render the char count when it is non-zero (or suppress it for chatgpt).

💡 Suggested Change

Before:

                {result.responseChars != null ? ` · ${result.responseChars} chars` : ""}

After:

                {result.responseChars ? ` · ${result.responseChars} chars` : ""}

18. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L532-L533)

file is used unresolved, so a relative chatgpt.tokenFile (e.g. tokenFile: chatgpt-oauth.json or --file=./t.json) gives path.dirname(...) === "." and restrictToOwner then chmods the process working directory to 0700 — an unrelated directory (the plugin folder) gets its permissions changed as a side effect of signing in. getOrCreateHostId() has the same pattern (await restrictToOwner(dir) with the raw dirname). Resolve the path once and never restrict the cwd (or only restrict directories the plugin actually created).

💡 Suggested Change

Before:

  await fsp.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
  const dirRestricted = await restrictToOwner(path.dirname(file));

After:

  const tokenPath = path.resolve(file);
  const dir = path.dirname(tokenPath);
  await fsp.mkdir(dir, { recursive: true, mode: 0o700 });
  // A relative tokenFile must not chmod the process working directory.
  const dirRestricted = dir === process.cwd() ? true : await restrictToOwner(dir);

19. apps/memos-local-plugin/core/llm/chatgpt-auth.ts (L213-L215)

If writeFile throws (ENOSPC, EIO, quota), the file handle is never closed: the fd leaks and the just-created, empty *.lock file stays behind for LOCK_STALE_MS (60 s), blocking every other MemOS process from refreshing even though nobody holds the lock. Wrap the write so the handle is always closed and the lock is removed on failure.

💡 Suggested Change

Before:

      const h = await fsp.open(lock, "wx", 0o600);
      await h.writeFile(owner);
      await h.close();

After:

      const h = await fsp.open(lock, "wx", 0o600);
      try {
        await h.writeFile(owner);
      } catch (err) {
        await h.close().catch(() => undefined);
        await fsp.rm(lock, { force: true }).catch(() => undefined);
        throw err;
      }
      await h.close();

20. apps/memos-local-plugin/core/llm/providers/chatgpt.ts (L190)

attempt is bounded by the hardcoded BACKOFF_MS.length here and in the HTTP-status retry below, and ctx.config.maxRetries (the setting every other provider honours via httpPostJson/httpPostStream) is ignored. A user who sets llm.maxRetries: 0 to avoid duplicate plan usage still gets up to three POSTs to /v1/responses per call, and a user who raises it gets no extra retries. Bound the retries with ctx.config.maxRetries.

💡 Suggested Change

Before:

        if (name !== "TimeoutError" && attempt < BACKOFF_MS.length && this.fitsDeadline(ctx, BACKOFF_MS[attempt])) {

After:

        const maxAttempts = Math.max(0, ctx.config.maxRetries ?? 0);
        if (name !== "TimeoutError" && attempt < maxAttempts && this.fitsDeadline(ctx, BACKOFF_MS[Math.min(attempt, BACKOFF_MS.length - 1)])) {

🧹 Filtered 1 low-confidence OCR finding(s) before posting/fix-loop (duplicate: 1).

Generated by cloud-assistant via Open Code Review.

- auth: tolerate corrupt token files, owner-checked refresh lock,
  folders chmod 700 (files 600), warn when owner-only access fails,
  JWKS status + strict kid matching, typed JWK, host-id temp cleanup,
  never print the ID token in the sign-in URL, keep models without
  a visibility field
- provider: no pause for local sign-in states, no fallback without a
  fallback target, shared fallback gate, error mapping helper
- wiring: l3Llm gets chatgpt + fallback inheritance; inherit the main
  llm endpoint/key only from OpenAI-compatible providers
- schema: ChatGptProviderConfig derived from the schema;
  reasoningEffort reuses the reasoning effort union
- settings: Test checks the ChatGPT sign-in; per-card hint; shared
  hint style; login script rejects unknown args and exits 1 without
  the plan scope
- tests for each behaviour change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeff-ang92

Copy link
Copy Markdown
Author

Addressed the Open Code Review findings in d184491:

  • Fixed 1, 2, 3/14, 4 (l3Llm wiring), 5, 6/8, 7, 9/24, 10, 12, 13, 15, 16, 17, 18/19, 20, 21, 22, 23, 25, 26, 28, with tests for the behaviour changes.
  • Not changed: 4 (copying the slot model into chatgpt.model): the slot model is the OpenAI-compatible fallback model, so it can't double as the ChatGPT slug. 11: the default slug is kept; a wrong or unavailable slug falls back and logs chatgpt.fallback, and users can set chatgpt.model from chatgpt-login.mjs --models. 27: cancellation maps to llm_timeout the same way the shared fetcher does for every provider (core/llm/fetcher.ts), and the chatgpt fallback already stops on abort.

- wiring: inherit the main llm endpoint/key only as a pair
- config: chatgpt defaults so llm/l3Llm/skillEvolver.chatgpt load
  without "unknown config key" warnings
- provider: fall back only on ChatGPT outcomes (local bugs surface),
  map body read errors to ChatGPT failures, pause after a failure
  that follows streamed text
- auth: ignore callbacks without this sign-in's state, default scopes
  when the token response omits them, report a busy callback port,
  bounded lock wait, document the id_token_hint argv limit
- login script: reject empty --file= and --status with --models
- tests for each behaviour change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeff-ang92

Copy link
Copy Markdown
Author

Second review round addressed in 7543d33:

  • Fixed 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, with tests for the behaviour changes; 8 is documented as a known limit in the chatgpt-auth.ts header (the ID token hint identifies the account but grants no API access, and the printed sign-in URL never contains it).
  • Not changed: 4: the default slug is kept; a wrong or unavailable slug falls back and logs chatgpt.fallback, and users can set chatgpt.model from chatgpt-login.mjs --models. 12: this is the Responses route, where success is defined by response.completed (which also carries usage); a [DONE] before it means no completion arrived, so the fallback is the intended outcome.

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugin OpenClaw & Hermes status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants