Skip to content

feat(aml): AML Cycle 2 Add/Search adapter for AutoMem - #29

Draft
jack-arturo wants to merge 1 commit into
mainfrom
feat/aml-cycle2-adapter
Draft

jack-arturo wants to merge 1 commit into
mainfrom
feat/aml-cycle2-adapter

Conversation

@jack-arturo

Copy link
Copy Markdown
Member

Summary

Adds runners/aml/: a dependency-free Node adapter that exposes AutoMem through the Agent Memory Leaderboard Add/Search contract, for the Cycle 2 entry (opens 2026-09-20).

  • POST /add writes every message to AutoMem before echoing the AML ids. It is idempotent per request_id, returning 409 for a conflicting replay. It stores the message timestamp and AML ids as memory timestamp/metadata, with t_invalid set 30 days out.
  • POST /search recalls only the exact user_id (hashed tag). It pins tag_match=exact, expand_relations=false, expand_entities=false and scope_fallback=false rather than trusting server defaults (the tag_match default is prefix).
  • GET /health returns 503 when AutoMem is down.
  • It adds a Dockerfile for the academic code route, contract tests, a live-AutoMem smoke, and a README with the deployment and operations plan.

This ports an adapter first built in a private repo and merges in hardening from a duplicate implementation there. Closes nothing yet. The submission itself is gated by #28.

Verification

  • node --test runners/aml/adapter.test.mjs → 5/5 pass: Add/echo, scoped Search, cross-user isolation, pinned recall options, idempotency/409, 401/413/422, and 503 health.
  • Read-only probe against production AutoMem with the adapter's exact recallParams() → HTTP 200, server echoed tag_match: exact, 0 results for an unknown user. This shows the server accepts the pinned params.
  • Boot check: PORT=18790 node runners/aml/server.mjs → /health 503 with AutoMem unreachable, /search with an empty query → 422.
  • Not run here: runners/aml/smoke-live.mjs, which does a write → search → delete round trip. No local AutoMem was up, and I didn't want to write to production without asking. The pre-port version passed it against real AutoMem. The Docker build was also not run (Docker daemon down).

Before submission

Owner sign-off is required before any AML evaluation request, smoke, Full run, or publication request. The remaining steps are listed in #28.

🤖 Generated with Claude Code

Dependency-free Node HTTP adapter for the Agent Memory Leaderboard
Add/Search contract. /add stores each message in AutoMem before echoing
the AML ids (idempotent per request_id), /search returns ranked evidence
scoped to the exact user_id, /health probes AutoMem.

Search pins tag_match=exact and disables relation/entity expansion and
scope fallback rather than relying on server defaults, so one AML user
can never see another's records.

Refs #28

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T13:55:29.655534Z e2b2aeb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2b2aeb5d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread runners/aml/adapter.mjs
}

const baseUrl = automemUrl.replace(/\/+$/, '');
const completedAdds = new Map();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Persist idempotency across concurrent requests and replicas

When AML retries while the original /add is still in flight, after a process restart, or against the second replica recommended by the README, this process-local map has no completed entry, so the request writes every message again. That violates the endpoint's advertised idempotency and can corrupt recall results with duplicate memories; request IDs need a durable, shared, atomically claimed record rather than an instance-local post-write cache.

Useful? React with 👍 / 👎.

Comment thread runners/aml/adapter.mjs
Comment on lines +298 to +300
if (writes.some(upstream => !upstream.ok)) {
detail(response, 503, 'AutoMem could not persist the memory');
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Clean up or deduplicate partially successful adds

When one message write fails but another succeeds, this returns 503 while leaving the successful memory in AutoMem; the expected AML retry then writes that message again because the request is not recorded as completed. Network rejection is worse because Promise.all can reject while other writes remain in flight. Persist each message idempotently or delete successful writes before reporting failure so a transient upstream error cannot duplicate part of a conversation.

Useful? React with 👍 / 👎.

Comment thread runners/aml/adapter.mjs
method: 'POST',
headers: upstreamHeaders(automemApiKey),
body: JSON.stringify({
content: formatMessage(message),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle messages above AutoMem's content limit

When a valid Add request contains an individual message longer than AutoMem's verified 50,000-character /memory limit but remains below this adapter's 1 MB body limit, validation accepts it and forwards it unchanged, causing AutoMem to reject the write and the adapter to report a misleading 503. The repository already guards this limit in runners/beam_shim.py; this adapter should likewise chunk the content or reject it as a contract error before calling AutoMem.

Useful? React with 👍 / 👎.

@jack-arturo

Copy link
Copy Markdown
Member Author

Live smoke against a local AutoMem

Stack: a fresh docker compose of automem main (3caa9d5) under an isolated project with empty volumes, torn down afterwards.

  • node runners/aml/smoke-live.mjs → PASS (add → scoped search → a different user_id gets nothing → delete).
  • An extended contract check, run ad hoc (not committed), also passed:
    • A 3-message add with timestamps: the ids are echoed exactly.
    • Replaying the same request_id adds nothing: the memory count went 0 → 4 for 3 + 1 messages.
    • Two users with overlapping content ("my dog … loves swimming"): each search returns only that user's records under the pinned tag_match=exact / no-expansion / no-fallback params.
    • top_k=1 is honored.
    • The evidence shape is {id, content, score, created_at}, and created_at reflects the AML message timestamp.
    • Cleanup took the memory count back to 0.

Readiness finding: vectors land after /add returns

POST /memory writes the graph record synchronously but queues the embedding unless the caller supplies one (automem/api/memory.py, the enqueue_embedding branch). Measured locally, the vector count was still 0 at about 0–1 s and reached 1 at about 3 s after the write returned. Keyword recall works immediately; semantic recall only after the vector lands.

AML requires that Add is synchronously persisted and searchable. If AML searches right after the last Add, the newest messages can be missing from vector recall. It showed up here: a semantic query for one user returned 1 of 2 related messages right after the add. Before the Cycle 2 run, choose one:

  1. The adapter computes embeddings and passes embedding on POST /memory (synchronous vector write; needs the same embedding model/provider as the server).
  2. The adapter waits for its own records' vectors before returning from /add.
  3. A server-side synchronous-embed option in automem.

Option 1 matches the contract most directly; option 3 is the cleanest if other clients need it too.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Member Author

Status: blocked on the explicit human owner sign-off in #28 (division/route, frozen AutoMem version, and public deployment target). Verified current head e2b2aeb5d4532c798424b7d9e1a15951f14da579: node --test runners/aml/adapter.test.mjs passes 5/5. GitHub reports no checks configured. Per #28, no AML evaluation request, smoke submission, Full run, publication request, or merge is being performed.

@autohub-codex

autohub-codex Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Backlog triage (2026-09-28): rechecked current head e2b2aeb5d4532c798424b7d9e1a15951f14da579 against main: mergeable/CLEAN, 819 additions across 7 files, no GitHub checks configured, and current-head Codex is settled by reviewed-commit marker. Exact blocker remains the explicit human-owner sign-off in #28: AML division/route, frozen AutoMem version, and public deployment target. Do not merge or submit Cycle 2 work until those decisions are recorded.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parked-post-launch Parked until after the Dec 15 launch. Not under review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant