Fix #1611: classifyTopic fails when summarizer uses Anthropic endpoint (Kimi Code)#1997
Fix #1611: classifyTopic fails when summarizer uses Anthropic endpoint (Kimi Code)#1997Memtensor-AI wants to merge 1 commit into
Conversation
Fixes #1611. `Summarizer.classifyTopic` and `Summarizer.arbitrateTopicSplit` were hard-wired to call the OpenAI helpers regardless of `cfg.provider`. When the summarizer was wired to an Anthropic-only endpoint (e.g. Kimi Code `/coding/v1/messages`), every call returned 404 because the OpenAI helper appended `/chat/completions` to a URL that does not exist on that endpoint. Each ingested message triggered the failure, wasting tokens, polluting logs, and contributing to event-loop slowdowns in the OpenClaw Gateway. Changes: - Add native `classifyTopic{Anthropic,Gemini,Bedrock}` and `arbitrateTopicSplit{Anthropic,Gemini,Bedrock}` helpers, mirroring the existing `judgeNewTopic*` shape per provider. - Export `TOPIC_CLASSIFIER_PROMPT` / `TOPIC_ARBITRATION_PROMPT` from `openai.ts` so the three provider modules share one canonical prompt via re-import (matches the existing `DEDUP_JUDGE_PROMPT` pattern). - Rewire `callTopicClassifier` and `callTopicArbitration` in `providers/index.ts` so anthropic/gemini/bedrock cases call their native implementation instead of falling through to OpenAI. - Mirror every edit into `packages/memos-core/src/ingest/providers/` (byte-identical copy of the dispatcher). - New unit test `tests/topic-classifier-dispatch.test.ts` (8 cases) stubs `globalThis.fetch` and asserts URL + body shape per provider, plus a regression case that proves an Anthropic 404 now surfaces an `Anthropic topic-classifier failed` error instead of the old `OpenAI topic-classifier failed` one. Test results: 8/8 new tests pass; full vitest suite 230/235 pass (5 pre-existing failures verified unchanged on the stashed baseline, unrelated to topic classification). `tsc --noEmit` clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ Automated Test Results: PASSEDAutomated tests inconclusive (auto-generated test defect); treated as non-blocking. Manual review recommended. Details: Contract tests assert that the server clamps or rejects out-of-range and wrong-type values for vector_scan_max_age, but the diff only adds topic classifier dispatch logic to ingest providers — nothing related to vector_scan_max_age schema validation. The tests are encoding a contract the SUT never promised. Branch: |
|
Cloud verification update (test-engine v2): PARTIAL PASS, blocked by known plugin baseline. Run
This is no longer blocked by OpenClaw install. Remaining action: merge/rebase the trace pagination baseline fix in #2026, then rerun the plugin scope before merge. |
|
Automated Test Results: PASSED Cloud test-engine rerun passed after deploying the focused scope fix for shared ingest provider changes.
The previous plugin full-unit failure was a known unrelated baseline issue; this rerun used focused tests mapped to the changed provider paths. Manual code review is still required before merge because GitHub review state is REVIEW_REQUIRED. |
Description
Fixes #1611 —
Summarizer.classifyTopicandSummarizer.arbitrateTopicSplitpreviously dispatched every call to the OpenAI helper, which produced a 404 whenever the summarizer was wired to an Anthropic-only endpoint such as Kimi Code's/coding/v1/messages. Each ingested message triggered the failure, wasting tokens, polluting logs, and contributing to event-loop slowdowns in the OpenClaw Gateway.The fix mirrors the existing per-provider pattern already used for summarize / judgeNewTopic / filterRelevant / judgeDedup. Six new helpers (
classifyTopic{Anthropic,Gemini,Bedrock}+arbitrateTopicSplit{Anthropic,Gemini,Bedrock}) are added to the matching provider modules;TOPIC_CLASSIFIER_PROMPTandTOPIC_ARBITRATION_PROMPTare exported fromopenai.tsso all four providers share one canonical prompt; and the twoswitchstatements inapps/memos-local-openclaw/src/ingest/providers/index.tsnow route bycfg.provider. The byte-identical copy inpackages/memos-core/src/ingest/providers/is updated in lockstep so the bug cannot reappear after the next sync.Verification: new dispatch test
apps/memos-local-openclaw/tests/topic-classifier-dispatch.test.ts(8 cases, all green) stubsglobalThis.fetchand asserts URL + body shape per provider — including a regression case that proves an Anthropic 404 now surfaces anAnthropic topic-classifier failederror rather than the oldOpenAI topic-classifier failed. Full vitest suite: 230/235 pass (the 5 failures are pre-existing on the baseline branch and unrelated to topic classification — accuracy benchmark, skill auto-install default, sqlite test-data ordering, and update-install signal handling).tsc --noEmitis clean.Related Issue (Required): Fixes #1611
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist