Commit cf1bf1e
fix(mcp): remember tool output validation — schema vs handler mismatches
The remember tool failed MCP output validation on every code path because
the declared schema did not match what the handler actually returns:
(1) memory_id / merged_with declared "type": "string" (UUID-style) but the
handler returns int (PG bigint). Aligned with anchor.py / forget.py /
get_causal_chain.py which already declare integer.
(2) Schema invariant required:["stored","action"] was violated by both
no_content early-exit paths in remember.py and by
write_gate.build_rejection_response(): they returned {"stored": false,
...} with no "action" field. Added "action": "rejected" to each.
(3) Schema enum was ["stored","merged","rejected"] (past-tense outcomes)
but the handler forwarded the internal curation vocab "create"/"link"
untouched, so every successful create/link failed with:
Output validation error: 'create' is not one of [...]
Normalized at the response boundary in build_response:
create/link → "stored", merge → "merged".
After these fixes the schema invariant and the enum constraint are both
honoured on every code path (no_content, gate-rejected, created, linked,
merged).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent e0b36d5 commit cf1bf1e
3 files changed
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
| 42 | + | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
72 | | - | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| |||
0 commit comments