Graph Upsert
graph_upsertFold new facts into a memory graph and get the whole graph back. FREE.
Idempotent by construction: re-adding the same entity, observation or relation changes nothing, so an agent that replays its own history does not end up with a graph full of duplicates. Typical input {"graph": {"entities": [], "relations": []}, "entities": [{"name": "Acme Corp", "type": "company", "observations": ["renewed in March"]}]} returns {"graph": {...}, "added": {"entities": 1, "observations": 1, "relations": 0}, "merged": 0}.
Use as the single write path for memory. Not for reading it back selectively - that is graph_search - and not for finding out what a write changed, which graph_diff answers precisely. Errors: on invalid, missing, or malformed input this tool never raises a protocol error — it returns {"error": ""} (for example {"error": "graph exceeds entities; split it"}). Every call is read-only and idempotent, so after correcting the input it is always safe to retry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph | No | The existing graph document, or omitted to start a new one. Shape: {"entities": [...], "relations": [...]}. | |
| entities | No | Entities to add or extend, each {"name": ..., "type": ..., "observations": [...]}. Observations are appended and deduplicated; an existing entity keeps its type unless a new one is supplied. | |
| relations | No | Relations to add, each {"from": ..., "to": ..., "type": ..., and optionally "since", "until", "confidence"}. Dates are ISO 8601 (YYYY-MM-DD); confidence is 0 to 1. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||