Skip to content

feat(memos-local): structured topic classifier, agent tracking, task auto-finalize#1412

Merged
tangbotony merged 10 commits into
MemTensor:openclaw-local-plugin-20260331from
tangbotony:native_memos
Apr 3, 2026
Merged

feat(memos-local): structured topic classifier, agent tracking, task auto-finalize#1412
tangbotony merged 10 commits into
MemTensor:openclaw-local-plugin-20260331from
tangbotony:native_memos

Conversation

@tangbotony
Copy link
Copy Markdown
Contributor

Summary

  • Replace simple NEW/SAME topic judge with a structured two-stage LLM classifier (JSON output with confidence score; low-confidence NEW triggers second-pass arbitration)
  • Compact prompts and task state format to reduce token consumption by ~50-60%
  • Add role-based dedup filtering to prevent cross-role memory merging (user ↔ assistant)
  • Add sourceAgent/owner field to memory search results and hub sharing for agent source tracking
  • Add task auto-finalize: stale active tasks (configurable timeout, default 4h) are automatically summarized and completed
  • Fix session-scoped task processing to prevent cross-agent task interference
  • Viewer UI: agent filter badges with unified styling, i18n support, auto-finalize timeout setting

Changes

Topic Judgment Algorithm

  • task-processor.ts: New buildTopicJudgeState() builds compact task context (topic, recent 3 turn summaries, conditional assistant snippet for short/ambiguous messages)
  • task-processor.ts: processChunksIncrementally() now calls classifyTopic() → structured JSON result; low-confidence NEW (< 0.65) triggers arbitrateTopicSplit() second pass
  • providers/openai.ts: New classifyTopicOpenAI(), arbitrateTopicSplitOpenAI(), parseTopicClassifyResult() with compact prompt ({"d":"S"|"N","c":0.0-1.0})
  • providers/index.ts: New Summarizer.classifyTopic() / arbitrateTopicSplit() methods with OpenClaw and multi-provider routing
  • providers/anthropic.ts, gemini.ts, bedrock.ts: Updated TOPIC_JUDGE_PROMPT with improved short-message/pronoun handling rules

Agent Source Tracking

  • index.ts: Added owner/sourceAgent fields to memory search results, auto-recall output, and hub sharing payloads
  • hub/server.ts: Accept and propagate sourceAgent in memory share and search responses
  • viewer/html.ts: Display agent badge on memory/task/skill items

Task Auto-Finalize

  • viewer/server.ts: autoFinalizeStaleTasks() triggered on task page load; configurable via taskAutoFinalizeHours
  • types.ts: Added taskAutoFinalizeHours to MemosLocalConfig with default of 4
  • viewer/html.ts: Settings UI field for auto-finalize timeout with i18n

Dedup & Task Isolation

  • worker.ts: Filter dedup candidates by matching role to prevent cross-role merging
  • task-processor.ts: Session-scoped task processing prevents cross-agent interference

Test Plan

  • Unit tests (task-processor.test.ts): 19/20 passed (1 pre-existing session-change issue)
    • 6 new classifier tests: high-confidence NEW/SAME, null fallback, low-confidence arbitration (SAME/NEW), timeout override
  • Accuracy tests (accuracy.test.ts) against real LLM:
    • Dedup: 4/4 (100%)
    • Topic: 3/3 (100%)
    • Precision: 9/10 (90%)
    • Summary: 6/6 (100%)
  • Build passes (tsc clean)
  • Manual verification: gateway restart + viewer API responsive

Made with Cursor

…isolation

- Add hubInstanceId to team_shared_chunks, local_shared_tasks, and
  client_hub_connection to prevent stale sharing state when switching
  between Hub instances
- Fix memory_search/timeline/get owner isolation by accepting agentId
  from tool execution context
- Fix viewer sharing queries to use role-appropriate tables (hub_memories
  vs team_shared_chunks)
- Apply maxChars truncation in memory_get handler
- Fix 11 failing tests: accuracy thresholds, integration env isolation,
  plugin-impl join flow, and task-processor topic judge flakiness

Made-with: Cursor
…n search, LLM dedup

- Compute embeddings on Hub when memories are shared (same as task/skill),
  instead of on-the-fly at search time; auto-backfill missing vectors on startup
- Hub search now reads pre-computed vectors from hub_memory_embeddings + FTS + RRF
  (unified retrieval strategy across memory/chunk/skill)
- Add deduplication rule to LLM filterRelevant prompt so merged local+remote
  results automatically drop near-duplicate snippets
- Add LLM filtering to skill_search hub merge path (consistent with memory_search)
- Persist latest Hub username/role during client 401 recovery
- Add admin rename notification + fix client nickname consistency
- Fix Hub join dryRun logic, normalizeTimestamp compile error
- Define missing OpenClaw provider prompt constants
…d 3-phase recall

- Refactor both memory_search tool and auto-recall to a 3-phase pipeline:
  Phase 1: local engine.search() ∥ hubSearchMemories() via Promise.all
  Phase 2: merge all candidates → single LLM filterRelevant() call
  Phase 3: build response with unified { candidates, hubCandidates, filtered } structure
- Remove redundant double LLM filtering (was: local filter → hub fallback → merge filter)
- Separate hub-memory origin hits from local candidates in RecallEngine results
- Simplify trackTool serialization to a single branch matching the unified details shape
- Add dedicated "远程召回" (Hub Remote) display section in Viewer between initial retrieval and LLM filtered results
… npm cache

- update-check: installCommand now uses exact version (e.g. @1.0.6-beta.11) instead of dist-tag (@beta)
- frontend: always construct pkgSpec as packageName@exactVersion, pass targetVersion to backend
- backend: verify downloaded version matches targetVersion, rollback on mismatch
- npm pack: add --prefer-online flag as extra safety
- postinstall: fix native binding validation, delegate to native-binding.cjs
- update-install: flush HTTP response before SIGUSR1 restart, add no-cache headers
Add disable, enable, and hard-delete management for skills in the memory viewer so inactive skills stop participating in recall while remaining manageable from the UI.

Made-with: Cursor
Merge the latest upstream openclaw-local-plugin-20260331 changes into the fork branch so follow-up MemOS local plugin work can continue from the synced codebase.

Made-with: Cursor
…, task auto-finalize, and viewer enhancements

- Replace simple NEW/SAME topic judge with structured two-stage LLM classifier
  (JSON output with confidence score, low-confidence arbitration fallback)
- Compact prompts and task state to reduce token consumption by ~50-60%
- Add role-based dedup filtering to prevent cross-role memory merging
- Add sourceAgent/owner field to memory search results and hub sharing
- Add task auto-finalize for stale active tasks (configurable timeout in settings)
- Add agent filter badges and i18n support in viewer UI
- Fix session-scoped task processing to prevent cross-agent task interference
- Update task-processor tests for new classifier API with arbitration scenarios

Made-with: Cursor
@tangbotony tangbotony merged commit 56afdc5 into MemTensor:openclaw-local-plugin-20260331 Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant