extractReflection (capture/reflection-extractor.ts)

MemTensor/MemOS · apps/memos-local-plugin/core/capture/reflection-extractor.ts · typescript · Apache-2.0
ai

Extracts agent reasoning from assistant text for AI agent systems.

// Source: https://github.com/MemTensor/MemOS | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * `reflection-extractor` — try to lift a self-reflection out of the
 * assistant text for free (no LLM required).
 *
 * The V7 spec defines a reflection as "the agent's own explanation of
 * why it made this decision". Hosts sometimes emit this inline:
 *   - An OpenClaw assistant block containing `### Reasoning:` or
 *     `I chose this because …`.
 *   - A Hermes `<reflection>…</reflection>` tag (legacy).
 *   - A Chinese-language agent producing "我这样做是因为…" or "思考过程:".
 *
 * We recognise a handful of high-precision patterns and return the cleaned
 * snippet. Never throws, never inv

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key