@yugabytedb/meko-mcp 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -33
- package/assets/hooks-handlers/codex-session-end.sh +13 -0
- package/assets/hooks-handlers/cursor-session-start.sh +19 -1
- package/assets/hooks-handlers/lib/capture-notices.js +321 -0
- package/assets/hooks-handlers/lib/capture-state.js +2079 -0
- package/assets/hooks-handlers/lib/capture-status-cli.js +82 -0
- package/assets/hooks-handlers/lib/capture.js +1653 -225
- package/assets/hooks-handlers/lib/checkpoint-timer.js +455 -50
- package/assets/hooks-handlers/lib/kiro-handler.js +738 -0
- package/assets/hooks-handlers/lib/terminal-handoff.js +418 -0
- package/assets/hooks-handlers/session-end.sh +3 -24
- package/assets/hooks-handlers/session-start.sh +8 -1
- package/assets/hooks-handlers/test_checkpoint_timer.sh +162 -0
- package/assets/scripts/meko-statusline.sh +41 -1
- package/assets/scripts/package-desktop-skill.sh +32 -1
- package/assets/skills/meko-mcp-tools/SKILL.md +90 -137
- package/assets/skills/meko-mcp-tools/references/_sections.md +3 -5
- package/assets/skills/meko-mcp-tools/references/tools-agent-id-conventions.md +31 -28
- package/assets/skills/meko-mcp-tools/references/tools-conversation-dedup.md +5 -7
- package/assets/skills/meko-mcp-tools/references/tools-conversation-reasoning.md +50 -0
- package/assets/skills/meko-mcp-tools/references/tools-cookbook.md +69 -49
- package/assets/skills/meko-mcp-tools/references/tools-datapack-workflow.md +6 -6
- package/assets/skills/meko-mcp-tools/references/tools-known-limitations.md +29 -5
- package/assets/skills/meko-mcp-tools/references/tools-memory-vs-conversation.md +29 -92
- package/assets/skills/meko-mcp-tools/references/tools-overview.md +42 -40
- package/assets/skills/meko-mcp-tools/references/tools-rag-workflow.md +1 -2
- package/assets/skills/meko-mcp-tools/references/tools-troubleshooting.md +18 -11
- package/assets/skills/meko-mcp-tools/references/tools-user-id-conventions.md +10 -9
- package/assets/skills/meko-mcp-tools-desktop/SKILL.md +51 -44
- package/assets/skills/meko-mcp-tools-desktop/desktop/README.md +6 -6
- package/assets/skills/meko-mcp-tools-desktop/references/_sections.md +2 -2
- package/assets/skills/meko-mcp-tools-desktop/references/tools-agent-id-conventions.md +34 -25
- package/assets/skills/meko-mcp-tools-desktop/references/tools-conversation-reasoning.md +50 -0
- package/assets/skills/meko-mcp-tools-desktop/references/tools-cookbook.md +63 -37
- package/assets/skills/meko-mcp-tools-desktop/references/tools-known-limitations.md +4 -4
- package/assets/skills/meko-mcp-tools-desktop/references/tools-memory-vs-conversation.md +19 -22
- package/assets/skills/meko-mcp-tools-desktop/references/tools-overview.md +42 -40
- package/assets/skills/meko-mcp-tools-desktop/references/tools-rag-workflow.md +1 -2
- package/assets/skills/meko-mcp-tools-desktop/references/tools-troubleshooting.md +3 -17
- package/assets/skills/meko-select-datapack-desktop/SKILL.md +31 -21
- package/assets/skills/meko-select-datapack-desktop/references/cookbook.md +8 -8
- package/assets/skills/meko-select-datapack-desktop/references/role-display-future.md +41 -0
- package/assets/skills/meko-select-datapack-desktop/references/troubleshooting.md +1 -1
- package/bin/create-meko-setup.mjs +93 -16
- package/lib/capture-status.mjs +67 -0
- package/lib/clients/aliases.mjs +5 -0
- package/lib/clients/claude-code.mjs +8 -4
- package/lib/clients/claude-desktop.mjs +133 -4
- package/lib/clients/codex.mjs +29 -11
- package/lib/clients/common.mjs +2 -0
- package/lib/clients/cursor.mjs +7 -2
- package/lib/clients/index.mjs +2 -0
- package/lib/clients/kiro.mjs +705 -0
- package/lib/config.mjs +90 -0
- package/lib/detect.mjs +7 -2
- package/lib/installer.mjs +1 -0
- package/lib/migrate/adapters/codex.mjs +490 -0
- package/lib/migrate/id.mjs +28 -3
- package/lib/migrate/orchestrator.mjs +34 -7
- package/lib/migrate.mjs +4 -2
- package/lib/prompt.mjs +17 -2
- package/lib/url-selection.mjs +55 -0
- package/package.json +4 -4
- package/assets/skills/meko-mcp-tools/references/tools-scope-permissions.md +0 -71
- package/assets/skills/meko-mcp-tools-desktop/references/tools-scope-permissions.md +0 -71
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
8
8
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
9
|
-
SKILLS_ROOT="$SCRIPT_DIR/../skills"
|
|
9
|
+
SKILLS_ROOT="${MEKO_DESKTOP_SKILLS_ROOT:-$SCRIPT_DIR/../skills}"
|
|
10
10
|
SKILL_NAMES=("meko-mcp-tools-desktop" "meko-select-datapack-desktop")
|
|
11
|
+
XML_TAG_PATTERN='</?[[:alpha:]_:][[:alnum:]_.:-]*([[:blank:]][^<>]*)?[[:blank:]]*/?>'
|
|
11
12
|
|
|
12
13
|
for SKILL_NAME in "${SKILL_NAMES[@]}"; do
|
|
13
14
|
if [ ! -d "$SKILLS_ROOT/$SKILL_NAME" ]; then
|
|
@@ -19,6 +20,36 @@ for SKILL_NAME in "${SKILL_NAMES[@]}"; do
|
|
|
19
20
|
echo "Error: SKILL.md not found in $SKILLS_ROOT/$SKILL_NAME/" >&2
|
|
20
21
|
exit 1
|
|
21
22
|
fi
|
|
23
|
+
|
|
24
|
+
if ! grep -q '^description:[[:space:]]*' "$SKILLS_ROOT/$SKILL_NAME/SKILL.md"; then
|
|
25
|
+
echo "Error: SKILL.md description is missing: $SKILL_NAME" >&2
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
DESCRIPTION="$(awk '
|
|
30
|
+
/^description:[[:space:]]*/ {
|
|
31
|
+
in_description = 1
|
|
32
|
+
value = $0
|
|
33
|
+
sub(/^description:[[:space:]]*/, "", value)
|
|
34
|
+
if (value !~ /^[>|][+-]?$/) printf "%s ", value
|
|
35
|
+
next
|
|
36
|
+
}
|
|
37
|
+
in_description && /^[^[:space:]]/ { exit }
|
|
38
|
+
in_description {
|
|
39
|
+
sub(/^[[:space:]]+/, "")
|
|
40
|
+
printf "%s ", $0
|
|
41
|
+
}
|
|
42
|
+
' "$SKILLS_ROOT/$SKILL_NAME/SKILL.md")"
|
|
43
|
+
|
|
44
|
+
if [[ -z "${DESCRIPTION//[[:space:]]/}" ]]; then
|
|
45
|
+
echo "Error: SKILL.md description is empty: $SKILL_NAME" >&2
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if printf '%s\n' "$DESCRIPTION" | grep -Eq "$XML_TAG_PATTERN"; then
|
|
50
|
+
echo "Error: SKILL.md description cannot contain XML-like tags: $SKILL_NAME" >&2
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
22
53
|
done
|
|
23
54
|
|
|
24
55
|
for SKILL_NAME in "${SKILL_NAMES[@]}"; do
|
|
@@ -4,180 +4,123 @@ description: Behavioral guide for AI agents using Meko MCP tools. Triggers when
|
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
author: Meko
|
|
7
|
-
version: "3.
|
|
7
|
+
version: "3.1.0"
|
|
8
8
|
tags: mcp, tools, datapack, memory, conversation, rag, meko
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
# Meko MCP Tools — Agent Behavioral Guide
|
|
12
12
|
|
|
13
|
-
Meko is agent-native data infrastructure that enables continuous learning from context windows through collective memory and shared knowledge. This skill teaches you how to use Meko's
|
|
13
|
+
Meko is agent-native data infrastructure that enables continuous learning from context windows through collective memory and shared knowledge. This skill teaches you how to use Meko's 23 MCP tools available in production.
|
|
14
14
|
|
|
15
15
|
**Read this first.** On Claude Code, conversation capture is automatic (SessionStart / PreCompact / SessionEnd hooks) and the Meko server extracts durable memories from the captured turns on its own. Facts the user states in conversation are saved for you — you do **not** proactively call `memory_add` for them. Your active jobs are: **recall** what's already known (`memory_search`, `knowledgebase_search`), and the **few** save cases automatic extraction cannot reach. Details below.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Non-negotiable operating contracts
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Apply these rules before the longer guidance below. They are service-contract safeguards, not suggestions.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
- **Team-shared knowledge** — When the user promotes important memories from the Cloud UI's Learnings tab (or uploads documents via **Add Knowledge**), the content becomes visible to every member of the datapack. Queryable via `knowledgebase_search`.
|
|
23
|
-
- **Conversation history** — Preserve full dialog exchanges with reasoning traces for audit, replay, and learning transfer.
|
|
24
|
-
- **Decision traces** — Capture how and why decisions were made, enabling debugging and continuous improvement.
|
|
21
|
+
### 1. Distinguish failure from an empty search
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
Inspect the response envelope before its contents:
|
|
27
24
|
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- You are managing datapacks
|
|
32
|
-
- You want to understand scope/permission requirements, `agent_id` conventions, or `datapack_id` routing
|
|
25
|
+
1. If `error` or an error-shaped `detail` is present, the search **failed** and its findings are **unknown**. Say exactly that. Never say "nothing was found," "no results," or "the store is empty."
|
|
26
|
+
2. Do not retry quota (`free_tier_limit_reached`) or permission errors. Report the error and stop. Retry only documented transient failures, with a bounded backoff.
|
|
27
|
+
3. Only a successful response with an explicit empty `results` array proves a legitimate empty search.
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
### 2. Treat `memory_get_all` as a recent window, never an export
|
|
35
30
|
|
|
36
|
-
`
|
|
31
|
+
`memory_get_all` returns roughly 20 recent rows plus a `total`; it is not a listing tool. Inspect the row count against `total`, and never state or imply you have listed everything — the only trustworthy count is `total`. Calling it more than once does not add up to a complete export: a second call with `promoted=true` (or any other variant) is just another recent window, not the remaining rows, so two calls are still not a full listing. Do not invent `limit`, `offset`, `page`, or `page_size` arguments—the tool rejects pagination. Use targeted `memory_search` or `memory_get_by_id` for older or exact content. If the user needs a complete export, report that MCP currently has no complete enumeration path.
|
|
37
32
|
|
|
38
|
-
|
|
33
|
+
### 3. Separate retrieval breadth from reader context
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
- **Common bucket** — `meko_agent`. The cross-project bucket for facts any agent should see regardless of project (user identity, global preferences). Empty / missing `agent_id` lands here automatically; you can also pass it explicitly.
|
|
42
|
-
- **Loose name** — non-coding clients (Claude Desktop, generic MCP) use a stable client name like `claude_desktop`. Not relevant in this skill (Claude Code is a coding agent).
|
|
35
|
+
Retrieve up to about 25 candidates for recall, preserve relevance order, and pass at most the top 10 useful evidence items to final reasoning. Never paste all 25–30 results into the reader by default. Raise the reader window only after measuring misses outside the top 10. When dated claims conflict, resolve recency only among claims about the same entity and field; do not sort the whole result set by date.
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
agent_id = "claude_code:meko-mcp-server" # this session's project bucket
|
|
46
|
-
agent_id = "meko_agent" # cross-project facts
|
|
47
|
-
```
|
|
37
|
+
If no candidate supports an answer, abstain: say the retrieved evidence does not cover it. Never fill the slot with a guess, and when the task offers fixed options, choose the one that *means* "not enough information" rather than defaulting to any particular option.
|
|
48
38
|
|
|
49
|
-
|
|
39
|
+
### 4. Verify writes and enforce real isolation
|
|
40
|
+
|
|
41
|
+
- A success-shaped write response is not proof. Read back memories and conversations. For artifacts, compute SHA-256 locally, require the matching `content_hash`, then read back important bytes. A missing hash means the upload is unconfirmed.
|
|
42
|
+
- `agent_id` attributes writes; it is not an access boundary. Put projects, tenants, or security domains that must not co-discover content in separate datapacks.
|
|
43
|
+
|
|
44
|
+
## `agent_id` — multi-agent identity
|
|
45
|
+
|
|
46
|
+
Use the SessionStart-injected `agent_id` verbatim. It normally has shape `<client>:<repo-basename>`. Use `meko_agent` only for deliberately cross-project writes; empty write IDs also route there.
|
|
50
47
|
|
|
51
48
|
**Read scoping varies by tool:**
|
|
52
|
-
- `memory_search` / `memory_get_all`
|
|
53
|
-
- `
|
|
49
|
+
- `memory_search` / `memory_get_all` — scoped to `(datapack_id, user_id)`; `agent_id` does not filter results. Do not fan out reads by agent.
|
|
50
|
+
- `conversation_get` — agent-owned: pass the exact `agent_id` that created the conversation; any other value returns `agent_id_mismatch`.
|
|
51
|
+
- `conversation_list` — user/datapack scoped; `agent_id` is trace attribution only.
|
|
52
|
+
- `knowledgebase_search` — datapack scoped; `agent_id` is ignored.
|
|
54
53
|
|
|
55
|
-
See `tools-agent-id-conventions.md` for the full model, including how promotion works and how to phrase broad-query responses to the user.
|
|
54
|
+
See `tools-agent-id-conventions.md` for the full model, including how promotion works and how to phrase broad-query responses to the user. Legacy IDs remain readable through the same personal-memory read.
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
## Use Meko for durable memory, not as a replacement for project files
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
Use Meko for durable facts that must survive sessions, be found by meaning, or be shared across agents. Keep source code, exact artifacts, canonical specifications, and whole documents in their normal file or artifact stores; use exact lookup when identity is known. Do not create an ad-hoc local "agent memory" file as a substitute for Meko.
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
On Claude Code, memory reaches Meko two ways:
|
|
62
61
|
|
|
63
62
|
- **Automatic capture + extraction** (the dominant path) — the hooks capture this session's turns and the server extracts memories from them. Facts the user states are stored without any tool call from you.
|
|
64
63
|
- **Explicit `memory_add`** (the narrow path) — only for the cases extraction can't reach (see "When to call memory_add" below).
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
For meaning-based recall, call `memory_search`. For an exact known filename, key, hash, or complete document, use the corresponding direct file or artifact lookup. If a Meko call fails, report the failure; do not silently replace durable shared memory with a private local note.
|
|
67
66
|
|
|
68
67
|
## When spawning subagents
|
|
69
68
|
|
|
70
|
-
Subagents
|
|
71
|
-
|
|
72
|
-
### Rule (parent's responsibility)
|
|
73
|
-
|
|
74
|
-
**Every spawn prompt MUST prepend an inherited-context block** with the parent's actual `agent_id` and `conversation_id`:
|
|
69
|
+
Subagents do not receive SessionStart context. Every spawn prompt must include:
|
|
75
70
|
|
|
76
71
|
```
|
|
77
72
|
Meko context (inherited from parent session):
|
|
78
73
|
- agent_id: "<parent's agent_id, verbatim>"
|
|
79
74
|
- conversation_id: "<parent's conversation_id>"
|
|
80
|
-
- Use these for all Meko MCP calls.
|
|
75
|
+
- Use these verbatim for all Meko MCP calls.
|
|
81
76
|
```
|
|
82
77
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
**Default: inject unconditionally.** The skill-listing heuristic (subagent seeing `meko-agent-skills:meko-mcp-tools` in its available skills) is unreliable, and injecting a 4-line block costs nothing. Don't try to predict whether the subagent will touch Meko — inject always.
|
|
86
|
-
|
|
87
|
-
### What the subagent does with it
|
|
78
|
+
Reuse the inherited conversation unless the parent or user explicitly requests a fresh scope. Always reuse the inherited agent ID.
|
|
88
79
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
1. **Default: reuse the inherited `conversation_id`.** The parent decides scope. Do NOT re-derive these values. Do NOT create a fresh conversation on a "feels separate" judgment — a separate-feeling task is not an explicit signal.
|
|
92
|
-
2. **Exception: create a new conversation only when the spawn prompt (or user) explicitly says so.** An explicit signal means the parent's prompt says something like "use a fresh conversation" or "start your own conversation scope," or the user directly asks for one. Absent that signal, reuse.
|
|
93
|
-
|
|
94
|
-
Whichever path applies, always use the inherited `agent_id` as-is — do not replace it, slugify it, or fall back to a constant.
|
|
95
|
-
|
|
96
|
-
If the inherited block is **absent**, the subagent MUST NOT guess — see the self-diagnosis subsection below.
|
|
97
|
-
|
|
98
|
-
### You may be a subagent — self-diagnosis
|
|
99
|
-
|
|
100
|
-
**Tell-tale signs:**
|
|
101
|
-
- You did NOT receive a SessionStart `additionalContext` block naming a Meko `conversation_id`.
|
|
102
|
-
- You see `meko-agent-skills:meko-mcp-tools` in your available skills but no watermark / inherited-context reference in your initial prompt.
|
|
103
|
-
- Your spawn prompt mentions you were "spawned" / "dispatched" / "launched" by a parent, or mentions a `Task` / `Agent` tool.
|
|
104
|
-
|
|
105
|
-
**What to do:**
|
|
106
|
-
- Look for a `Meko context (inherited from parent session):` block in the spawn prompt. If present, use those values verbatim for every Meko MCP call.
|
|
107
|
-
- If absent, **refuse to invoke Meko write tools** and respond to the parent with a clarification request: ask for the parent's `agent_id` and `conversation_id`. The parent can re-dispatch with the block prepended.
|
|
108
|
-
|
|
109
|
-
**What NOT to do:**
|
|
110
|
-
- Do NOT fall back to the nil UUID (`"00000000-0000-0000-0000-000000000000"`) for `conversation_id` — that's an orphan-write pattern.
|
|
111
|
-
- Do NOT invent an `agent_id`. The right value is whatever the parent is using (typically `claude_code:<repo-basename>`); don't assume `"agent"`, `"claude-code"`, `"meko_agent"`, or a different basename. Ask.
|
|
112
|
-
- Do NOT silently create your own conversation to "just get moving" — ask the parent.
|
|
113
|
-
|
|
114
|
-
Subagents cannot auto-discover the parent's watermark today: Claude Code does not expose a `CLAUDE_PARENT_SESSION_ID` env var or any equivalent marker file to subagent processes (see the spike note in `skills/hooks-handlers/lib/capture.js`). Prompt injection is the only enforcement mechanism.
|
|
80
|
+
**You may be the subagent.** If no SessionStart context named a `conversation_id`, assume you are one and look for the block above in your prompt. If it is absent, do not guess, invent IDs, use the nil UUID, or write — ask the parent for both values.
|
|
115
81
|
|
|
116
82
|
## Core principle: capture is automatic — recall, don't re-store
|
|
117
83
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
So your Meko reflexes are:
|
|
84
|
+
On Claude Code, hooks capture user turns and the server extracts durable memories. Do not duplicate facts the user states with `memory_add`.
|
|
121
85
|
|
|
122
|
-
|
|
123
|
-
2. **Save only what capture can't reach** (the three narrow cases below).
|
|
124
|
-
3. **Never** re-store a fact the user just said. **Never** write memories to local files.
|
|
86
|
+
Recall first; save only what capture cannot reach; never re-store a just-stated fact.
|
|
125
87
|
|
|
126
88
|
### When the user shares information
|
|
127
89
|
|
|
128
90
|
| Signal in conversation | What to do |
|
|
129
91
|
|---|---|
|
|
130
92
|
| User states a fact about themselves, their team, tools, or preferences | **Nothing — automatic capture + extraction stores it.** Just answer. |
|
|
131
|
-
| User corrects
|
|
93
|
+
| User corrects a prior fact | Capture adds the correction but may retain the old fact; find and update/delete the stale memory when it must not survive. |
|
|
132
94
|
| User explicitly says "remember this" / "save this to memory" | `memory_add` (verbatim). This is the clearest explicit-save case. |
|
|
133
|
-
| A durable fact appears only in
|
|
134
|
-
| User asks "what do you know about X?" |
|
|
95
|
+
| A durable fact appears only in assistant output or a tool result | `memory_add`; automatic extraction reads the user turn. |
|
|
96
|
+
| User asks "what do you know about X?" | Search both production retrieval surfaces: `memory_search` for personal context, then `knowledgebase_search` for shared datapack knowledge when relevant. |
|
|
135
97
|
| User asks "what do we (as a team) know about X?" or about uploaded documents | `knowledgebase_search` (returns uploaded docs + promoted memories). |
|
|
98
|
+
| User asks to share private memories | Follow the exact-ID `memory_promote` confirmation workflow below. |
|
|
136
99
|
| User provides structured/tabular data (CSV, data dictionary) | Not natively supported via MCP. Point the user at the UI's Add Knowledge upload; do not `memory_add` row-by-row. |
|
|
137
100
|
| User wants to add documents to the team's knowledge base | Point them at the Cloud UI flow — Datapack → Actions → **Add Knowledge** (PDF/TXT/MD/JSON/MP4, 5MB each, 10/batch). MCP ingestion tools are not available on Cloud. |
|
|
138
101
|
|
|
139
|
-
### When to call memory_add
|
|
140
|
-
|
|
141
|
-
Automatic capture handles the rest, so explicit `memory_add` is reserved for exactly three cases:
|
|
142
|
-
|
|
143
|
-
1. **Explicit request** — the user says "remember this" / "save this."
|
|
144
|
-
2. **Output-only / tool-derived fact** — a durable fact that lives only in the assistant's output or a tool result, never in a user turn (extraction only sees the user turn).
|
|
145
|
-
3. **Overwriting correction** — a prior fact was negated and the stale memory must not survive (extraction is additive; pair `memory_add`/`memory_update` with a `memory_delete_by_id` of the old one).
|
|
102
|
+
### When to call memory_add
|
|
146
103
|
|
|
147
|
-
|
|
104
|
+
Use it only for an explicit save request, an output/tool-derived durable fact, or a correction whose stale predecessor must be replaced. Store one focused fact verbatim; for corrections, update/delete the stale record.
|
|
148
105
|
|
|
149
106
|
## Automatic conversation capture
|
|
150
107
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
1. **Background checkpoint timer** — runs every 10 minutes, captures new exchanges without interrupting the agent
|
|
154
|
-
2. **PreCompact hook** — fires before context compaction, captures everything before compaction discards context
|
|
155
|
-
3. **SessionEnd hook** — fires at session end, captures remaining exchanges
|
|
156
|
-
|
|
157
|
-
All three are handled automatically. **Do NOT set up CronCreate for conversation capture** — it interrupts running tool calls and causes disruptive retry cycles.
|
|
108
|
+
Background, PreCompact, and SessionEnd hooks capture the conversation automatically. Do not create a separate capture cron.
|
|
158
109
|
|
|
159
110
|
### What to do at session start
|
|
160
111
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
1. **Created a Meko conversation** — `conversation_id` is injected into `additionalContext` on the first turn. Use that value for all subsequent MCP tool calls that accept `conversation_id`.
|
|
164
|
-
2. **Echoed the session's `agent_id`** — also injected into `additionalContext`. Use the injected value verbatim for project-scoped Meko tool calls. It's a per-session value derived from the cwd (shape: `claude_code:<repo-basename>`), not a constant. For genuinely cross-project facts, write/read with `agent_id="meko_agent"` (the common bucket) instead.
|
|
165
|
-
3. **Preloaded recent memories** — `additionalContext` may include a `### Memories from prior sessions` block. Inspect it before acting so you don't re-ask questions the user has already answered.
|
|
166
|
-
|
|
167
|
-
If `additionalContext` is absent or empty (hook failed, MCP unavailable), ask the user for their `agent_id` — do not invent one. See `tools-agent-id-conventions.md`.
|
|
112
|
+
Use the injected `conversation_id` and `agent_id` verbatim and inspect any preloaded memories. If injection is absent, do not invent values; ask for the missing identity or create a conversation only when the applicable workflow permits it.
|
|
168
113
|
|
|
169
114
|
### Before potentially destructive actions
|
|
170
115
|
|
|
171
|
-
|
|
116
|
+
When Meko is available and the user may have stored relevant preferences, search for them before deleting, overwriting, or restructuring user content:
|
|
172
117
|
|
|
173
118
|
```
|
|
174
|
-
memory_search(
|
|
119
|
+
memory_search(query="destructive <action type> preferences feedback",
|
|
175
120
|
agent_id=<your agent_id>, conversation_id=<session_conversation_id>)
|
|
176
121
|
```
|
|
177
122
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
If a relevant feedback memory exists (e.g., "always ask before deleting content"), confirm with the user before proceeding. If the search is empty, proceed, but treat the action as irreversible and prefer a dry-run / preview when one is available.
|
|
123
|
+
A single search covers all of this user's agents. Memory is supplemental evidence, not authorization: a relevant preference can require more caution, but an empty search never authorizes destruction. Follow host approval rules and prefer previews.
|
|
181
124
|
|
|
182
125
|
### Capture rules
|
|
183
126
|
|
|
@@ -195,47 +138,70 @@ In the examples below, `<your-agent-id>` means the value the SessionStart hook i
|
|
|
195
138
|
### memory_add — correct call pattern
|
|
196
139
|
|
|
197
140
|
Only for the three narrow cases in "When to call memory_add" above — not for facts the user stated in conversation (those are captured automatically). The example below is an explicit "remember this" save:
|
|
141
|
+
|
|
198
142
|
```
|
|
199
|
-
memory_add(
|
|
143
|
+
memory_add(
|
|
200
144
|
text="Remember: deploy scripts must be run from the repo root, never a subdir",
|
|
201
145
|
agent_id="<your-agent-id>",
|
|
202
146
|
conversation_id="<session_conversation_id>")
|
|
203
147
|
```
|
|
204
|
-
|
|
148
|
+
|
|
149
|
+
Required parameters: `text`, `conversation_id`. On **writes**, `conversation_id` must be a real UUID (from `conversation_create` or the SessionStart hook) — writes attached to a nil/empty conversation are orphaned in Langfuse traces. NEVER pass `"current"` or other non-UUID values. `agent_id` is technically optional — empty/missing routes the write into the `meko_agent` common bucket — but for project-scoped facts pass the SessionStart-injected value verbatim.
|
|
150
|
+
|
|
151
|
+
**Write one coherent fact per memory**, with the identifiers a later search will use — never a transcript or multi-topic dump; focused memories retrieve better and read far faster.
|
|
205
152
|
|
|
206
153
|
### memory_search — correct call pattern
|
|
154
|
+
|
|
207
155
|
```
|
|
208
|
-
memory_search(
|
|
156
|
+
memory_search(
|
|
209
157
|
query="user role",
|
|
210
158
|
agent_id="<your-agent-id>",
|
|
211
159
|
conversation_id="<session_conversation_id>")
|
|
212
160
|
```
|
|
213
|
-
Required parameters: `scope`, `query`, `agent_id`, `conversation_id`. On **`memory_search`** specifically, `conversation_id` is used only for Langfuse trace nesting — it does NOT filter results. Pass the session's UUID so the search span appears under the active conversation in Observe; passing `""` is accepted and means "don't nest under any trace." For conversation-scoped filtering use the separate `run_id` parameter.
|
|
214
161
|
|
|
215
|
-
|
|
216
|
-
```
|
|
217
|
-
memory_search(scope="read", query="user role",
|
|
218
|
-
agent_id="meko_agent", conversation_id="<session_conversation_id>")
|
|
219
|
-
```
|
|
162
|
+
Required parameters: `query`, `agent_id`, `conversation_id`. On **`memory_search`** specifically, `conversation_id` is used only for Langfuse trace nesting — it does NOT filter results. Pass the session's UUID so the search span appears under the active conversation in Observe; passing `""` is accepted and means "don't nest under any trace."
|
|
220
163
|
|
|
221
|
-
|
|
164
|
+
`agent_id` does not filter what `memory_search` returns — one call covers every agent's rows for this user, including the `meko_agent` bucket (see Read scoping above).
|
|
165
|
+
|
|
166
|
+
Evidence going into reasoning follows operating contract 3 (retrieve ≤ ~25, pass ≤ ~10).
|
|
167
|
+
|
|
168
|
+
### memory_get_all — recent-window pattern
|
|
169
|
+
|
|
170
|
+
Follow operating contract 2: a ~20-row recent window plus an honest `total` — no pagination, no completeness claims. Use targeted `memory_search` or `memory_get_by_id` instead.
|
|
222
171
|
|
|
223
172
|
### knowledgebase_search — correct call pattern
|
|
173
|
+
|
|
224
174
|
```
|
|
225
|
-
knowledgebase_search(
|
|
175
|
+
knowledgebase_search(
|
|
226
176
|
query="...",
|
|
227
177
|
agent_id="<anything — ignored>",
|
|
228
178
|
conversation_id="<session_conversation_id>",
|
|
229
179
|
datapack_id="<datapack UUID>",
|
|
230
180
|
limit=10)
|
|
231
181
|
```
|
|
232
|
-
|
|
182
|
+
|
|
183
|
+
Required parameters: `query`, `agent_id`, `conversation_id`, `datapack_id`. `datapack_id` has no default here. `agent_id` is ignored for filtering — results are the team's shared knowledge on the datapack regardless of what you pass.
|
|
184
|
+
|
|
185
|
+
For recalling working memories — especially recently-changed facts — prefer `memory_search`; the knowledge base is the team's publish/archive surface.
|
|
186
|
+
|
|
187
|
+
### memory_promote — explicit confirmation required
|
|
188
|
+
|
|
189
|
+
`memory_promote` is destructive and non-idempotent: it makes selected content visible to the datapack, moves the memories into shared knowledge, and evicts the private records. There is no MCP rollback.
|
|
190
|
+
|
|
191
|
+
1. Use `memory_search` or `memory_get_all` to obtain exact memory UUIDs from the `id` field. Never pass any other identifier.
|
|
192
|
+
2. Present each exact candidate memory and its UUID to the user.
|
|
193
|
+
3. State that promotion is one-way, team-visible, and removes the private records.
|
|
194
|
+
4. Obtain explicit confirmation for those exact candidates before calling `memory_promote`.
|
|
195
|
+
5. Call it with the active `conversation_id`, exact `memory_ids`, intended `agent_id`, and intended `datapack_id`. If a legacy deployment exposes `scope`, use the minimum `write` scope; do not escalate to `admin`.
|
|
196
|
+
6. Only datapack owners and maintainers may promote. If a viewer/contributor receives 403, or any authentication/permission error occurs, report it and stop. Do not retry with a broader scope, another datapack, or altered identity.
|
|
197
|
+
7. After success, optionally verify visibility with `knowledgebase_search`. Do not claim rollback is possible.
|
|
198
|
+
|
|
199
|
+
The Cloud UI's Learnings tab remains an alternative user-driven path.
|
|
233
200
|
|
|
234
201
|
### Critical parameter rules
|
|
235
202
|
|
|
236
203
|
- **agent_id**: Per-session value, injected via `additionalContext` by the SessionStart hook. Shape: `<client>:<repo-basename>`. Pass verbatim on project-scoped writes and reads. Pass `"meko_agent"` for the cross-project common bucket (or empty/omit — server rewrites empty to `meko_agent`). Ignored on `knowledgebase_search`. See `tools-agent-id-conventions.md`.
|
|
237
|
-
- **conversation_id**:
|
|
238
|
-
- **scope**: Only `"read"`, `"write"`, or `"admin"`. Nothing else. Use the minimum the code actually requires (the per-tool cookbook shows it).
|
|
204
|
+
- **conversation_id**: the conversation's ID *is* its trace ID, so every call carrying it becomes a span under that conversation in the Observe hub. On write tools (`memory_add`, `conversation_add_message`) pass a real UUID from `conversation_create` or the SessionStart hook — a nil/empty value orphans the trace. On `memory_search` it only nests the trace (it does not filter), and empty-string is accepted; on `memory_get_all` and most read tools, still pass the session UUID when you have one. Never pass `"current"` or other non-UUID junk.
|
|
239
205
|
- **When in doubt about optional parameters, omit them.** The server has sensible defaults.
|
|
240
206
|
|
|
241
207
|
### Verify after writing
|
|
@@ -244,6 +210,7 @@ Never confirm a successful save to the user without first validating via a read-
|
|
|
244
210
|
|
|
245
211
|
- **After `memory_add`**: call `memory_search` with a distinctive token from the stored text (a name, UUID, rare phrase — not a common word). Assert the new memory appears in the results. Only then tell the user it was saved.
|
|
246
212
|
- **After `conversation_add_message`**: call `conversation_get(include_messages=true)` with the returned `conversation_id`. Assert `message_count` > 0 and that the new message is in the returned list.
|
|
213
|
+
- **After `artifact_put`**: operating contract 4 — the locally-computed SHA-256 must match the returned `content_hash` (a rate-limited or errored put carries **none**); read back important artifacts via `artifact_get` and compare bytes.
|
|
247
214
|
- **On verification failure**: tell the user the save did not succeed — do **not** claim it did. Include the verification-failure detail (empty search, missing message, HTTP error) so they can act — wrong datapack, scope mismatch, expired API key are the common causes.
|
|
248
215
|
|
|
249
216
|
### First-run connection test
|
|
@@ -254,7 +221,6 @@ On the first Meko tool call in a fresh session (no prior Meko tool call since pr
|
|
|
254
221
|
|
|
255
222
|
**Canary memory shape.** This is the spec; keep the fields stable so support can grep for them.
|
|
256
223
|
|
|
257
|
-
- `scope`: `"write"`
|
|
258
224
|
- `agent_id`: the session's `agent_id` (from `additionalContext`); not a constant
|
|
259
225
|
- `conversation_id`: the session's `conversation_id` (from `additionalContext`). If the hook failed and you truly have no conversation_id, call `conversation_create` first and use the returned id — do not use a nil UUID, it orphans the canary trace.
|
|
260
226
|
- `text`: `"Meko connection test: <client> @ <installer-version> — <ISO timestamp>. Safe to delete."`
|
|
@@ -266,33 +232,20 @@ On the first Meko tool call in a fresh session (no prior Meko tool call since pr
|
|
|
266
232
|
|
|
267
233
|
**Reporting.** This is user-visible — the whole point is to give the user concrete proof. On success: `"Meko connection OK (canary round-trip succeeded)"`. On failure, name the failing step and include the raw error: `"Meko canary failed at memory_add: <error>. Likely causes: wrong datapack, expired API key, server unreachable."`
|
|
268
234
|
|
|
269
|
-
##
|
|
235
|
+
## Budgeting calls
|
|
270
236
|
|
|
271
|
-
|
|
272
|
-
2. **Scope hierarchy**: `read < write < admin` — every tool validates scope at entry. Only three valid values: `"read"`, `"write"`, `"admin"`. Using anything else (e.g., `"all"`) will fail. Tool docstrings sometimes say `"Pass 'admin'"` but the code only requires `"read"` or `"write"` — use the minimum the code actually enforces.
|
|
273
|
-
3. **datapack_id routing**: DB, RAG, and memory tools accept optional `datapack_id` (default datapack if omitted). `knowledgebase_search` is the exception: `datapack_id` is **required** there.
|
|
274
|
-
4. **agent_id is multi-agent**: Each client+project uses its own `agent_id` (shape `<client>:<repo-basename>`). Writes are scoped to `(datapack_id, user_id, agent_id)`. Personal reads (`memory_search`, `memory_get_all`) filter strictly on this tuple. Empty/missing `agent_id` lands in the `meko_agent` common bucket — use it explicitly for cross-project facts. `knowledgebase_search` ignores `agent_id` entirely and returns the team-shared knowledge on the datapack. See `tools-agent-id-conventions.md`.
|
|
275
|
-
5. **Personal memory vs. team-shared knowledge**: Un-promoted memories (`mem0_collection`) are scoped per-user and per-agent — only you see them. The user can promote important memories to Shared Knowledge via the Cloud UI's Learnings tab, which makes them visible to every team member on the datapack (user_id filter stripped). `knowledgebase_search` is the MCP read path for both Shared Knowledge and uploaded documents. See `tools-memory-vs-conversation.md`.
|
|
276
|
-
6. **conversation_id IS the Langfuse trace ID**: every MCP tool call inside a conversation becomes a span under that trace. Observable in the Meko UI's Observe hub (`/observe-hub?project=<langfuse_pid>&session=<conversation_id>`) or directly from a datapack's Conversations tab via the **Open in Observe** button. See `tools-memory-vs-conversation.md`.
|
|
277
|
-
7. **Adding documents or growing a knowledge base is UI-only on Cloud today**: users upload files via Datapack → Actions → **Add Knowledge** (PDF/TXT/MD/JSON/MP4, 5MB each). The MCP ingestion tools are not available on Cloud. See `tools-rag-workflow.md`.
|
|
278
|
-
8. **Conversation dedup**: `conversation_add_message` supports seed-based deterministic trace IDs to prevent duplicates.
|
|
279
|
-
9. **Memory latencies are not cheap**: observed on prod 2026-05-07 — `memory_add` 12-21s/call (calls OpenAI), `memory_search` 2-6s/call. Budget accordingly.
|
|
280
|
-
10. **Known limitations**: see `tools-known-limitations.md` before attempting write operations on tools that appear in the catalog but aren't available on Cloud.
|
|
281
|
-
11. **Error recovery**: Connection errors are common with memory tools — see `tools-troubleshooting.md` for retry strategies and fallbacks.
|
|
237
|
+
`memory_add` takes ~10s for a one-line fact and ~20-30s for document-sized text; `memory_search` ~2-6s. Sustained bulk ingest throttles to roughly per-call latency — run large ingests as background jobs. `memory_search`, `knowledgebase_search`, and `memory_add` also draw from **lifetime per-user quotas** on Free/Standard tiers, so budget latency *and* call count. `datapack_id` is optional on most tools (default datapack) but **required** on `knowledgebase_search`. See `tools-known-limitations.md`.
|
|
282
238
|
|
|
283
239
|
## Reference sections
|
|
284
240
|
|
|
285
241
|
| File | What it covers |
|
|
286
242
|
|------|---------------|
|
|
287
|
-
| `tools-overview.md` | Complete catalog of all
|
|
243
|
+
| `tools-overview.md` | Complete catalog of all 23 tools available in production, with decision tree |
|
|
288
244
|
| `tools-cookbook.md` | Per-tool examples with correct parameters, responses, and error cases |
|
|
289
245
|
| `tools-memory-vs-conversation.md` | When to use memory tools vs conversation tools |
|
|
290
246
|
| `tools-datapack-workflow.md` | Datapack lifecycle and datapack_id routing |
|
|
291
247
|
| `tools-rag-workflow.md` | End-to-end RAG pipeline flow |
|
|
292
|
-
| `tools-write-guardrails.md` | Blocked SQL patterns and configurable limits |
|
|
293
|
-
| `tools-scope-permissions.md` | read/write/admin permission hierarchy |
|
|
294
248
|
| `tools-agent-id-conventions.md` | Naming rules and constraints for agent_id |
|
|
295
249
|
| `tools-conversation-dedup.md` | Seed-based trace deduplication |
|
|
296
|
-
| `tools-db-query-patterns.md` | Read-only vs write query execution patterns |
|
|
297
250
|
| `tools-troubleshooting.md` | Error recovery, retry strategies, stuck pipeline diagnosis |
|
|
298
|
-
| `tools-known-limitations.md` |
|
|
251
|
+
| `tools-known-limitations.md` | Lifetime quotas, the `memory_get_all` window, `run_id` scoping, missing capabilities |
|
|
@@ -6,17 +6,15 @@ description: Maps reference files to their topics for the meko-mcp-tools skill
|
|
|
6
6
|
# Reference Sections
|
|
7
7
|
|
|
8
8
|
## Tool Selection & Catalog
|
|
9
|
-
- [tools-overview.md](tools-overview.md) — Complete catalog of all
|
|
9
|
+
- [tools-overview.md](tools-overview.md) — Complete catalog of all 23 tools available in production, with a decision tree
|
|
10
10
|
|
|
11
11
|
## Tool-Specific Guidance
|
|
12
12
|
- [tools-memory-vs-conversation.md](tools-memory-vs-conversation.md) — Decision framework: memory_add vs conversation_create/conversation_add_message
|
|
13
|
+
- [tools-conversation-reasoning.md](tools-conversation-reasoning.md) — Authoring the `reasoning` and `plan` fields on `conversation_add_message`, with worked examples
|
|
13
14
|
- [tools-datapack-workflow.md](tools-datapack-workflow.md) — Datapack lifecycle, datapack_id routing, and multi-database patterns
|
|
14
15
|
- [tools-rag-workflow.md](tools-rag-workflow.md) — End-to-end RAG pipeline: source registration, index creation, status polling
|
|
15
|
-
- [tools-db-query-patterns.md](tools-db-query-patterns.md) — Read-only vs write query execution patterns and SQL conventions
|
|
16
16
|
|
|
17
17
|
## Safety & Permissions
|
|
18
|
-
- [tools-write-guardrails.md](tools-write-guardrails.md) — Blocked SQL operations, bulk insert limits, WHERE clause enforcement
|
|
19
|
-
- [tools-scope-permissions.md](tools-scope-permissions.md) — read/write/admin permission hierarchy and per-tool requirements
|
|
20
18
|
|
|
21
19
|
## Conventions & Deduplication
|
|
22
20
|
- [tools-agent-id-conventions.md](tools-agent-id-conventions.md) — agent_id naming rules, hyphen prohibition, and namespace isolation
|
|
@@ -28,4 +26,4 @@ description: Maps reference files to their topics for the meko-mcp-tools skill
|
|
|
28
26
|
|
|
29
27
|
## Troubleshooting & Limitations
|
|
30
28
|
- [tools-troubleshooting.md](tools-troubleshooting.md) — Error recovery, retry strategies, stuck pipeline diagnosis
|
|
31
|
-
- [tools-known-limitations.md](tools-known-limitations.md) —
|
|
29
|
+
- [tools-known-limitations.md](tools-known-limitations.md) — Lifetime quotas, the `memory_get_all` window, `run_id` scoping, missing capabilities
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# agent_id — multi-agent identity on Cloud Meko
|
|
2
2
|
|
|
3
|
-
`agent_id` identifies **which agent wrote a memory or created a conversation**. It is not a constant. Pick a value that represents the specific agent + project you're acting for
|
|
3
|
+
`agent_id` identifies **which agent wrote a memory or created a conversation**. It is not a constant. Pick a value that represents the specific agent + project you're acting for and use it consistently for writes and trace attribution within this session.
|
|
4
4
|
|
|
5
|
-
The Cloud UI (`cloud.mekodata.ai`) renders `agent_id` as a badge on every memory and conversation row — so the value you pick is user-visible. Multiple different agents with different `agent_id` values can write into the same datapack;
|
|
5
|
+
The Cloud UI (`cloud.mekodata.ai`) renders `agent_id` as a badge on every memory and conversation row — so the value you pick is user-visible. Multiple different agents with different `agent_id` values can write into the same datapack; the badge records who wrote each row, and both the UI and a `memory_search` show the full cross-agent picture for the user.
|
|
6
6
|
|
|
7
7
|
## The three buckets
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Each memory is written under an `agent_id` (stored on the row, shown as the UI badge). It labels *who wrote* the row — it does not restrict who can later read it (`memory_search` spans all your agents for the user). Still, pick the right value up front so attribution is meaningful:
|
|
10
10
|
|
|
11
11
|
| Pattern | When to use | Example |
|
|
12
12
|
|---|---|---|
|
|
@@ -16,13 +16,15 @@ Memories segregate strictly by `agent_id`. Pick the right bucket up front:
|
|
|
16
16
|
|
|
17
17
|
**Discover the value at session start.** The SessionStart hook injects the chosen `agent_id` into the first-turn `additionalContext` based on the cwd's repo basename. Use that value verbatim — do not re-derive it. If the block is absent, fall back to `<client>:<basename(cwd)>` or ask the user.
|
|
18
18
|
|
|
19
|
-
For genuinely cross-project facts ("the user's name is
|
|
19
|
+
For genuinely cross-project facts ("the user's name is Alice", "the user prefers dark mode") write with `agent_id="meko_agent"` so their attribution clearly identifies the common cross-project bucket.
|
|
20
|
+
|
|
21
|
+
**Pick a value that matches the running client — don't invent another client's shape.** A Claude Desktop session that writes with `agent_id="claude_code"` (or `claude_code:something`) creates rows the UI will attribute to Claude Code — a misleading badge for both clients. Use the pattern from the table that matches the client you're actually running under.
|
|
20
22
|
|
|
21
23
|
## Valid characters
|
|
22
24
|
|
|
23
25
|
The server stores `agent_id` as a row-level column value — it never becomes a PostgreSQL identifier on Cloud. Any printable string works: colons, hyphens, dots, underscores, spaces. Stay within what's readable in the UI badge.
|
|
24
26
|
|
|
25
|
-
Pre-existing data in real datapacks includes a mix of legacy shapes — `agent`, `claude-code`, `claude_code`, `cursor:<slug>`, `claude-code:-Users-...`. None of them cause errors
|
|
27
|
+
Pre-existing data in real datapacks includes a mix of legacy shapes — `agent`, `claude-code`, `claude_code`, `cursor:<slug>`, `claude-code:-Users-...`. None of them cause errors or prevent memory recall. New writes should follow the table above.
|
|
26
28
|
|
|
27
29
|
## How agent_id filters reads and writes
|
|
28
30
|
|
|
@@ -31,15 +33,17 @@ Pre-existing data in real datapacks includes a mix of legacy shapes — `agent`,
|
|
|
31
33
|
- The row stores `(meko_datapack_id, meko_user_id, meko_agent_id)` — the user_id comes from your cognito account; the datapack_id defaults or is explicit; the agent_id is what you pass.
|
|
32
34
|
- If you pass an empty or whitespace-only `agent_id`, the server stores `meko_agent`. That's the common bucket — fine for cross-project facts; not what you want for project-scoped writes.
|
|
33
35
|
|
|
34
|
-
### Personal reads — `memory_search`, `memory_get_all
|
|
36
|
+
### Personal memory reads — `memory_search`, `memory_get_all`
|
|
37
|
+
|
|
38
|
+
Filter tuple: `(datapack_id, user_id)`. `agent_id` is **not** applied on memory reads.
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
- `user_id` is **always enforced**: you can only see memories you wrote (or content shared via promotion). One user cannot read another's un-promoted memories from MCP.
|
|
41
|
+
- `agent_id` does **not** filter results: a memory written under `agent_id="cursor:foo"` IS returned to a search passing any other value. It scopes only the call's trace. One call sees all of your agents' memories, including the `meko_agent` bucket — nothing to fan out.
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
- `agent_id` is **strictly matched**: a search with `agent_id="claude_code:meko-mcp-server"` returns only rows whose stored value is exactly that. A memory written by `agent_id="cursor:foo"` is invisible to it.
|
|
40
|
-
- An empty `agent_id` is rewritten to `meko_agent` server-side, so a "broad" read with empty string returns only common-bucket rows — **not** a cross-agent fan-out. To search across multiple agent_ids, call once per known value.
|
|
43
|
+
### Personal conversation reads — `conversation_get`, `conversation_list`
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
- `conversation_get` — agent-owned. Filter tuple `(datapack_id, user_id, agent_id)`: pass the exact `agent_id` that created the conversation; a wrong value returns `agent_id_mismatch`.
|
|
46
|
+
- `conversation_list` — **not** agent-filtered. It lists by `(datapack_id, user_id)` only; `agent_id` on the call is trace-attribution only (like memory reads), so one call returns the datapack's conversations for your user regardless of which agent created them.
|
|
43
47
|
|
|
44
48
|
### Team-shared reads — `knowledgebase_search`
|
|
45
49
|
|
|
@@ -57,9 +61,10 @@ The originating `agent_id` is preserved in each result's `metadata_filters.agent
|
|
|
57
61
|
memory_add(agent_id=X, text=...)
|
|
58
62
|
│
|
|
59
63
|
▼
|
|
60
|
-
|
|
64
|
+
memory_store ── personal memories, tagged (datapack, user, agent)
|
|
61
65
|
│
|
|
62
|
-
│
|
|
66
|
+
│ memory_promote (exact UUIDs + explicit confirmation)
|
|
67
|
+
│ or UI "Promote to Knowledge" (Learnings tab)
|
|
63
68
|
│ ─────────────────────────────────────────
|
|
64
69
|
│ Strips user_id, keeps agent_id as metadata,
|
|
65
70
|
│ copies into team-shared table
|
|
@@ -72,30 +77,28 @@ knowledgebase_search(agent_id=anything, query=...)
|
|
|
72
77
|
|
|
73
78
|
- **Personal memories** are what you get from `memory_search` / `memory_get_all`. Private to you.
|
|
74
79
|
- **Shared Knowledge** is what you get from `knowledgebase_search`. Visible to every user and every agent on the datapack.
|
|
75
|
-
- **Promotion
|
|
80
|
+
- **Promotion has MCP and UI paths.** `memory_promote` moves exact, user-confirmed memories into Shared Knowledge and evicts the private records; the Learnings tab is the user-driven alternative. Only datapack owners and maintainers may use the MCP path.
|
|
76
81
|
|
|
77
82
|
## When to use what — broad-query guidance
|
|
78
83
|
|
|
79
|
-
If the user asks "what do you know about X?"
|
|
80
|
-
|
|
81
|
-
1. **First call**: `memory_search(agent_id="<your agent_id>", query="X")` — returns your own project's memories. Most relevant if the context is "what have you and I done in this repo."
|
|
82
|
-
2. **Second call**: `memory_search(agent_id="meko_agent", query="X")` — returns the common cross-project bucket (user identity, global preferences). Anything you wrote with `agent_id="meko_agent"` from any agent or project, plus rows the server stored under that name when called with empty `agent_id`.
|
|
83
|
-
3. **Third call**: `knowledgebase_search(agent_id="<anything>", datapack_id="<datapack>", query="X")` — returns team-shared knowledge. Useful when the answer may have been promoted by the user or a teammate.
|
|
84
|
-
|
|
85
|
-
For a true cross-agent fan-out (e.g. you also want to see what was written from `claude_code:other-repo` or `cursor:foo`), call `memory_search` once per known agent_id — the empty-string shortcut does not bypass the filter; the server rewrites empty to `meko_agent`.
|
|
86
|
-
|
|
87
|
-
Always tell the user what scope you searched, so they understand why the answer is or isn't there. Example wording: "I found this in your project memories" vs. "I found this in your common cross-project bucket" vs. "I found this in your team's shared knowledge."
|
|
84
|
+
If the user asks "what do you know about X?": one `memory_search` covers the whole personal surface (every `agent_id`, nothing to fan out), then `knowledgebase_search` for team-shared knowledge. Tell the user which surface each finding came from.
|
|
88
85
|
|
|
89
|
-
##
|
|
86
|
+
## Optional sub-scoping
|
|
90
87
|
|
|
91
|
-
Optional parameters narrow
|
|
88
|
+
Optional parameters can narrow a call further:
|
|
92
89
|
- `user_id` — explicitly scope writes/reads to a specific end-user if your agent serves multiple (rare in Claude Code; more common in API products)
|
|
93
|
-
- `run_id` —
|
|
90
|
+
- `run_id` — on `memory_search` and the delete tools it is a **read/delete
|
|
91
|
+
filter** on the row's `meko_conversation_id`, so pass a *conversation id* to
|
|
92
|
+
scope the call to that conversation (consistent scoping landed in
|
|
93
|
+
MEKO-473/MEKO-474, #271). On `memory_add` it is Langfuse trace metadata only
|
|
94
|
+
and is not persisted as the conversation id, so scope writes with
|
|
95
|
+
`conversation_id` — a row written with `memory_add(run_id=X)` is not findable
|
|
96
|
+
via `memory_search(run_id=X)`.
|
|
94
97
|
|
|
95
98
|
Available on `memory_add`, `memory_search`, `memory_get_all`, `memory_delete_all`, `conversation_create`, `conversation_list`.
|
|
96
99
|
|
|
97
100
|
## Things I checked and found in-data on real Cloud datapacks
|
|
98
101
|
|
|
99
|
-
- `agent_id="agent"` appears on many legacy rows — it was the previous canonical constant. New writes should use the schema in the table above;
|
|
100
|
-
- Memory Summary UI (`/datapacks/<name>/memory-summary`) is agent-id-agnostic — shows every row in the datapack, renders the stored `agent_id` as a badge.
|
|
102
|
+
- `agent_id="agent"` appears on many legacy rows — it was the previous canonical constant. New writes should use the schema in the table above; memory reads still return the legacy rows.
|
|
103
|
+
- Memory Summary UI (`/datapacks/<name>/memory-summary`) is agent-id-agnostic — shows every row in the datapack, renders the stored `agent_id` as a badge. `memory_search` and `conversation_list` are likewise agent-agnostic (they return all your agents' rows for the user); only `conversation_get` enforces `agent_id` (agent ownership).
|
|
101
104
|
- Subagents spawned via the `Agent` tool in Claude Code do not automatically inherit the parent's `agent_id`. The parent must inject it into the spawn prompt. See the SKILL.md "When spawning subagents" section.
|