[wrangler] Add agent_memory binding support and namespace commands#13610
Conversation
🦋 Changeset detectedLatest commit: dd0ec30 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
|
UnknownError: ProviderInitError |
|
@petebacondarwin Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
penalosa
left a comment
There was a problem hiding this comment.
Initial pass. My main concern at this stage is the agentmemory/agent_memory/agent_memory_namespace naming confusion
|
Looks this doesn't include the new OAuth permissions. |
|
Not completely sure how "remote" bindings are implemented, but they don't seem to work. |
|
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). |
79346fe to
230fe18
Compare
|
✅ All changesets look good |
|
Marking as draft while @oliy works through some backend updates (e.g. around the agentmemory/agent-memory/agent_memory naming etc) |
6ffd5a4 to
181d5f5
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
779c979 to
dd9bf72
Compare
There was a problem hiding this comment.
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.
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.
91d2b28 to
33d40b8
Compare
5308f7a to
a0db0f6
Compare
a0db0f6 to
19d4cf6
Compare
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
* 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>
|
Codeowners approval required for this PR:
Show detailed file reviewers |
- 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
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
|
This can go in once cloudflare/workerd#6628 is released (tonight) |
Adds support for Cloudflare's Agent Memory service in Wrangler and Miniflare.
Binding
{ "agent_memory": [ { "binding": "MY_MEMORY", "namespace": "my-namespace" } ] }Remote-only —
wrangler devproxies to the live API via a new Miniflare plugin.wrangler deployprovisions missing namespaces automatically.wrangler typesemits typedAgentMemoryNamespacebindings (runtime type from cloudflare/workerd#6628).Commands (private beta)
Adds the
agent-memory:writeOAuth scope to default login scopes.A picture of a cute animal (not mandatory, but encouraged)