Repository navigation
fix(memory): report relations create_relations skipped - #5708
Conversation
create_relations returned a bare empty list for a relation that already exists, so an agent could not tell "already there" from "nothing happened". Mirror create_entities: list the skipped relations (existing, or repeated earlier in the same call) in an optional `skipped` field of structuredContent, add a text notice naming them, and say so in the tool description and README. Closes #5654 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
🦋 Changeset detectedLatest commit: edb349e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 9 | 0 | 1 | 0 |
| Head | 9 | 0 | 1 | 0 |
tools
--- base/tools.json
+++ target/tools.json
- tools[create_relations].description: "Create multiple new relations between entities in the knowledge graph. Relations should be in active..."
+ tools[create_relations].description: "Create multiple new relations between entities in the knowledge graph. Relations should be in active..."
+ tools[create_relations].outputSchema.properties.skipped: {"items":{"additionalProperties":false,"properties":{"from":{"description":"The name of the entity where the relation starts","type":"string"},"relationType":{"description":"The type of the relation",...Updated by this run for edb349e3cf443893df273538957cc504810ed940.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to report skipped duplicate relations.
No open issues 🎉
What changed in this PR
Updates the memory server’s create_relations response to report skipped duplicates, matching create_entities and addressing #5654 without changing graph mutation behavior.
Changes:
- Adds an optional
skippedarray and a text notice for existing relations and within-request repeats. - Updates the tool description and README to explain skip reporting.
- Adds protocol regression coverage and a patch changeset.
| File | Description |
|---|---|
src/memory/README.md |
Documents duplicate handling and skipped-relation responses. |
src/memory/index.ts |
Adds skip detection, notices, and the optional output field. |
src/memory/__tests__/write-limits.test.ts |
Updates duplicate-at-limit expectations to include skipped relations. |
src/memory/__tests__/tools.test.ts |
Verifies the updated schema, mixed batches, and repeated calls. |
.changeset/memory-create-relations-skipped.md |
Records the memory server patch release change. |
Review effort: Balanced
|
Copilot round 1: clean (no findings, no suppressed comments). The loop stops on the first clean round, so no further round was requested. |
Closes #5654
Description
create_relationsreturned a bare[]for a relation that already exists, so an agent could not tell "already there" from "nothing happened". It now mirrorscreate_entities' skip report (#4887):structuredContentcarries a new optionalskippedarray of the requested relations that were not added, present only when at least one was skipped.Skipped 1 relation that already exists: A -[knows]-> B. It is already in the graph, so nothing was added for it.create_entitiestreats them: the first occurrence is created, the repeat is reported as skipped.The skip list is computed by identity against what
createRelationsreturned (skippedRelations), exactly asskippedEntityNamesdoes for entities.KnowledgeGraphManager.createRelationsitself is unchanged.Server Details
create_relationstool (output schema gains optionalskipped, description, result content), READMEMotivation and Context
See #5654: the
create_entitieshandler adds its notice because "otherwise an agent reads the response as its observations having been stored"; a relation the agent asked for and did not get has the same problem.How Has This Been Tested?
Protocol-level tests (
__tests__/tools.test.ts): the issue's exact repro (repeat an existing relation:relations: []plusskippedand the notice), a mixed batch with an existing relation and a within-batch repeat, the updatedtools/listexpectation for the description and output schema, andwrite-limits.test.ts's at-the-limit repeat.npm run local:gateexited 0; itsinterface-diffstage shows only the description change and the addedoutputSchema.properties.skipped(additive;requiredunchanged).Inspector CLI 2.12.0 (stdio):
create_entitiesA, B;create_relationsA knows B; then the samecreate_relationsagain. The second call's result:--protocol-era legacy) and 2026-07-28 (modern) alike:{"content":[{"type":"text","text":"[]"}],"structuredContent":{"relations":[]}}legacy:{"content":[{"type":"text","text":"[]"},{"type":"text","text":"Skipped 1 relation that already exists: A -[knows]-> B. It is already in the graph, so nothing was added for it."}],"structuredContent":{"relations":[],"skipped":[{"from":"A","to":"B","relationType":"knows"}]}}modern: the same, plus_meta["io.modelcontextprotocol/serverInfo"](2026-07-28 answered).LLM client: Claude Code 2.1.332 (
claude -p --strict-mcp-config, local build; the era cannot be selected from this client). Prompt: "create entities A and B, then create the relation A knows B, then call create_relations again with exactly the same relation; report what the second call returned and whether the relation was stored." The model received{"relations":[],"skipped":[{"from":"A","to":"B","relationType":"knows"}]}and answered: "The secondcreate_relationscall skipped the relation because it was already stored. The graph still holds exactly oneA knows Brelation."Breaking Changes
None. The new output field is optional and only present when something was skipped; existing clients that read
relationssee the same value.Types of changes
Checklist
npm run changeset) if this changes what a TypeScript server publishes (patch, matching memory: create_entities silently drops observations for existing entities #4887's precedent forcreate_entities'skipped)Additional context
Sibling PRs touch the same file: #5693 rewrites
createRelations' dedupe loop (behavior-preserving). This PR relies oncreateRelationsreturning the requested relation objects themselves; the protocol tests here fail if a rewrite stops doing so.🤖 Generated with Claude Code