Skip to content

classifyTopic fails when summarizer uses Anthropic endpoint (Kimi Code) #1611

Closed

Description

@Lunareith

Bug Report: classifyTopic fails when summarizer is configured with Anthropic endpoint

Environment

  • OpenClaw version: 2026.4.29
  • MemOS plugin: memos-local-openclaw-plugin v1.0.8
  • Model: anthropic/kimi-for-coding
  • Endpoint: https://api.kimi.com/coding/v1/messages

Problem

TaskProcessor.classifyTopic always fails with 404 when the MemOS summarizer is configured to use an Anthropic-compatible endpoint (e.g., Kimi Code's /messages endpoint).

Error Log

classifyTopic failed (anthropic/kimi-for-coding), trying next:
Error: OpenAI topic-classifier failed (404):
{"error":{"message":"The requested resource was not found","type":"resource_not_found_error"}}

Root Cause

classifyTopic in src/ingest/providers/index.ts always calls classifyTopicOpenAI(), which sends requests in OpenAI format (/chat/completions), regardless of the summarizer's configured provider.

Component Format Used Endpoint
summarizer (configured) Anthropic Messages /coding/v1/messages ✅
classifyTopic (hardcoded) OpenAI Chat Completions /coding/v1 ❌

When the endpoint only supports Anthropic format, the OpenAI-style classifyTopic request returns 404.

Why This Didn't Happen Before

  • DeepSeek supports both OpenAI and Anthropic formats simultaneously, so OpenAI-style classifyTopic works even when summarizer uses Anthropic config.
  • Kimi Code's Anthropic endpoint (/coding/v1/messages) only accepts Anthropic format, rejecting OpenAI-style requests.

Impact

  • Every incoming message triggers a classifyTopic call that fails and falls back.
  • Wastes tokens (small per-call, but adds up).
  • Pollutes logs with repeated 404 errors.
  • Increases event-loop latency (related to observed Gateway slowdowns).

Proposed Fix

Option A: Make classifyTopic respect the summarizer's configured provider and call the appropriate implementation (OpenAI vs Anthropic).

Option B: Add a separate topicClassifier configuration key so users can explicitly set a different provider/model for topic classification.

Related Code

  • src/ingest/providers/index.ts: classifyTopic()
  • src/ingest/providers/openai.ts: classifyTopicOpenAI()
  • src/ingest/task-processor.ts: onChunksIngested() → classifyTopic()

Additional context: This was discovered while investigating why QQ Bot responses became slow. The repeated classifyTopic failures contribute to event-loop blocking in the OpenClaw Gateway.

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 29, 2026
  2. self-assigned this
    on Jun 30, 2026
  3. added a commit that references this issue on Jun 30, 2026
    16e9e4b
  4. added
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 30, 2026
  5. removed
    types:bugSomething isn't working | 功能异常
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    on Jul 7, 2026
  6. added theissue type on Jul 7, 2026
  7. added
    status:readyReady for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发
    on Jul 8, 2026
  8. 10 remaining items

  9. Memtensor-AI commented on Jul 21, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 75ef940b99925b96
    Working branch: feature/autodev-1611-20260721033002951
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  10. Memtensor-AI commented on Jul 21, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 75ef940b99925b96 completed.

    Summary: Fixed issue #1611: Summarizer.classifyTopic and Summarizer.arbitrateTopicSplit in the memos-local-openclaw plugin used to unconditionally dispatch to the OpenAI implementation, so any summarizer configured against an Anthropic-only endpoint (e.g. Kimi Code's /coding/v1/messages) had every classification call return 404 — the OpenAI helper appended /chat/completions to a URL that doesn't exist. The fix implements Option A from the issue: added six new native transport helpers (classifyTopic{Anthropic,Gemini,Bedrock} and arbitrateTopicSplit{Anthropic,Gemini,Bedrock}) mirroring the shape of the existing judgeNewTopic* helpers, and rewired both callTopicClassifier and callTopicArbitration switch statements so the anthropic / gemini / bedrock arms route to their native implementations instead of falling through to the OpenAI helpers.

    To prevent prompt drift across providers, TOPIC_CLASSIFIER_PROMPT / TOPIC_ARBITRATION_PROMPT are exported from openai.ts and re-imported by the three provider files; parseTopicClassifyResult continues as the single JSON parser. The byte-similar duplicate at packages/memos-core/src/ingest/providers/ received identical edits so a future re-sync between the two trees cannot silently regress the bug. Bedrock helpers require cfg.endpoint, matching every other Bedrock helper in the file.

    Tests: added apps/memos-local-openclaw/tests/topic-classifier-dispatch.test.ts with 8 cases that stub globalThis.fetch and assert each provider hits the correct URL + body shape. TDD baseline was 7/8 failing against the buggy code — the anthropic case surfaces the exact OpenAI topic-classifier failed (404) string from the issue. Post-fix: 8/8 pass. Existing topic-judge-minimax-1315.test.ts (5/5) continues to pass, and task-processor.test.ts regressions match baseline exactly. tsc --noEmit on the modified provider files is clean.

    Files: 5 modified + 1 new in apps/memos-local-openclaw/, 5 mirrored in packages/memos-core/. Total 11 files, 876 insertions, 14 deletions. Branch pushed to origin/feature/autodev-1611-20260721033002951; scheduler will create the PR and add reviewers.

    Base branch: main
    Branch: feature/autodev-1611-20260721033002951
    Commit: 1f7ffe1
    PR: #2133
    Assigned to: @bittergreen
    Reviewers: @whipser030, @hijzy

  11. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    on Jul 21, 2026
  12. added
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    and removed
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jul 21, 2026
  13. added a commit that references this issue on Jul 23, 2026
    976d1af
  14. removed
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    on Jul 23, 2026
  15. added a commit that references this issue on Jul 24, 2026
    e820406
  16. added a commit that references this issue on Sep 18, 2026
    a447579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:pluginOpenClaw & Hermesstatus:in-progressSomeone or AI is working on it | 人工或 AI 正在处理

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions