Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Codex
every prompt prompt recall into context: ten memories, the block naming the tool
on demand mcp past_recall, the model's own recall, on a local MCP server
every turn stop stamps the activity file, keeps one waiter on the session
compaction precompact sends the session so far
compaction precompact sends the sittings that closed; the one still open at most once an hour
session end end makes sure a waiter runs
detached idle the waiter: sends once Codex's process is gone, or after idleMinutes
|
Expand All @@ -43,6 +43,11 @@ plugins/past/
.github/workflows/check.yml every pull request: the script parses and runs, the manifests parse
```

Credit refusals persist per operation in this host's state book, under `creditPauses`.
Each pause stores a connection fingerprint, required credits, and the next balance check time.
Use `updateState` for every change. Keep transcript hashes and pending sessions intact on a refusal.
`status --refresh` reads `/api/v1/usage` before it clears a pause. A write pause leaves recall available.

## The script

`bin/past-hook.mjs` is the whole plugin. The rules it keeps:
Expand All @@ -65,7 +70,11 @@ plugins/past/
gone or the last turn is `idleMinutes` old (720 by default). `ensureWaiters` (`Stop`,
`SessionStart`, `$past:status`) replaces a waiter that died or that an older `WAITER_VERSION`
started (bump it whenever the waiter changes), and a replacement past its deadline sends at
once. `PreCompact` sends before the context is summarised. `SessionStart` sends the idle
once. `PreCompact` sends the sittings that closed since the last send, once each, and the one
still open only when the session's last send is an hour old (`COMPACTION_RESEND_MS`): a session
that never goes quiet compacts every few minutes, and sent whole at each one it was a new paid
revision every time, while the transcript on disk loses nothing. The held sitting keeps its old
hash in `state.json`, so it goes with the waiter's send. `SessionStart` sends the idle
sessions that never reached past.dev, and `tidyPending` drops an open session that is gone, empty,
or in past.dev unchanged and idle. Why `SessionEnd` sends nothing is under "Codex" below.
5. **A recall query is redacted like the content it would send.** It crosses the network exactly
Expand All @@ -90,8 +99,8 @@ plugins/past/
9. **What is sent for a session does not change by a byte.** The heading and the speaker names
that `renderTranscript` prints are part of the content hash, and so are `SOURCE`, `AGENT` and
`SPEAKER` at the top of the script: a changed byte makes `backfill` send every session already
in past.dev again, as a paid revision. `sittingId` and the cut (`sittingsOf`, `silenceMeter`) are
fixed too: changed, they move the boundaries of every session that grows afterwards, and the old
in past.dev again, as a paid revision. `sittingId` and the cut (`sittingsOf`, `silenceMeter`, the size
measured on the turns' own text) are fixed too: changed, they move the boundaries of every session that grows afterwards, and the old
sittings stay in past.dev beside the new ones.
10. **`~/.past` is the person's alone.** The folder is `700` and every file in it is created
`600`, never written open and narrowed afterwards. A plain-http `apiUrl` on another machine
Expand All @@ -100,9 +109,14 @@ plugins/past/
decides which of two statements is the later from those times. A sitting starts at the first
turn after the thread was silent for `sittingMinutes` (30 by default, 5 at least), whoever
speaks; tool calls and their output count as activity, so a prompt stays with its reply while
Codex works. Each sitting is one data point timed at its first turn, and every changed sitting
goes in one `/api/v1/ingest/batch` call. `state.json` pins `sittingMinutes` per session at its
first send, so a changed value never moves the boundaries of a session already in past.dev.
Codex works. One also starts once the sitting so far holds `sittingKilobytes` of prose (50 by
default, 10 at least), measured on the turns' own text and only once Codex has answered, so a
thread that never goes quiet is cut all the same and a prompt is never parted from its first
answer. Each sitting is one data point timed at its first turn, and every changed sitting
goes in one `/api/v1/ingest/batch` call. `state.json` pins `sittingMinutes` and
`sittingKilobytes` per session at its first send, so a changed value never moves the boundaries
of a session already in past.dev; one sent in sittings before the size existed is pinned to no
size (`0`).

12. **The product is written past.dev.** Every sentence a person reads says past.dev: the READMEs,
the manifest's display names, the skills' text, what a mode prints. Identifiers keep `past`:
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ session opens recall what past.dev knows about this project ──► in
every prompt recall what past.dev knows about this prompt ──► into context
any time Codex asks past.dev itself, with past_recall ──► into context
every reply nothing is sent; the session is marked active
compaction the session so far is sent, before its detail is summarised away
compaction the sittings that closed are sent; the one still open at most once an hour
session over the session is sent: its Codex process exited, or it was quiet for 12 hours
```

Expand All @@ -88,7 +88,7 @@ after 12 hours without a new turn. The next session to start also sends any earl
reached past.dev, which covers a crash or a machine that slept.

**A session is sent in sittings.** Where a thread went quiet for 30 minutes, the next turn starts a
new sitting. Each sitting is dated at its own first turn, so a decision made on the third day of a
new sitting; so does the next one after 50 KB of prose, once Codex has answered. Each sitting is dated at its own first turn, so a decision made on the third day of a
long thread is remembered on that day, and past.dev can tell which of two statements came later. A
session that continues sends its last sitting and the new ones again, nothing earlier.

Expand Down Expand Up @@ -142,8 +142,9 @@ slug from the console's **Audiences** page. `$past:connect --audience project` w

`~/.past/config.json` holds the connection and a few switches: `recall` and `ingest` turn either
half off, `idleMinutes` (720) is how long a session stays quiet before it is sent,
`sittingMinutes` (30) is how long a pause starts a new sitting, and `deny` lists paths whose
sessions are never read. `PAST_API_KEY`, `PAST_IDENTITY` and `PAST_API_URL` override the file.
`sittingMinutes` (30) is how long a pause starts a new sitting, `sittingKilobytes` (50) how much
prose does, and `deny` lists paths whose sessions are never read. `PAST_API_KEY`, `PAST_IDENTITY`
and `PAST_API_URL` override the file.
Each setting is described in the [plugin's README](plugins/past/README.md#configuration).

For a self-hosted past.dev, pass your deployment's URL as the third argument of `$past:connect`. Use
Expand Down
2 changes: 1 addition & 1 deletion plugins/past/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "past",
"version": "0.2.0",
"version": "0.4.0",
"description": "Your Codex sessions become memory, and every session starts briefed.",
"author": { "name": "past.dev", "url": "https://past.dev" },
"homepage": "https://github.com/pastdotdev/codex-plugin",
Expand Down
22 changes: 19 additions & 3 deletions plugins/past/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,22 @@ is nothing to do: `$past:status` shows it.
| `SessionStart` | a session opens | recalls this project's history and puts it in context |
| `UserPromptSubmit` | every prompt | recalls the ten memories closest to the prompt and puts them in context |
| `Stop` | after each reply | stamps the session's activity; sends nothing itself |
| `PreCompact` | the context is about to be compacted | sends the session so far, before the detail is summarised away |
| `PreCompact` | the context is about to be compacted | sends the sittings that closed since the last send; the one still open at most once an hour |
| `SessionEnd` | Codex unloads a session | makes sure the session will be sent; sends nothing itself |

**When a session is sent.** Codex says a session ended even when it only went quiet for half an
hour, so the plugin does not send on that. A session is sent within a minute after the Codex
process that ran it exits (the end of a `codex exec` run, the desktop app when you quit it), or
after 12 hours without a new turn (`idleMinutes`). It is sent before a compaction too.
after 12 hours without a new turn (`idleMinutes`). Before a compaction, the sittings that closed
since the last send go too, and the one still open at most once an hour.

`SessionStart` also sends any earlier session that never reached past.dev and has gone idle, which is
what covers a crash or a machine that slept.

**A session is sent in sittings.** A new sitting starts where the session went quiet for 30
minutes (`sittingMinutes`): nobody wrote and Codex ran nothing. Each sitting is dated at its own
minutes (`sittingMinutes`): nobody wrote and Codex ran nothing. One also starts once the sitting
so far holds 50 KB of prose (`sittingKilobytes`), after Codex's reply, so a thread that never pauses
is cut all the same. Each sitting is dated at its own
first turn, and what past.dev remembers takes the date of the sitting it came from, so something said
on the third day of a thread that ran for three days is dated that day. A prompt and its reply stay
together while Codex works on it, however long. When a session continues, only its last sitting
Expand Down Expand Up @@ -122,6 +125,7 @@ narrows it to an audience from the console; `--audience project` widens it back.
"ingest": true,
"idleMinutes": 720,
"sittingMinutes": 30,
"sittingKilobytes": 50,
"deny": ["/Users/you/clients/acme"]
}
```
Expand All @@ -133,6 +137,9 @@ narrows it to an audience from the console; `--audience project` widens it back.
- `sittingMinutes` is how long a session stays quiet before what follows starts a new sitting (30
by default, 5 at least). Shorter dates what past.dev remembers more closely, in more and smaller
data points. A session keeps the length it was first sent with.
- `sittingKilobytes` is how much prose a sitting holds before the next turn starts a new one (50
by default, 10 at least), the cut waiting for Codex's reply. A session keeps the size it was
first sent with.
- `deny` holds path fragments. A session whose working directory matches one is ignored
completely — nothing is read and nothing is sent.
- `PAST_API_KEY`, `PAST_IDENTITY` and `PAST_API_URL` override the file.
Expand Down Expand Up @@ -164,3 +171,12 @@ console.
## License

MIT — see [LICENSE](LICENSE).

## Credits

After `402 out-of-credits`, the plugin pauses the refused operation and keeps unsent data locally.
A write refusal does not pause recall. A recall refusal pauses recall separately.
On later calls, the plugin checks the balance at most once per five minutes for each paused operation.
The plugin resumes when the balance covers the refused call. The server checks the balance again for each request.
Run `$past:status --refresh` after you add credits to check the balance now.
A new API key or API URL starts with no pause from the previous connection.
Loading
Loading