Never Ask Twice

Never Ask Twice

Enterprise support memory agent that remembers customer context across sessions, retrieves relevant memories, and forgets stale facts to reduce re-ask rates.

Category
访问服务器

README

Never Ask Twice

Enterprise Support MemoryAgent on Qwen Cloud

License: Apache-2.0 TypeScript Runtime Cloud Model Memory MCP

Never Ask Twice is a production-shaped B2B support memory agent that remembers customer context across sessions, retrieves only the memories that matter, forgets stale facts safely, and proves improvement with a deterministic memory ON/OFF evaluation harness plus a live Qwen-backed API path.

The demo agent is Nat. Nat is powered by NATE — the Never Ask Twice Engine — a scoped memory layer that turns support conversations into durable, auditable customer context.

Built for the Qwen Cloud Global AI Hackathon — Track: MemoryAgent.

Status

Area Status Notes
Public clean-room repo Done Synthetic data only; boundary scan included.
Local Postgres + pgvector setup Done docker compose up -d binds Postgres on localhost:5433.
Deterministic eval harness Done pnpm eval prints memory ON/OFF re-ask, recall, and hallucination metrics.
Memory service Done Working, episodic, semantic, forgetting, and budgeted recall paths are implemented.
MCP stdio surface Done Four memory tools are exposed through pnpm mcp:list-tools.
Qwen-backed live path In progress Requires DASHSCOPE_API_KEY; local-safe mode runs without it.
Alibaba Function Compute deployment In progress s.yaml and deployment instructions exist; final live proof is still required.
Demo video Pending Should use the frozen Acme scenario and the eval output line.

Judge path

  1. Read the memory model: docs/memory-model.md.
  2. Run the ablation:
    pnpm eval
    
  3. Inspect the forgetting behavior: docs/forgetting-policy.md.
  4. Read the system architecture: docs/architecture.md.
  5. List MCP tools:
    pnpm build
    pnpm mcp:list-tools
    
  6. Review the deployment instructions and proof placeholder: deploy/alibaba-fc.md.

The measurable result

Run:

pnpm eval

Expected deterministic fixture output:

memory-on re-ask rate: 0.00
memory-on recall accuracy: 1.00
memory-on hallucination count: 0
memory-off re-ask rate: 1.00
memory-off recall accuracy: 0.00
memory-off hallucination count: 0
re-ask rate: 0.00 (memory) vs 1.00 (no-memory)

The evaluation path is intentionally deterministic for reproducible scoring. It uses fixed synthetic fixtures and a fake Qwen client. The live API path uses Qwen Cloud when DASHSCOPE_API_KEY is configured.

What makes it a MemoryAgent

Never Ask Twice implements explicit memory tiers:

  • Working memory — current-session context usable before session-close distillation.
  • Episodic memory — raw support events with Qwen embeddings and provenance.
  • Semantic memory — distilled customer facts with confidence, validity windows, and source links.
  • Forgetting policy — TTL expiry, supersession, stale-memory exclusion, and audit-safe provenance.
  • Budgeted recall — relevant memories only, capped to a strict context budget.
  • MCP surface — memory tools exposed for agent interoperability.

This is not transcript logging. It is structured memory with retrieval discipline, provenance, forgetting, and measurable cross-session improvement.

Architecture

Customer chat / MCP
        |
        v
Hono API on Alibaba Function Compute
        |
        v
MemoryService
  |-- working memory: current-session facts
  |-- episodic memory: turn events + Qwen embeddings
  |-- semantic memory: distilled durable facts
  |-- forgetting: TTL + supersession + scoped recall
        |
        +--> Qwen Cloud via DashScope-compatible OpenAI API
        +--> Postgres + pgvector
        +--> MCP stdio tools

More detail: docs/architecture.md.

Getting started

1. Clone and install

git clone https://github.com/marcelle-labs/never-ask-twice.git
cd never-ask-twice
pnpm install

2. Configure environment

cp .env.example .env

Edit .env and set your DASHSCOPE_API_KEY from DashScope for live Qwen-backed embeddings, distillation, and adjudication. The example is pre-filled for local Postgres on port 5433.

DATABASE_URL=postgresql://neverasktwice:neverasktwice@localhost:5433/neverasktwice
DASHSCOPE_API_KEY=your-key-here
QWEN_BASE_URL=https://dashscope-intl.aliyuncs.com/compatible-mode/v1
QWEN_CHAT_MODEL=qwen-plus
QWEN_EMBEDDING_MODEL=text-embedding-v3
QWEN_EMBEDDING_DIM=1024
MEMORY_TOKEN_BUDGET=1200

Without DASHSCOPE_API_KEY, the API boots in local-safe mode. Local-safe mode uses zero-vector embeddings and empty distillation responses so the server can run without secrets; it does not perform real Qwen work. Use pnpm eval for deterministic local scoring without a key.

3. Start Postgres

docker compose up -d

The local database binds to localhost:5433 so it does not collide with other Postgres services on 5432.

4. Run migrations

pnpm migrate

5. Run the eval harness

pnpm eval

6. Run the boundary scan

pnpm boundary-scan

7. Start the local API

pnpm dev

The API will be available at http://localhost:3000 with endpoints:

  • GET /health — health and capability status.
  • POST /turn — append a customer/agent turn.
  • POST /sessions/:id/close — close a session and distill episodic memory into semantic memory.
  • POST /recall — recall a bounded memory bundle.

8. Run the MCP server

pnpm build
node dist/src/mcp/server.js

The MCP server exposes four tools: recall_memory, write_memory, distill_session, and forget.

Project structure

  • apps/api — Hono API, local server, and Function Compute handler.
  • src/agent — deterministic support-agent policy used by the eval harness.
  • src/contracts.ts — memory predicate enum, Zod contracts, and shared types.
  • src/db — Drizzle schema and SQL migration string.
  • src/memory — memory service, stores, retrieval, supersession, and forgetting behavior.
  • src/mcp — stdio MCP surface over the shared memory service.
  • src/qwen — single Qwen Cloud client module.
  • src/testing — deterministic fake Qwen client for the eval harness.
  • eval — frozen three-session scenario, ground truth, expected output, and runner.
  • scripts — boundary scan, migration, MCP list-tools, and demo script checks.
  • docs — judge-facing architecture, memory model, evaluation, and forgetting documentation.
  • deploy — Alibaba Function Compute deployment instructions and proof placeholder.

Key commands

Command Purpose
pnpm install Install dependencies
pnpm build Build the project
pnpm lint Run TypeScript type check
pnpm test Run the test suite
pnpm eval Run the deterministic memory ON/OFF eval harness
pnpm migrate Run database migrations
pnpm boundary-scan Run the clean-room boundary scan
pnpm mcp:list-tools List the MCP tools
pnpm demo:script-check Verify demo fixtures are aligned

Security and clean-room boundary

Never Ask Twice uses synthetic data only. Do not commit real customer data, secrets, .env files, or private platform identifiers. The repository includes a boundary scan to fail on known forbidden tokens and a local-safe mode so judges can run the server without secrets.

See SECURITY.md.

License

Apache-2.0

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选