-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[wrangler] Add agent_memory binding support and namespace commands #13610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
petebacondarwin
wants to merge
29
commits into
main
Choose a base branch
from
pbd/agent-memory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
e5273fc
[wrangler] Add wrangler agent-memory namespace commands
petebacondarwin 862b5d1
[wrangler] Use namespace name instead of ID for agent-memory get/dele…
petebacondarwin cb7f39b
[workers-utils] Add agent_memory binding config and typing
petebacondarwin 09134fa
[wrangler] Wire remote-only agent_memory bindings through dev and deploy
petebacondarwin 6ba6871
[wrangler] Add type generation, tests, and config-diffs fix for agent…
petebacondarwin 6fa9251
fixes to use agent_memory_namespace type
oliy 1b3b6e9
Improve changeset description to follow official guidelines
petebacondarwin 4be1d27
Fix lint, format, and test type errors
petebacondarwin ddd56ed
Fix deploy/bindings test to use agent_memory_namespace
petebacondarwin 92bdc15
Address review feedback for agent_memory binding
petebacondarwin 2ae9fcc
Use fetchResult<void> for agent_memory delete
petebacondarwin ca9d124
Address more agent_memory review feedback
petebacondarwin 35ffa67
[wrangler] Add agentmemory:write OAuth scope
petebacondarwin 2769588
[wrangler] Wrap user-caused agent-memory errors as UserError
petebacondarwin 7ff5bef
fix the OAuth scope
petebacondarwin 4e82c66
`agent_memory_namespace` is actually just `agent_memory` now
petebacondarwin 935136f
fix type for new UserError
petebacondarwin 0225cce
fix API paths
petebacondarwin 1de595f
keep e2e namespace names below 32 chars
petebacondarwin 24c2b06
fixup creation test checks
petebacondarwin 5bd4958
tidy up telemetry message
petebacondarwin a545481
fixup! keep e2e namespace names below 32 chars
petebacondarwin e9de19d
fix e2e test colon mismatch in agent-memory create output
petebacondarwin 4b9703c
expect open-beta warning in agent-memory e2e test stderr
petebacondarwin 5b7b554
fix up e2e test and cleanup logic
petebacondarwin 2bf5b71
test: retry transient API 5xx in remote-binding e2e suite
petebacondarwin 53879be
test: refactor remote-binding e2e to use updateBindings per test
petebacondarwin 50cc148
test: fix agent-memory e2e to match runtime binding API
petebacondarwin 91d2b28
[wrangler] Fix agent-memory tests after upstream changes
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| "miniflare": minor | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Add support for `agent_memory` bindings | ||
|
|
||
| Agent Memory bindings allow Workers to connect to Cloudflare's Agent Memory service for storing and retrieving agent conversation state. This binding is remote-only, meaning it always connects to the Cloudflare API during `wrangler dev` rather than using a local simulation. | ||
|
|
||
| To configure an `agent_memory` binding, add the following to your `wrangler.json`: | ||
|
|
||
| ```jsonc | ||
| { | ||
| "agent_memory": [ | ||
| { | ||
| "binding": "MY_MEMORY", | ||
| "namespace": "my-namespace", | ||
| }, | ||
| ], | ||
| } | ||
| ``` | ||
|
|
||
| Wrangler will automatically provision the namespace during deployment if it does not already exist. Type generation via `wrangler types` is also supported. | ||
|
|
||
| This change also adds the `agent-memory:write` OAuth scope to Wrangler's default login scopes, so `wrangler login` can request the permissions needed to provision and manage Agent Memory namespaces. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Add `wrangler agent-memory namespace` commands | ||
|
|
||
| The following commands have been added for managing Agent Memory namespaces: | ||
|
|
||
| ```bash | ||
| 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] | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { z } from "zod"; | ||
| import { | ||
| getUserBindingServiceName, | ||
| ProxyNodeBinding, | ||
| remoteProxyClientWorker, | ||
| } from "../shared"; | ||
| import type { Plugin, RemoteProxyConnectionString } from "../shared"; | ||
|
|
||
| const AgentMemoryEntrySchema = z.object({ | ||
| namespace: z.string(), | ||
| remoteProxyConnectionString: z | ||
| .custom<RemoteProxyConnectionString>() | ||
| .optional(), | ||
| }); | ||
|
|
||
| export const AgentMemoryOptionsSchema = z.object({ | ||
| agentMemory: z.record(AgentMemoryEntrySchema).optional(), | ||
| }); | ||
|
|
||
| export const AGENT_MEMORY_PLUGIN_NAME = "agent-memory"; | ||
|
|
||
| const AGENT_MEMORY_SCOPE = "agent-memory"; | ||
|
|
||
| export const AGENT_MEMORY_PLUGIN: Plugin<typeof AgentMemoryOptionsSchema> = { | ||
| options: AgentMemoryOptionsSchema, | ||
| async getBindings(options) { | ||
| if (!options.agentMemory) { | ||
| return []; | ||
| } | ||
|
|
||
| return Object.entries(options.agentMemory).map(([bindingName, entry]) => ({ | ||
| name: bindingName, | ||
| service: { | ||
| name: getUserBindingServiceName( | ||
| AGENT_MEMORY_SCOPE, | ||
| bindingName, | ||
| entry.remoteProxyConnectionString | ||
| ), | ||
| }, | ||
| })); | ||
| }, | ||
| getNodeBindings(options) { | ||
| if (!options.agentMemory) { | ||
| return {}; | ||
| } | ||
|
|
||
| return Object.fromEntries( | ||
| Object.keys(options.agentMemory).map((bindingName) => [ | ||
| bindingName, | ||
| new ProxyNodeBinding(), | ||
| ]) | ||
| ); | ||
| }, | ||
| async getServices({ options }) { | ||
| if (!options.agentMemory) { | ||
| return []; | ||
| } | ||
|
|
||
| return Object.entries(options.agentMemory).map(([bindingName, entry]) => ({ | ||
| name: getUserBindingServiceName( | ||
| AGENT_MEMORY_SCOPE, | ||
| bindingName, | ||
| entry.remoteProxyConnectionString | ||
| ), | ||
| worker: remoteProxyClientWorker( | ||
| entry.remoteProxyConnectionString, | ||
| bindingName | ||
| ), | ||
| })); | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.