memory_self_edit
Alpha, on the 3.6.x line. The API can still change within 3.x.
Lets the agent correct and re-weigh what it knows. Every call needs a
reason.
Actions
action | What it does |
|---|---|
append | Adds content to the target’s text. |
replace | Replaces the target’s text with content. |
strengthen | Raises the target’s worth. |
weaken | Lowers the target’s worth. |
reflect | Runs the reflection cycle. |
link | Joins the target and the ids in content into a hyperedge. content lists at least two ids, separated by commas. |
There is no forget action. To invalidate a fact or a strategy, use
memory_forget.
Arguments
| Name | Type | Required | Default | Notes |
|---|---|---|---|---|
action | string | yes | One of the six actions above. | |
target | string | yes | A fact id, profile, or strategy:{id}. | |
reason | string | yes | 1 to 2000 characters. Used to evaluate the edit policy. | |
content | string | no | New text for append and replace, or the member ids for link. Up to 20,000 characters. | |
sessionId | string | no | With it, the edit draws from that session’s budget. Without it, from the credential’s budget for calls with no session. | |
idempotencyKey | string | no | Prevents applying the same edit twice on a retry. |
Example
{
"name": "memory_self_edit",
"arguments": {
"action": "replace",
"target": "<fact id>",
"content": "The Larkspur warehouse fleet has 48 picker robots.",
"reason": "Counted on the fleet dashboard after the November expansion"
}
}Returns
{
"applied": true,
"action": "replace",
"target": "<fact id>",
"targetKind": "fact",
"replacementId": "<new fact id>",
"countsAsEdit": true,
"countsAsDelete": false
}replacementId is present when the edit closed the original and created
a new fact; use that id from then on. reflect returns
{ "applied": true, "action": "reflect", "episode_id", "strengthened", "weakened" }.
Limits
The default policy allows:
- 5 edits per session
- 3
strengthenand 5weakencalls per day - one edit on the same target every 300 seconds; a faster one is rejected
A call over a limit returns 429. Without a cache adapter the counters are kept in the server process, so they reset when it restarts.
The reason is required as context for the policy. It is not yet stored
in a durable audit log.
Related
- Self-editing memory, the concept
- REST:
POST /self/edit memory_updatecorrects the statement of a fact with a single call.