Skip to main content
UltraContext - Edit context guide cover

Guide Overview

After this guide, you’ll be able to:
  • Replace messages mid-conversation (e.g. system prompts)
  • Delete messages mid-conversation
  • Track every context change

Why Edit Contexts?

You want to tweak the system prompt. But first, the ritual. Copy it somewhere. Just in case. Make the edit. Test. It’s worse. What was the prompt before? You’re debugging blind—reconstructing from memory. And editing without losing the audit trail? A pain. What if you could skip the ritual? Edit anything. Never lose the original. Every change tracked. Rewind anytime. Effortlessly. UltraContext gives you that out of the box. Update or delete any message with a single API call. Every change creates a new version. The original is preserved. Add metadata to track why. Full audit trail, full control. Zero complexity. Edit freely. The system remembers.

Editing Contexts

Updates and deletes automatically create new versions. This means you can always rewind to any mutation point.
Appends don’t create new versions. Using before and at is enough to travel back in time for them.

Update Messages

Update by message ID or index:

Update multiple messages

Partial updates

Updates are partial by default. Only the fields you specify get changed. Everything else stays intact.

Delete Messages

Soft delete vs hard delete — one method, two behaviors.
  • Soft delete — uc.delete(contextId, ids). Removes messages from the current version but creates a new version; deleted messages are preserved in prior versions and recoverable via uc.get(contextId, { version: N }).
  • Hard delete — uc.delete(contextId, { permanent: true }). Wipes the entire context, all versions, all messages. Irreversible.
The second argument is always required — this prevents accidental context wipes from typos.
Delete by ID or index:

Delete multiple messages

Including Metadata

Include metadata to track why changes were made. It is optional, but recommended to make audit trail easier to understand.
View the audit trail:

Examples

Replace System Prompt

Track prompt_version in the message metadata. This lets you correlate agent behavior with specific prompt versions.

Undo Last Message

Remove the last message from the conversation.
Deleting a message creates a new version of the conversation. The original is always preserved in the version history. Notice that after deleting the last message, the version number is incremented by 1 in our example, so v0 is completely preserved.

Delete Entire Context

Permanently delete a context and all its versions.
This is irreversible. The context, all its versions, and all messages are permanently deleted. Audit metadata is echoed in the response and logged server-side, but no DB row survives to hold it.

Delete Multiple Contexts

Permanently delete up to 100 contexts in one call.
Returns per-context results so partial failures don’t block the entire operation. Status code is 200 on full success, 207 on partial, 500 when every item fails — SDKs pass through the response body in all three cases.

See also: Fork & Clone Contexts

For major changes, consider forking instead of editing.