Memory
kōjō remembers three kinds of things between sessions. All three are rows of one table in Postgres, and all three are searched the same way: by meaning when an embedding model is configured and pgvector is available, by words otherwise.
| Kind | Belongs to | Comes from | Read by |
|---|---|---|---|
| Team memory | A repository, or the whole org | Skills (memory_save), and operators in the dashboard, the API or MCP |
Every session on that repository |
| Per-person memory | One person | That person: in chat, in a mention, or in the dashboard | Only sessions that person starts |
| Lessons learned from reviews | A repository, as team memory | A maintainer’s review of a pull request kōjō opened | The skill that produced that pull request, the next time it runs there |
A memory is text a person wrote, or text distilled from it. It reaches a model as data: inside the same fence as an issue body, or as the result of a memory_search call, never as part of the instructions. See Security.
The files under a repository’s .factory/memory/ are something else: notes kept in git and handed to every subagent as they are. They are described under AGENTS.md and .factory/memory and are not copied into the database.
Team memory
Team memory holds facts about how a repository or the org works: “integration tests need Docker and are tagged integration”, “releases are cut from main on Tuesdays”. A memory with a repository applies to that repository; one without applies to every repository.
It is written in three ways:
- A skill that lists the
memory_savetool saves a fact while it works. This only works in a session whose requester is trusted. A request from an untrusted actor cannot save team memory, because what was learned from untrusted input must not steer later sessions. - An operator adds a memory by hand, on the dashboard’s Memory screen, with
POST /api/v1/memoryor with the MCP toolkojo_memory_add. - kōjō learns a lesson from a review.
It is read in two ways. Every subagent starts with up to five team memories that match its task, and the orchestrator and any skill that lists memory_search can search for more.
Each memory records where it came from:
| Source | Meaning |
|---|---|
session:<id> |
A skill saved it in that session |
user:<email or token> |
Someone added it by hand |
review:<number>:<reviewer> |
A lesson learned from that reviewer’s feedback on pull request <number> |
Per-person memory
A person can have memories of their own: preferences and context that apply to their requests and to nobody else’s. “I review in the morning, keep pull requests under 200 lines.” “Explain Rust lifetimes when you touch them.”
Saving one
- Tell kōjō in chat or in a mention: “remember that I want pull requests under 200 lines”. The orchestrator saves it with its
memory_savetool, which only ever writes to the memory of the person who asked. - A skill that lists
memory_savecan save withscope: personal. The default scope isteam; the tool’s answer says which memory was written. - On the dashboard’s Memory screen, choose “Mine” and add it, or choose “Only me” in the dialog.
POST /api/v1/memorywith"scope": "personal", or the MCP toolkojo_memory_addwithscope: personal.
A person does not need the operator role, or any trigger permission, to keep a memory of their own: it only ever reaches sessions they start themselves. One person can have at most 200.
A personal memory saved by a session follows the person to every repository. One added through the API with a repo applies to their requests on that repository only.
Which sessions read it
Only a request a person made has a person: a mention on a forge, a chat message, a run started by hand from the dashboard, the CLI or MCP, or a campaign (its sessions are the person’s who created it). Such a session gets that person’s memories when it starts (up to 20, newest first, for the orchestrator and for every subagent), and its memory_search searches them along with team memory. Each search result says whether it is team or personal.
A session nobody asked for works for the team and reads no personal memory: an automatic trigger such as issue_opened, a schedule, a review to learn from. Dry runs (skill tests and evals) read and save none either, so their results do not depend on who started them.
Who is a person
A person is identified by a key:
| Where the request comes from | The key |
|---|---|
| Chat, when the surface gives kōjō the sender’s email | email:<address> |
| The dashboard, signed in through OIDC | email:<address> |
| A forge mention | <forge>:<login>, for example github:ana |
| Chat, when the surface gives no email | <surface>:<user id>, for example slack:u02abcdef |
| The API, the CLI or MCP with an API token | token:<name of the token> |
An email is the person: it is the same key in chat and in the dashboard, so a preference saved in Slack applies to a run started from the dashboard by the same address. It is also what roles are granted to.
A forge does not tell kōjō a user’s email, so a forge login is a person of its own until an admin links it. The identities of the settings/memory object say which accounts belong to which email:
version: 1
objects:
- scope: org
object: settings/memory
content:
identities:
- email: ana@example.com
logins: ["github:ana", "forgejo:ana", "token:ana-laptop"]
With this, Ana’s mentions on GitHub and Forgejo and the runs she starts with her API token read and write the same memory as her chat messages. kōjō never decides by itself that two accounts are the same human. An account that is not linked keeps a memory of its own, and that memory does not move when the account is linked later.
Keys are lower case, and logins in identities are matched without case. A key is the account’s name: when a forge account is renamed, what it saved stays under the old name.
The same links decide whose limits a session counts against: a linked login’s sessions count under the email, whether or not per-person memory is on.
Privacy
A person’s memories are theirs.
- On the Memory screen, “Mine” lists only your own.
GET /api/v1/memory?scope=minedoes the same; the default listing and every search withoutscopereturn team memory only. - You delete your own memories, one at a time or all at once (
DELETE /api/v1/memory?person=<your key>), whatever your role. - Nobody else sees them in a listing or a search, and to another user’s
DELETEthey do not exist (404). - An admin can list one person’s memories (
GET /api/v1/memory?person=<key>) and delete them, one or all, to answer a request for a copy or for erasure. Each of those is in the audit log:memory.read,memory.deletewithby_admin,memory.erase. The audit entries name the person and the memory, not its text.
# Everything kōjō remembers about one person, then all of it deleted (admin)
curl -H "Authorization: Bearer $KOJO_TOKEN" \
"$KOJO_SERVER/api/v1/memory?person=email:ana@example.com"
curl -X DELETE -H "Authorization: Bearer $KOJO_TOKEN" \
"$KOJO_SERVER/api/v1/memory?person=email:ana@example.com"
Sessions are a separate record. The replay of a session a person started shows its tool calls, the results of a memory_search among them, and what the model answered. Everyone with the viewer role can read it, so what a person saved can show there.
To turn per-person memory off for the whole install, set personal: false in settings/memory. Sessions then read and save none. What is already stored stays until its owners or an admin delete it.
Lessons learned from reviews
When a maintainer reviews a pull request kōjō opened, what they say can improve the next run. “We never mock the database in this repository” is worth remembering; “typo here” is not.
flowchart TD
C["A comment or review on a pull request"] --> W["Forge webhook"]
W --> M{"Mentions kōjō?"}
M -- yes --> R["A request, handled as a mention"]
M -- no --> O{"Pull request opened by a kōjō session?"}
O -- no --> I["Ignored"]
O -- yes --> P{"Author has trigger_permission?"}
P -- no --> X["Refused and audited"]
P -- yes --> S["Feedback session queued"]
S --> D["One model call distils general lessons"]
D -- "nothing general" --> N["Session ends, nothing saved"]
D -- "a lesson" --> T["Saved as team memory of the repository, for the skill"]
T --> U["The skill's next run there starts with it"]
What counts as feedback
Three things must hold:
- It is on kōjō’s own pull request. kōjō records every pull request a session opens. A comment on anyone else’s pull request is ignored.
- Its author has the repository’s
trigger_permission(defaultwrite), the same permission a mention needs. Anyone else’s comment is refused and audited asrequest.reject, and reaches no model. A lesson is read by later sessions, so a stranger must not be able to plant one. - It does not mention kōjō. A comment that mentions the bot is a request, as always, and is handled as one and not also as feedback: on kōjō’s own open pull request, a follow-up that commits to it. A comment that does not mention kōjō never changes the pull request.
What each forge delivers:
| Forge | A comment on the conversation | A review’s summary | A comment on a line of the diff |
|---|---|---|---|
| GitHub | issue_comment |
pull_request_review |
pull_request_review_comment, with the diff hunk |
| GitLab | Note Hook | Note Hook (GitLab has no separate review text) | Note Hook, with the file and line; kōjō reads the diff from the API |
| Forgejo, Gitea | issue_comment |
pull_request_approved, pull_request_rejected, pull_request_comment |
Not delivered by the forge’s webhooks |
| Bitbucket | pullrequest:comment_created |
None: a Bitbucket review has no text | pullrequest:comment_created, with the file and line |
The events to enable are listed for GitHub, GitLab, Forgejo and Bitbucket. A review without text (a bare approval) teaches nothing and is ignored. Edited comments are not read again.
What happens to it
The comment becomes a session with the trigger feedback, queued like any other. It runs no skill and needs no sandbox. It makes one model call on the strong tier with:
- the comment,
- the pull request’s title and description,
- the part of the diff the comment is on, or the beginning of the pull request’s diff for a comment on the whole,
- the skill that produced the change,
- the lessons the repository already has.
The model answers with up to three lessons, or none. A lesson is a short, general rule about the repository or about how its maintainers want work done, understandable without the pull request. A correction that only applies to that change, praise, a question, and anything about a person are not lessons.
The session ends with the outcome lessons_learned or nothing_learned. It posts nothing on the pull request, whether it learned something, learned nothing or failed. Its model call is priced and counted against the budgets like any other.
What is saved
Each lesson is saved as team memory of the repository, with:
- the skill it concerns: the last skill of the session that changed files, the one whose work the reviewer read,
- the source
review:<number>:<reviewer>, and a link to the comment, - a one or two word topic.
A lesson the repository already has is not saved twice: the model is shown the known lessons, the same sentence is recognised whatever its punctuation and capitals, and with an embedding model a lesson that means the same as a stored one is dropped too. Every saved lesson is in the audit log as memory.learn.
How it is used
A skill that runs on the repository starts with the lessons learned for it there (up to 20, newest first), ahead of the team memories that match its task. Lessons are team memory, so memory_search finds them as well.
Finding and deleting a bad lesson
On the dashboard’s Memory screen, “Learned from reviews” lists every lesson with its skill, its repository, and the review it came from, as a link to the comment. An operator deletes one there; sessions stop seeing it at once.
The same through the API:
# The lessons learned for fix-bug in one repository
curl -H "Authorization: Bearer $KOJO_TOKEN" \
"$KOJO_SERVER/api/v1/memory?repo=github/acme/api&skill=fix-bug&source=review:"
curl -X DELETE -H "Authorization: Bearer $KOJO_TOKEN" \
"$KOJO_SERVER/api/v1/memory/mem_01jexample"
Turning learning off
Learning is on by default. An admin turns it off for the org, or for one repository, with learn_from_reviews in the settings/memory object, or on the dashboard under Settings, Memory.
version: 1
objects:
# Off everywhere...
- scope: org
object: settings/memory
content:
learn_from_reviews: false
# ...except in this repository.
- scope: repo:github/acme/api
object: settings/memory
content:
learn_from_reviews: true
With learning off, review comments are not queued and reach no model. Lessons already saved stay, and are still given to their skills, until someone deletes them.
What became of each pull request
The same pull request events tell kōjō what happened to its pull requests after their sessions ended: merged, or closed without merging, and whether a person pushed commits first. That gives two numbers per repository and skill:
- the merge rate: merged, out of merged and closed;
- the human-edit rate: out of the merged ones, those a person pushed commits to before the merge.
They are on the dashboard’s overview next to the critic pass rate, in GET /api/v1/stats, and in Prometheus as kojo_pull_requests_closed_total. See Prometheus metrics.
Lessons and the fate of pull requests are also the evidence of self-improvement: with it turned on, kōjō proposes a change to a skill’s instructions or goals once enough of it has gathered, and a person approves or rejects the proposal.
Who can see and delete what
| See | Add | Delete | |
|---|---|---|---|
| Team memory, lessons included | Everyone with a role | operator; skills in a trusted session; kōjō, from a review |
operator |
| Your personal memory | You | You, and sessions you start | You |
| Someone else’s personal memory | admin, by naming the person; audited |
Nobody | admin; audited |
The endpoints are listed in the HTTP API, the tools in MCP, and the audit actions in Audit log.