Skip to main content
Glama

memory_add

Store cross-task standing preferences, constraints, and design intent as direction-layer memory that gets injected into every agent's system prompt, with quota enforcement and overflow handling.

Instructions

Add a direction-layer memory — the team's shared, cross-task standing preferences.

方向层 = 低频·高价值密度·跨任务长寿命的偏好/纠正/约束/设计意图。每个派出 的 agent 出生即注入方向层,"全中文""完成即汇报"这类偏好不再靠手抄进 prompt。

写入检验(软门槛):这条能影响多少未来任务?只影响单个任务的 → 去 task_memo_add(情景层),不要写这里。

体量红线是单一轴:存储上限 = 注入预算。方向层按桶计字符配额—— global 1200 字 + 每个 project 1500 字 + user 300 字,一个会话实际继承 3000 字;单条仍 ≤ 400 字。存得下的一定传得到,写不进去的就是真的没位置: 超限时本工具返回该桶全部有效条目(id / kind / 字数 / 全文)+ 用量缺口, 要求当轮先 memory_invalidate(可用 content_match 子串定位)或 memory_reconcile_apply 腾出空间,再重试本次写入。 超长内容改写成「触发条件 + 指向权威文件」的指针条目(如 "涉及生产/集群/DB 时遵守只读铁律,详见 ~/.claude/CLAUDE.md"),正文外置。

写入侧安全扫描:方向层条目会进每个派出 agent 的 system prompt,因此不可见 Unicode、提示注入句式(覆盖既有指令 / 套取系统提示 / 伪造对话角色)、凭据 形态一律拒绝入库。

kind 四类(决定注入截断优先级 constraint>design>directive>preference):

  • constraint(禁令/护栏):一句话、可机检、终身有效。 如 "所有输出使用中文"、"git 提交绝不自动加 agent 署名"。

  • design(价值排序/设计意图):缺显式指令时的取舍依据。 如 "技术决策偏向质量/简洁/健壮/长期可维护,不看重开发成本"。

  • directive(方法论/工作方式):回答"怎么干"。 如 "完成即按问题→根因→解法→验证汇报,不攒批次"。

  • preference(格式偏好):可选,如 "每句一行便于 diff"。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindNoconstraint / design / directive / preferencepreference
scopeNoglobal(全局)/ project(当前项目)/ user(用户级)。 写 global 前自问:**这条对任意目录的任意会话都成立吗?** 提及具体 项目/仓库/书稿/某次任务的一律 scope=project——未注册目录会落入本目录 指纹临时桶("dir:..."),只被本目录的会话继承,绝不广播成全局记忆。global
contentYes记忆内容(单条 ≤ 400 字,且须放得进本桶字符配额;超长改指针条目)
supersedesNo可选,被本条置换失效的旧 memory id(偏好被改 = 新条 supersede 旧条,Zep 失效语义不删除)
source_refsNo可选,溯源 id 列表(回指 memo/report/meeting,蒸馏提升时用)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It extensively documents behavioral traits: quota/overflow behavior (returns all bucket entries + usage gap on overflow), security scanning (rejects invisible Unicode, prompt-injection patterns, credential forms since entries enter agents' system prompts), the injection truncation priority (constraint>design>directive>preference), and the '存得下的一定传得到' guarantee. Loses one point only because the exact return format on success isn't described (though output schema exists).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but densely informative — every section earns its place, covering purpose, write-check, quota, overflow protocol, pointer-entry strategy, security, and kind taxonomy. It uses clear structural markers (bold, bulleted kind categories, code examples) and front-loads the core purpose. The only deduction is length; while justified, it's substantial and slightly dense for quick scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex memory-writing tool with a rich output schema, the description is remarkably complete. It covers the direction-layer concept, quota system across scopes, overflow handling with concrete sibling tool references (memory_invalidate, memory_reconcile_apply, task_memo_add), security constraints, and the kind taxonomy with examples and truncation priority. The pointer-entry pattern for long content and soft-threshold test round out what an agent needs to correctly decide and execute.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all 5 parameters are documented in the schema. The description adds value beyond the schema: it explains the four kinds with concrete examples and their truncation priority ordering, defines scope inheritance semantics (project-specific contents that list specific repos fall to dir: fingerprint buckets, never broadcast globally), the '≤400 char' rule per entry, and the supersedes semantics (Zep invalidation without deletion). This meaningfully enriches what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool adds a 'direction-layer memory' — shared cross-task standing preferences. It distinguishes from sibling task_memo_add (情景层) explicitly and defines the exact scope with detailed kind taxonomy. The verb 'add' plus the complex resource ('direction-layer memory with four kinds') is highly specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Excellent when/when-not guidance. It explicitly says single-task preferences should go to task_memo_add (情景层), not here. It provides a soft-threshold test ('how many future tasks does this affect?'), defines quota limits with per-scope buckets, and explains the overflow protocol (when full, return all entries and require memory_invalidate or memory_reconcile_apply first). It also covers the pointer-entry rewriting strategy and security scanning.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CronusL-1141/AI-company'

If you have feedback or need assistance with the MCP directory API, please join our Discord server