Skip to content

[wrangler] Add agent_memory binding support and namespace commands#13610

Merged
penalosa merged 34 commits into
mainfrom
pbd/agent-memory
May 29, 2026
Merged

[wrangler] Add agent_memory binding support and namespace commands#13610
penalosa merged 34 commits into
mainfrom
pbd/agent-memory

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Adds support for Cloudflare's Agent Memory service in Wrangler and Miniflare.

Binding

{
  "agent_memory": [
    { "binding": "MY_MEMORY", "namespace": "my-namespace" }
  ]
}

Remote-only — wrangler dev proxies to the live API via a new Miniflare plugin. wrangler deploy provisions missing namespaces automatically. wrangler types emits typed AgentMemoryNamespace bindings (runtime type from cloudflare/workerd#6628).

Commands (private beta)

wrangler agent-memory namespace create <namespace>
wrangler agent-memory namespace list   [--json]
wrangler agent-memory namespace get    <namespace_name> [--json]
wrangler agent-memory namespace delete <namespace_name> [--force]

Adds the agent-memory:write OAuth scope to default login scopes.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Apr 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dd0ec30

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
miniflare Minor
wrangler Minor
@cloudflare/pages-shared Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Apr 20, 2026
@ask-bonk

ask-bonk Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

UnknownError: ProviderInitError

github run

@ask-bonk

ask-bonk Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

@petebacondarwin Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@pkg-pr-new

pkg-pr-new Bot commented Apr 20, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13610

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@13610

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13610

miniflare

npm i https://pkg.pr.new/miniflare@13610

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13610

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13610

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13610

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13610

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13610

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@13610

wrangler

npm i https://pkg.pr.new/wrangler@13610

commit: dd0ec30

@petebacondarwin petebacondarwin marked this pull request as ready for review April 20, 2026 17:07
@workers-devprod workers-devprod requested review from a team and ascorbic and removed request for a team April 20, 2026 17:08
@workers-devprod

workers-devprod commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/miniflare/src/plugins/agent-memory/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/index.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/config.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/environment.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/map-worker-metadata-bindings.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/types.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/worker.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/e2e/agent-memory.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/e2e/remote-binding/miniflare-remote-resources.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/e2e/remote-binding/workers/agent-memory.js: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/agent-memory.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/create-worker-upload-form/bindings.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/bindings.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/index.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/print-bindings.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/provision.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/type-generation.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/whoami.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/client.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/create.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/delete.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/get.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/list.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/provisioning.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/utils.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/core/teams.d.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/check-remote-secrets-override.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/config-diffs.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/bindings.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev/miniflare/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/type-generation/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/user/user.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/utils/print-bindings.ts: [@cloudflare/wrangler]
  • tools/e2e/common.ts: [@cloudflare/wrangler]
  • tools/e2e/e2eCleanup.ts: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@penalosa penalosa left a comment

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.

Initial pass. My main concern at this stage is the agentmemory/agent_memory/agent_memory_namespace naming confusion

Comment thread packages/workers-utils/src/config/environment.ts
Comment thread packages/workers-utils/src/config/validation.ts Outdated
Comment thread packages/workers-utils/src/map-worker-metadata-bindings.ts Outdated
Comment thread packages/wrangler/e2e/agent-memory.test.ts
Comment thread packages/wrangler/src/__tests__/deploy/bindings.test.ts Outdated
Comment thread packages/wrangler/src/__tests__/index.test.ts Outdated
Comment thread packages/wrangler/src/agent-memory/client.ts
Comment thread packages/wrangler/src/agent-memory/create.ts
Comment thread packages/wrangler/src/agent-memory/create.ts Outdated
Comment thread packages/wrangler/src/agent-memory/provisioning.ts
@oliy

oliy commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Looks this doesn't include the new OAuth permissions.

@oliy

oliy commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Not completely sure how "remote" bindings are implemented, but they don't seem to work.

@oliy

oliy commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

As for naming, you make good points on the consistency. Since we are not constrained by agent week deadlines, we are going to make changes to center on using "agent-memory" in the naming. (and "agent_memory", as necessary).
Unfortunately, this means numerous changes in other systems (EWC, API Gateway, etc.)

@github-actions

github-actions Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

Marking as draft while @oliy works through some backend updates (e.g. around the agentmemory/agent-memory/agent_memory naming etc)

@petebacondarwin petebacondarwin marked this pull request as draft April 24, 2026 13:37
@petebacondarwin petebacondarwin marked this pull request as ready for review April 30, 2026 09:10
@workers-devprod

workers-devprod commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/agent-memory-binding-support.md: [@cloudflare/wrangler]
  • .changeset/agent-memory-namespace-commands.md: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/agent-memory/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/index.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/config.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/environment.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/map-worker-metadata-bindings.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/types.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/worker.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/e2e/agent-memory.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/e2e/remote-binding/miniflare-remote-resources.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/e2e/remote-binding/workers/agent-memory.js: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/agent-memory.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/create-worker-upload-form/bindings.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/bindings.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/index.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/print-bindings.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/provision.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/type-generation.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/whoami.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/client.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/create.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/delete.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/get.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/list.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/agent-memory/provisioning.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/utils.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/core/teams.d.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/check-remote-secrets-override.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/config-diffs.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/bindings.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev/miniflare/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/type-generation/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/user/user.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/utils/print-bindings.ts: [@cloudflare/wrangler]
  • tools/e2e/common.ts: [@cloudflare/wrangler]
  • tools/e2e/e2eCleanup.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@oliy oliy force-pushed the pbd/agent-memory branch 2 times, most recently from 779c979 to dd9bf72 Compare May 4, 2026 16:11

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 1 new potential issue.

🐛 1 issue in files not directly in the diff

🐛 Missing agent_memory in pickRemoteBindings causes binding to be silently dropped during wrangler dev (packages/wrangler/src/api/remoteBindings/index.ts:42-48)

agent_memory is an always-remote binding (confirmed by the changeset description, the miniflare plugin calling warnOrError("agent_memory", memory.remote, "always-remote") at packages/wrangler/src/dev/miniflare/index.ts:637, and by the miniflare plugin only implementing remote proxy). However, the pickRemoteBindings function at packages/wrangler/src/api/remoteBindings/index.ts:18-52 does not include agent_memory in its list of always-remote types. Every other always-remote binding (ai, media, artifacts, vpc_service, vpc_network, ai_search_namespace, ai_search) is explicitly listed. Without this, an agent_memory binding will only be picked for the remote proxy session if the user explicitly sets remote: true in their config. Since remote is optional (remote?: boolean in packages/workers-utils/src/config/environment.ts:1069), most users won't set it, causing the binding to silently not work during local development.

View 19 additional findings in Devin Review.

Open in Devin Review

Wrap startRemoteProxySession() in retry() to handle transient
Cloudflare API 5xx (most commonly edge-preview returning 500),
which has been blocking shard 3 of this PR consistently for 2+
days. Test-only change; no runtime behaviour modified.

Refs: #13831
Boot the remote proxy session in beforeAll with only the first test
case's bindings, then call updateBindings inside each `it` to install
that test case's bindings. Previously every test case's bindings were
merged into a single startRemoteProxySession call, causing the boot to
time out as the suite grew. The new flow makes the boot smaller and
attributes any per-binding boot failure to the test that owns that
binding rather than to an opaque beforeAll timeout.

Also drop the retry wrapper around startRemoteProxySession in both the
main and mTLS describe blocks.
The agent-memory worker binding API uses `getProfile()` (not
`getContext()`), and the result's text field is `profile` (not
`context`). Update the test worker and assertion to match.
- Update unit test to import runInTempDir from
  @cloudflare/workers-utils/test-helpers (the helper was moved out of
  packages/wrangler/src/__tests__/helpers/ in main).
- Drop the open-beta status warning expectation from the two e2e tests
  that run with --json. PR #13837 made the status warning honor the
  printBanner result, so commands with printBanner: (args) => !args.json
  now suppress the warning in JSON mode.
devin-ai-integration[bot]

This comment was marked as resolved.

@petebacondarwin petebacondarwin force-pushed the pbd/agent-memory branch 2 times, most recently from 5308f7a to a0db0f6 Compare May 22, 2026 12:04
@petebacondarwin petebacondarwin added the product:agent-memory Relating to Cloudflare Agent Memory: https://developers.cloudflare.com/agent-memory/ label May 22, 2026
penalosa pushed a commit to cloudflare/workerd that referenced this pull request May 28, 2026
Adds minimal type declarations for the AgentMemoryNamespace binding so
user-facing `wrangler types` output in workers-sdk can reference them.
The real runtime API surface is owned by the Agent Memory team and is
expected to extend this scaffold.

Related: cloudflare/workers-sdk#13610
danlapid pushed a commit to cloudflare/workerd that referenced this pull request May 28, 2026
* Add AgentMemoryNamespace types scaffold

Adds minimal type declarations for the AgentMemoryNamespace binding so
user-facing `wrangler types` output in workers-sdk can reference them.
The real runtime API surface is owned by the Agent Memory team and is
expected to extend this scaffold.

Related: cloudflare/workers-sdk#13610

* Added real type files for Agent Memory API (#6783)

* fix types

* fix type snapshots

---------

Co-authored-by: Oliver Yu <387030+oliy@users.noreply.github.com>
Co-authored-by: Samuel Macleod <smacleod@cloudflare.com>
@workers-devprod

workers-devprod commented May 28, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@penalosa penalosa dismissed their stale review May 28, 2026 15:52

stale

penalosa added 2 commits May 28, 2026 17:03
- Add INHERIT_SYMBOL print-bindings test for agent_memory.
- Make the delete confirmation copy consistent with the rest of the
  agent_memory namespace user-facing copy ('OK to delete the Agent
  Memory namespace "…"?'). Updated unit tests to match.
- Clarify the load() comment on the agent_memory provisioning handler:
  load() only feeds the interactive 'Connect an existing X?' picker,
  which is unreachable here because namespace is required in config.
  isConnectedToExistingResource() (GET /namespaces/:name) is what
  actually prevents re-creating an existing namespace.
- Rewrite the getAgentMemoryNamespace docstring and drop a misleading
  copy-pasted inline comment.
- Lowercase the create-failure telemetry message to match the repo
  convention.

@workers-devprod workers-devprod left a comment

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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from In Review to Approved in workers-sdk May 28, 2026
@penalosa

Copy link
Copy Markdown
Contributor

This can go in once cloudflare/workerd#6628 is released (tonight)

@penalosa penalosa merged commit cbb39bd into main May 29, 2026
53 checks passed
@penalosa penalosa deleted the pbd/agent-memory branch May 29, 2026 11:00
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-remote-tests Run remote/E2E tests that require Cloudflare API credentials product:agent-memory Relating to Cloudflare Agent Memory: https://developers.cloudflare.com/agent-memory/

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants