Go to file
matevip 0476447ab6 fix(agent): persist mid-turn narrative, queue follow-ups without dispose, flush on shutdown
A bundle of stability fixes that all surfaced together while running
the same long-form generation task across multiple turns. Each one
addresses a distinct way the previous behavior silently dropped
content the user had already seen on screen.

1. Mid-turn narrative persistence (StateGraphReActAgent +
   SummarizingNode). Intermediate ReasoningNode rounds and
   SummarizingNode broadcast their content_delta directly to the
   SSE channel for live display, but the StreamAccumulator only
   received the final answer. After refresh the assistant message
   showed only tool_call cards with no body text.
   StateGraphReActAgent now also forwards STREAMED_CONTENT (already
   set per round) as a persistOnly StreamDelta whenever it changes,
   so every narrative chunk lands in the accumulator's content
   buffer and gets written to mate_message. SummarizingNode now
   writes its summary into the same key so summarize narratives
   persist too.

2. Follow-up message queue, not dispose (ChatController#interruptStream).
   Sending a new message while a turn was running called
   requestInterrupt, which dispose()d the active Reactor chain mid
   LLM call. That cancelled the in-flight generation, lost partial
   tokens, and left the user staring at a half-finished bubble.
   The endpoint now uses enqueueMessage in all paths, matching
   the "wait for current turn, then run" behavior. The old
   requestInterrupt API is kept for any future force-replace UI
   but no caller routes to it.

3. Queued user message ordering (ChatStreamTracker.QueuedInput +
   ChatController.startQueuedMessage). interruptStream used to save
   the queued user message immediately, before the in-flight
   assistant message finalized in doOnError. listMessages orders
   by create_time ASC, so the queued user message ended up above
   the assistant reply it was supposed to follow. QueuedInput now
   carries contentParts; persistence is delayed to startQueuedMessage,
   which runs only after Asst-N is on disk.

4. JVM shutdown flush (ChatStreamTracker @PreDestroy +
   emergencySaveAccumulator). A mvn spring-boot:run restart used to
   wipe in-flight turns: SSE emitter timed out, ShutdownHook fired,
   HikariPool closed before doOnError could save. ChatStreamTracker
   now exposes an emergency-save callback per RunState; ChatController
   registers one per stream that snapshots the accumulator and
   writes status="interrupted_shutdown". @PreDestroy walks active
   runs, invokes the callback, then disposes. Spring's reverse-order
   bean teardown keeps ConversationService and Hikari alive long
   enough for the save to complete.

5. Observation thresholds for summarize (GraphObservationProperties +
   application.yml). The previous total-chars threshold of 12 KB
   triggered summarize after one or two RFC reads, costing a 40 to
   80 second compaction LLM call per loop. Tuned to: total 200 KB,
   single 16 KB, large-result 32 KB, rounds safety net 25. Java
   field defaults reverted to the conservative original values so
   application.yml stays the source of truth.

6. Frontend thinking segmentation (useChat.ts thinking_delta +
   phase). Multi-round ReAct turns merged every reasoning + summarize
   round's thinking into one segment, accumulating to 9 KB+ in a
   single bubble. thinking_delta now uses findLast(running) so a
   tool_call_started or phase transition closes the previous segment
   and the next delta opens a fresh one. phase event also closes
   running thinking/content segments.

7. Other small things bundled: removed a debug metadata-keys log
   that flooded the log file with one line per stream chunk; fixed
   three stale tests that didn't compile after earlier constructor
   changes (WikiLogServiceTest, WikiOverviewSpliceTest,
   WikiProcessingServiceLazyTest); added rfc-066 documenting the
   unified message queue + priority refactor as the next logical
   step on top of these stabilizations.

Verified end-to-end with multiple full sessions: a four-minute
generation that produced the expected docx and a follow-up enqueue
that ran cleanly after the previous turn naturally completed,
without the old "Disposable unavailable" interrupt path.
2026-04-27 07:51:49 +08:00
assets docs: add preview screenshot to README 2026-04-10 18:35:13 +08:00
docker/searxng fix(docker): bake searxng settings.yml into custom image 2026-04-24 23:25:03 +08:00
mateclaw-plugin-api feat(plugin): Plugin SDK + UI layout improvements 2026-04-13 18:38:03 +08:00
mateclaw-plugin-sample feat(plugin): Plugin SDK + UI layout improvements 2026-04-13 18:38:03 +08:00
mateclaw-server fix(agent): persist mid-turn narrative, queue follow-ups without dispose, flush on shutdown 2026-04-27 07:51:49 +08:00
mateclaw-ui fix(agent): persist mid-turn narrative, queue follow-ups without dispose, flush on shutdown 2026-04-27 07:51:49 +08:00
mateclaw-webchat release: v1.1.0 2026-04-17 19:41:03 +08:00
.dockerignore chore: bump version to 1.1.137-SNAPSHOT 2026-04-18 21:58:54 +08:00
.env.example build(docker): pass MAVEN_FLAGS build-arg to support aliyun-first profile in CN builds 2026-04-25 10:32:23 +08:00
.gitignore feat(model): add Bailian Token Plan, SiliconFlow CN/INTL, OpenCode providers (V32-V34) 2026-04-23 18:14:12 +08:00
docker-compose.yml build(docker): pass MAVEN_FLAGS build-arg to support aliyun-first profile in CN builds 2026-04-25 10:32:23 +08:00
LICENSE chore: add Apache-2.0 license 2026-04-04 23:29:51 +08:00
README_zh.md docs: update README title and tagline 2026-04-21 09:27:42 +08:00
README.md docs: update README title and tagline 2026-04-21 09:27:42 +08:00

MateClaw Logo

MateClaw

Your second brain

GitHub Repo Documentation Live Demo Website Java Version Spring Boot Vue Last Commit License

[Website] [Live Demo] [Documentation] [中文]

MateClaw Preview


Most AI tools die when their vendor has a bad day. Most forget you the moment the tab closes. Most give you a chatbox and call it a product.

MateClaw is the whole widget. One deployment. Reasoning, knowledge, memory, tools, channels — built together, not bolted on. And when your primary model goes down, the next one picks up mid-sentence.


Three things that make it different

1 · Your AI doesn't die when a model does

Primary key expired. Vendor returns 401. Network blip. Quota drained.

Other tools hand you a red error card. MateClaw routes to the next healthy provider — DashScope, OpenAI, Anthropic, Gemini, DeepSeek, Kimi, Ollama, LM Studio, MLX, 14+ in total — and the user sees the reply finish. A provider health tracker parks bad vendors in a cooldown window so they don't waste seconds on every turn.

You don't write a retry script. You drag providers into priority order in Settings → Models and watch the health dashboard fill with green dots as requests route around failures in real time.

Upload a PDF, a batch of markdown, a scraped page — raw material in.

MateClaw's LLM Wiki digests it into structured pages, builds [[links]] between them, and remembers where every sentence came from. Click a citation, see the exact source chunk. Ask a question, the page you get is stitched from the right chunks — with references you can verify.

This is the difference between a warehouse and a library.

3 · One product, five surfaces

Surface What it is
Web Console Full admin — agents, models, tools, skills, knowledge, security, cron
Desktop Electron app with a bundled JRE 21. Double-click, run. No Java install
Webchat Widget One <script> tag embed. Drop it on any site
IM Channels DingTalk · Feishu · WeChat Work · Telegram · Discord · QQ
Plugin SDK Java module for third-party capability packs

Same brain. Same memory. Same tools. Different doors.

$0 · No tokens metered. No seats billed. Your server. Your data. Your keys.


What's in the box

Agent runtime

ReAct for iterative reasoning. Plan-and-Execute for complex multi-step work. Dynamic context pruning, smart truncation, stale-stream cleanup — the boring stuff that makes long conversations actually work.

Knowledge & memory

  • LLM Wiki — raw materials digest into linked pages with citations
  • Workspace memoryAGENTS.md, SOUL.md, PROFILE.md, MEMORY.md, daily notes
  • Memory lifecycle — post-conversation extraction, scheduled consolidation, dreaming workflows

Tools, skills, MCP

Built-in tools for web search, files, memory, date/time. MCP over stdio / SSE / Streamable HTTP. SKILL.md packages from the ClawHub marketplace. A Tool Guard layer with RBAC, approval flows, and path protection — capability needs boundaries.

Multimodal creation

Text-to-speech · Speech-to-text · Image · Music · Video. First-class, not add-ons.

Enterprise-ready

RBAC + JWT. Full audit trail. Flyway-managed schema that auto-heals on upgrade. One JAR to ship. MySQL in production, H2 for dev — nothing to change in your code.


AI is becoming infrastructure

On March 2, 2026, Claude went dark for 4 hours across API, web, and mobile. Three weeks later, another 5 hours. Every company that bet their AI strategy on a single vendor spent those outages staring at red error cards.

This is the same shift databases went through around 2010 and cloud went through around 2018: the winning layer stops being tied to one supplier. 57% of companies now run AI agents in production. None of them want one vendor's bad day to become their bad day.

MateClaw is that layer — built the Spring Boot way.


Why MateClaw

MateClaw OpenClaw Hermes Agent Claude Code Cursor
Multi-vendor failover Chain + health tracker + cooldown Swap providers via config Orchestration w/ retry Anthropic only One model
Knowledge digestion LLM Wiki + page-level citations Canvas + memory Skills Hub + memory Code index
Multi-user admin RBAC + approval flow + audit Config-file first Single-user CLI Enterprise tier Teams plan
Surfaces Web admin + Desktop + Widget + SDK + 6 IM 25+ chat channels 15+ channels (CLI-led) 3 IM preview IDE only
Stack Java (Spring Boot) TypeScript Python TypeScript Electron/TS
License / Price Apache 2.0 · Free MIT · Free MIT · Free Proprietary · $20200/mo Proprietary · $0200/mo

OpenClaw and Hermes Agent are excellent personal AI platforms — pick either if you're running one user on one laptop, building your own agent from CLI, and treating everything as config files to hand-tune. Both have bigger communities than MateClaw today.

MateClaw is the version built for teams. RBAC per agent, per model, per tool. An approval flow that pauses risky actions for review. Full audit trail. A web admin dashboard where one operator manages 50 agents across 14 vendors. Spring Boot inside — drop-in for any Java shop already running production services.

Same "whole widget" philosophy. Different center of gravity.


Quick start

# Backend
cd mateclaw-server
mvn spring-boot:run           # http://localhost:18088

# Frontend
cd mateclaw-ui
pnpm install && pnpm dev      # http://localhost:5173

Login: admin / admin123

Docker

cp .env.example .env
docker compose up -d          # http://localhost:18080

Desktop

Download from GitHub Releases. Bundles JRE 21. No Java install needed.


Architecture

Business Architecture

Technical architecture

Technical Architecture


Project structure

mateclaw/
├── mateclaw-server/        Spring Boot 3.5 backend (Spring AI Alibaba, StateGraph runtime)
├── mateclaw-ui/            Vue 3 + TypeScript admin SPA (built into the server JAR)
├── mateclaw-webchat/       Embeddable chat widget (UMD / ES bundles)
├── mateclaw-plugin-api/    Java SDK for third-party capability plugins
├── mateclaw-plugin-sample/ Reference plugin implementation
├── docker-compose.yml
└── .env.example

Desktop binaries ship via GitHub Releases with a bundled JRE 21 — no Java install needed.

Tech stack

Layer Technology
Backend Spring Boot 3.5 · Spring AI Alibaba 1.1 · MyBatis Plus · Flyway
Agent StateGraph runtime · ReAct + Plan-Execute
Database H2 (dev) · MySQL 8.0+ (prod)
Auth Spring Security + JWT
Frontend Vue 3 · TypeScript · Vite · Element Plus · TailwindCSS 4
Desktop Electron · electron-updater · JRE 21 (bundled)
Widget Vite library mode · UMD + ES bundles

Documentation

Full docs at claw.mate.vip/docs — setup, architecture, each subsystem, API reference.

Roadmap

Sharper multi-agent collaboration · Smarter model routing · Deeper multimodal understanding · Longer-lived memory · A richer ClawHub.

Contributing

git clone https://github.com/matevip/mateclaw.git
cd mateclaw
cd mateclaw-server && mvn clean compile
cd ../mateclaw-ui && pnpm install && pnpm dev

Why the name

Mate is companion. Claw is capability.

Something that stays with you — and grabs work and moves it.

License

Apache License 2.0. No asterisks.