Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ead9bfd
feat(summarize): report failures to Sentry + configurable retry
rexplx Jul 12, 2026
d88b7c2
feat(summarize): make chunk-level retry configurable (default 3)
rexplx Jul 12, 2026
26787f2
fix(providers): stop embedding raw response content in thrown errors
rexplx Jul 13, 2026
3a9173c
fix(observability): harden Sentry init/capture against silent failure…
rexplx Jul 13, 2026
223d2a7
fix(summarize): retry backoff/ceiling, chunk-partial caching, accurat…
rexplx Jul 13, 2026
838bad7
fix(index): flush Sentry on shutdown before process exit
rexplx Jul 13, 2026
22c7aab
fix(deploy): build the patched fork from source instead of a manual t…
rexplx Jul 13, 2026
8982ee1
fix(deploy): commit a build-scoped lockfile, switch builder stage to …
rexplx Jul 13, 2026
de83024
refactor(summarize): extract retry/backoff/cache config into summariz…
rexplx Jul 13, 2026
b984ed5
feat(health): expose Sentry-enabled state on the health snapshot
rexplx Jul 13, 2026
c2aad66
fix(deploy): correct dockerfile path resolution in fly.toml
rexplx Jul 13, 2026
ac8d73e
fix(docs): correct fly deploy README against verified runtime behavior
rexplx Jul 13, 2026
72202eb
fix(deploy): copy tsdown.config.ts into the Docker build context
rexplx Jul 13, 2026
b3ddc62
fix(observability): don't re-initialize Sentry if already initialized
rexplx Jul 13, 2026
202e62c
fix(deploy): bake sentry-preload.cjs into the image
rexplx Jul 13, 2026
377fa63
fix(api): honor limit on GET /agentmemory/sessions and memory_sessions
rexplx Jul 15, 2026
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
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.git/
node_modules/
dist/
*.tgz
*.log
.DS_Store
.env
.env.*
!.env.example
data/
data-*/
agentmemory-debug/
.gstack/
benchmark/
eval/
docs/
READMEs/
assets/
CHANGELOG.md
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ data-*/
agentmemory-debug/
.gstack/

# Lock files — never commit (see feedback_no_lockfiles memory)
# Lock files — never commit (see feedback_no_lockfiles memory), except a
# lockfile scoped ONLY to the Fly deploy build context, which is
# deliberately committed for build reproducibility (deploy/fly/README.md).
package-lock.json
pnpm-lock.yaml
yarn.lock
!deploy/fly/package-lock.json
integrations/hermes/__pycache__/

# Eval reports (transient; published scorecards live in docs/benchmarks/)
Expand Down
43 changes: 40 additions & 3 deletions deploy/fly/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,34 @@ ARG III_VERSION=0.11.2

FROM iiidev/iii:${III_VERSION} AS iii-image

# Builder stage: packs this branch's checked-out source into an npm
# tarball at image-build time. The Dockerfile previously installed the
# published `@agentmemory/agentmemory@${AGENTMEMORY_VERSION}` npm package,
# which can't ship a fork patch until it's released upstream; an interim
# local workaround (a manually-built, untracked tarball) covered that gap
# but had no build-time check that it matched the checked-out source — a
# fresh checkout with no local tarball would break, and a source change
# with no tarball rebuild would silently ship stale code. Build context is
# the repo root (see deploy/fly/README.md), so this stage sees the same
# source tree `npm run build` would use locally.
FROM node:22-slim AS builder
WORKDIR /build
# deploy/fly/package-lock.json is a lockfile scoped ONLY to this build
# context, committed despite the repo-wide no-lockfile policy (see the
# .gitignore exception) so this stage gets a reproducible dependency tree
# instead of re-resolving semver ranges on every build. Regenerate it
# deliberately (npm install --package-lock-only against the root
# package.json) whenever a dependency is intentionally bumped.
COPY package.json deploy/fly/package-lock.json ./
RUN npm ci
COPY tsconfig.json tsdown.config.ts ./
COPY src/ ./src/
COPY plugin/ ./plugin/
COPY iii-config.yaml iii-config.docker.yaml docker-compose.yml .env.example LICENSE README.md AGENTS.md ./
RUN npm run build && mkdir -p /build/out && npm pack --pack-destination /build/out

FROM node:22-slim

ARG AGENTMEMORY_VERSION=0.9.27
ARG III_VERSION=0.11.2
ARG III_SDK_VERSION=0.11.2

Expand All @@ -21,14 +46,26 @@ COPY --from=iii-image /app/iii /usr/local/bin/iii
# is not refactored for yet). `npm install -g` ignores overrides, hence
# the local prefix.
WORKDIR /opt/agentmemory
COPY --from=builder /build/out/*.tgz /opt/agentmemory/agentmemory.tgz
RUN printf '{"name":"agentmemory-deploy","version":"1.0.0","private":true,"overrides":{"iii-sdk":"%s"}}\n' "${III_SDK_VERSION}" > package.json \
&& npm install "@agentmemory/agentmemory@${AGENTMEMORY_VERSION}" --omit=optional --no-fund --no-audit \
&& npm install ./agentmemory.tgz --omit=optional --no-fund --no-audit \
&& ln -s /opt/agentmemory/node_modules/.bin/agentmemory /usr/local/bin/agentmemory

# Optional NODE_OPTIONS preload for broad crash reporting: set
# NODE_OPTIONS="--require /opt/agentmemory/sentry-preload.cjs"
# to capture uncaught exceptions/module-load failures that happen before
# this package's own initSentry() (src/observability/sentry.ts) gets a
# chance to run. Requires @sentry/node, already installed above as a
# dependency of the packed tarball. No-op (just logs and exits the
# require silently-successful) when SENTRY_DSN is unset. initSentry()
# detects an already-initialized client from this preload and reuses it
# instead of re-initializing over its tracesSampleRate/release.
COPY deploy/fly/sentry-preload.cjs /opt/agentmemory/sentry-preload.cjs

ENV AGENTMEMORY_III_VERSION=${III_VERSION} \
TINI_SUBREAPER=1

COPY --chmod=0755 entrypoint.sh /usr/local/bin/agentmemory-entrypoint.sh
COPY --chmod=0755 deploy/fly/entrypoint.sh /usr/local/bin/agentmemory-entrypoint.sh

EXPOSE 3111

Expand Down
55 changes: 39 additions & 16 deletions deploy/fly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,25 @@ flow stays consistent:

```bash
# 1. Install flyctl: https://fly.io/docs/flyctl/install/
# 2. Pick your unique app name (and matching volume name):
# 2. Pick your unique app name:
export APP="agentmemory-$(whoami)" # or any other globally-unique name
export VOLUME="${APP//-/_}_data" # Fly volume names can't contain '-'

# 3. From this directory:
fly launch --copy-config --no-deploy --name "$APP"
export VOLUME="agentmemory_data" # must exactly match [[mounts]].source
# in deploy/fly/fly.toml — NOT derived
# from $APP (that volume would never
# get attached to the app)

# 3. From the REPO ROOT (not this directory) — the Dockerfile packs
# checked-out source into an npm tarball at build time, so the build
# context must be the whole repo, not deploy/fly/. (flyctl reads the
# Dockerfile path from fly.toml's own [build].dockerfile field, resolved
# relative to deploy/fly/ — there's no working CLI flag to override it.)
fly launch --copy-config --no-deploy --name "$APP" --config deploy/fly/fly.toml

# 4. Create the volume in the same region as the app:
fly volumes create "$VOLUME" --region iad --size 1

# 5. Deploy:
fly deploy --app "$APP"
# 5. Deploy (still from the repo root):
fly deploy . --config deploy/fly/fly.toml --app "$APP"
```

If `fly launch` reports the name is taken, pick another value for `$APP`,
Expand Down Expand Up @@ -115,6 +122,7 @@ inside the machine.
fly ssh console --app "$APP"
rm /data/.hmac
exit
fly machine list --app "$APP" # copy the machine ID from the ID column
fly machine restart <machine-id>
fly logs --app "$APP" | grep AGENTMEMORY_SECRET=
```
Expand All @@ -132,6 +140,7 @@ To restore on a fresh machine:

```bash
cat "$APP-YYYYMMDD.tar.gz" | fly ssh console --app "$APP" -C "tar xzf - -C /"
fly machine list --app "$APP" # copy the machine ID from the ID column
fly machine restart <machine-id>
```

Expand All @@ -140,8 +149,8 @@ fly machine restart <machine-id>
- Idle (machine stopped): the volume costs ~$0.15/GB/month. A 1 GB
volume is roughly $0.15/month.
- Active (machine running on `shared-cpu-1x` with 512 MB): about
$1.94/month if it ran 24/7; in practice `auto_stop_machines` keeps
that well under $1.
$3.69/month if it ran 24/7 (per Fly's current pricing page); in
practice `auto_stop_machines` keeps that well under $1.
Comment on lines 151 to +153

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant section of the README
sed -n '130,170p' deploy/fly/README.md

# Look for the region and pricing references nearby
rg -n "iad|shared-cpu-1x|3\\.69|3\\.32|pricing" deploy/fly/README.md

Repository: rohitg00/agentmemory

Length of output: 2023


🌐 Web query:

Fly pricing shared-cpu-1x 512 MB iad monthly current pricing

💡 Result:

As of July 13, 2026, the monthly cost for a shared-cpu-1x machine with 512 MB of RAM on Fly.io is $3.19 [1][2][3]. This pricing is based on the resource usage rate of $0.0044 per hour [1]. Fly.io billing for compute resources is consistent across its regions, including iad (Northern Virginia), and is calculated based on the specific machine configuration [1][4]. Please note that while individual resource usage is billed at these rates, your account may also be subject to the costs associated with the specific Fly.io plan you are subscribed to (e.g., Hobby or Launch plans), which may have separate monthly base fees [3].

Citations:


Update the Fly compute estimate. The current shared-cpu-1x 512 MB rate is about $3.19/month, and Fly compute pricing is region-independent, so the $3.69/month figure is outdated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@deploy/fly/README.md` around lines 151 - 153, Update the active Fly compute
estimate in the pricing section of README.md from $3.69/month to about
$3.19/month, while preserving the existing 24/7, shared-cpu-1x, 512 MB, and
auto_stop_machines context.

Source: MCP tools

- Outbound bandwidth: 100 GB/month free on the Hobby plan, then $0.02/GB
in North America / Europe.

Expand All @@ -152,15 +161,29 @@ See <https://fly.io/docs/about/pricing/> for the up-to-date rate card.
- The volume lives in one region. To survive a region outage, create a
second volume in another region and update `primary_region` after the
failover, or take snapshots with `fly volumes snapshots create`.
- The Dockerfile builds in the Fly Builder on every deploy — first
build is ~30 seconds; cached layers shrink rebuilds to under 10
seconds. Image is ~114 MB.
- The Dockerfile builds in the Fly Builder on every deploy — the
`builder` stage compiles this branch's checked-out source and packs
it into an npm tarball, so the shipped image always matches the
commit you deploy from (no manually-built tarball to keep in sync).
First build is ~60 seconds (includes `npm ci` + `npm run build` +
`npm pack`); cached layers shrink rebuilds to well under that when
only `src/` changed. Image is ~124 MB.
- First deploy lands on a **shared IPv4 + dedicated IPv6** by default
(free). If you need a dedicated IPv4 for legacy clients without SNI,
run `fly ips allocate-v4 --app "$APP"` — costs $2/month.
- Cold-start (from machine launch to passing `/agentmemory/livez`) is
~9 seconds measured. `grace_period = "30s"` on the health check
gives a 3x safety margin.
- Bump `AGENTMEMORY_VERSION` or `III_VERSION` in the Dockerfile to
upgrade. `fly deploy --build-arg AGENTMEMORY_VERSION=<x>` also works
for a one-off without editing the file.
gives more than 3x safety margin.
- To upgrade `III_VERSION` (the `iii` engine binary), bump the
`ARG III_VERSION` default in `deploy/fly/Dockerfile` or pass
`--build-arg III_VERSION=<x>` on deploy. To upgrade the agentmemory
code itself, just commit the change and deploy — the builder stage
packs whatever is checked out, so there is no separate version arg to
bump.
- `deploy/fly/package-lock.json` is a lockfile scoped only to this build
context (the repo otherwise gitignores lockfiles). It's committed for
build reproducibility and used by the builder stage's `npm ci`. When
you intentionally bump a dependency in `package.json`, regenerate it:
`npm install --package-lock-only && cp package-lock.json deploy/fly/package-lock.json && rm package-lock.json`
(run from the repo root). A stale lockfile makes `npm ci` fail loudly
at build time rather than silently drifting.
7 changes: 7 additions & 0 deletions deploy/fly/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ app = "agentmemory"
primary_region = "iad"

[build]
# flyctl resolves this path relative to the DIRECTORY CONTAINING
# THIS CONFIG FILE (deploy/fly/), not the build context root —
# verified empirically 2026-07-13: "deploy/fly/Dockerfile" here
# doubled up to deploy/fly/deploy/fly/Dockerfile at build time.
# The build CONTEXT is still the repo root (see deploy/fly/README.md
# for the full `fly deploy .` invocation) — only this dockerfile
# path is config-relative.
dockerfile = "Dockerfile"

[[mounts]]
Expand Down
Loading