Choose the repository and exact version
Use a separate memory repository when the information needs its own access rules, storage lifetime, or delete boundary. You can use one repository per project, user, tenant, or company. Before the agent reads memory, read the current commit SHA of the branch and store it with the agent session. This SHA is the pinned revision. It always identifies the same files, so the agent reads one exact version.repos.tags.create when a person needs a readable name for the version.
Load only the required files
Give the sandbox a temporary API token for only the memory repository. Keep the organization private key in trusted product code. See Authentication for token details. Userepos.archive.get with file patterns to fetch a group of memory files without a git clone.
Use repos.files.get for one file. The sandbox needs no local Git index and no git push.
Save the agent’s changes
Setexpected_target_sha to the commit SHA that was current before the agent made its change. Code
Storage accepts the save only if the target branch still points to that commit.
precondition_failed; the branch still points at the pinned revision.
Treat it as success with no new commit.
After a timeout, the save can still have succeeded. Do not resend the same request. Read the current
head again, apply the intended change to the current files, and save with the new head as
expected_target_sha.
Combine changes from separate branches
A product can give each agent session its own branch. Check the merge first, then requiremain to
remain at the commit that you checked.
main moved after the check, run the check
again on the new head.
Inspect and undo a change
Userepos.commits.list to show file history and repos.diff.get to show one change.
repos.commits.restore to create a new commit from an earlier version. The new commit keeps the
undo action in history.