Skip to content

feat: Implement LocalBackend#124

Merged
sm86 merged 11 commits into
mainfrom
local
May 13, 2026
Merged

feat: Implement LocalBackend#124
sm86 merged 11 commits into
mainfrom
local

Conversation

@DaevMithran
Copy link
Copy Markdown
Collaborator

@DaevMithran DaevMithran commented Apr 7, 2026

Summary

  • Add LocalBackend implementing ContextoBackend that runs the full ingestion pipeline locally: extract → summarize (LLM) → embed → cluster (AGNES) → persist
  • Add episode summarizer that calls OpenRouter/OpenAI with the same prompt and parameters as the remote API (gpt-4o-mini, temperature: 0.2, JSON response format)
  • Wire into plugin config via mode: 'local' option: provider and API key are resolved from OpenClaw runtime defaults, no duplicate config needed
  • Storage is pluggable via MindmapStorage interface, defaults to jsonFileStorage('.contexto/mindmap.json')

Motivation

@ekai/contexto only shipped with RemoteBackend, requiring an external API for summarization, ingestion, and search. Users who want to run fully local had no option. The ContextoBackend interface was designed to be pluggable — this PR provides the local implementation.

Usage

{
  "mode": "local"
}

@DaevMithran DaevMithran marked this pull request as draft April 7, 2026 16:35
@DaevMithran DaevMithran marked this pull request as ready for review April 8, 2026 09:40
@DaevMithran DaevMithran force-pushed the local branch 6 times, most recently from d3f7e0d to dd0626a Compare April 8, 2026 13:05
@DaevMithran DaevMithran requested a review from sm86 April 8, 2026 13:28
@sm86
Copy link
Copy Markdown
Contributor

sm86 commented Apr 9, 2026

A few things look worth fixing before merge:

  • In local mode, contexto is only registered after an async API-key lookup finishes. OpenClaw ignores async registration after register() returns, so the context engine may not be available when the slot is resolved.
  • The local summarizer only indexes userMessage and assistantMessages; it drops toolMessages. That means tool-derived facts can become unretrievable, even though the README says episodes include tool output.
  • This PR removes contextEnabled, so existing installs with contextEnabled=false will silently start retrieving/injecting context again after upgrade.

Also worth confirming: release.config.cjs now treats breaking as minor and feat as patch. If that was intentional, fine, but it looks unusual enough to double-check.

@DaevMithran DaevMithran marked this pull request as draft April 9, 2026 09:15
- Register context engine synchronously in local mode; defer API key
  resolution to first ingest/search via a credential resolver callback.
  OpenClaw does not await async work in register(), so the prior .then()
  chain could miss the slot-resolution window.
- Include toolMessages in extractEpisodeText so tool-derived facts remain
  retrievable in the local mindmap.
- Restore contextEnabled flag: existing installs that disabled context
  retrieval would otherwise silently start injecting context after upgrade.
- Revert release.config.cjs to match main (feat=minor, no breaking override).

Co-Authored-By: DaevMithran <daevmithran1999@gmail.com>
Co-Authored-By: sh1hsh1nk <13179671+sm86@users.noreply.github.com>
@sm86 sm86 marked this pull request as ready for review May 12, 2026 21:19
@sm86 sm86 merged commit ba78c32 into main May 13, 2026
2 checks passed
@sm86 sm86 deleted the local branch May 13, 2026 00:29
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.

2 participants