Skip to content

Add AgentMemoryNamespace types scaffold#6628

Draft
petebacondarwin wants to merge 1 commit intomainfrom
pbd/agent-memory-types
Draft

Add AgentMemoryNamespace types scaffold#6628
petebacondarwin wants to merge 1 commit intomainfrom
pbd/agent-memory-types

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

Summary

Adds minimal scaffold type declarations for the AgentMemoryNamespace binding class. This unblocks wrangler types output in workers-sdk PR cloudflare/workers-sdk#13610, which currently emits a reference to AgentMemoryNamespace that does not resolve in @cloudflare/workers-types.

Scope

This PR intentionally only declares the minimum surface visible from the workers-sdk e2e test (packages/wrangler/e2e/remote-binding/workers/agent-memory.js):

  • AgentMemoryNamespace.getContext(contextId: string): AgentMemoryContext
  • AgentMemoryContext.getSummary(): Promise<AgentMemoryContextSummary>
  • AgentMemoryContextSummary — an open record ([key: string]: unknown) with a @todo noting the real shape has not yet been declared

The real runtime API surface is owned by the Agent Memory product team. They should extend types/defines/agent-memory.d.ts with the complete API before the workers-sdk PR ships, or replace the scaffold with generated types from a C++ JSG resource.

Changes

  • types/defines/agent-memory.d.ts — new file, scaffold class declarations
  • types/generated-snapshot/experimental/index.d.ts — regenerated
  • types/generated-snapshot/experimental/index.ts — regenerated
  • types/generated-snapshot/latest/index.d.ts — regenerated
  • types/generated-snapshot/latest/index.ts — regenerated

Test plan

  • just generate-types runs cleanly against the new defines file locally.
  • CI `types` check should pass — the snapshot diff is strictly additive (76 lines per file, block inserted before AI Search defines).

Reviewer notes

Keeping this PR as a draft until:

  1. The Agent Memory team has signed off on the class/method names and extended the declarations with their real API, OR
  2. A decision is made to instead ship the types via C++ JSG from the agent-memory runtime binding (in which case this PR can be closed in favour of that approach).

cc @cloudflare/workers-sdk

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
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

Adds scaffold type declarations for AgentMemoryNamespace, AgentMemoryContext, and AgentMemoryContextSummary to unblock wrangler types in workers-sdk.

Overall this looks clean — naming follows the AgentMemory* prefix convention, the declare abstract class pattern matches other binding types (e.g., AiSearchNamespace, Workflow), and the generated snapshots are consistent with the source.

One issue:

  1. Missing type tests (low). types/AGENTS.md asks for type-level compile checks in test/types/ when adding new types. A minimal test exercising the getContextgetSummary chain would catch regressions if this scaffold is later extended or replaced. Something like:
// test/types/agent-memory.ts
const ns = {} as AgentMemoryNamespace;
const ctx: AgentMemoryContext = ns.getContext("id");
const summary: AgentMemoryContextSummary = await ctx.getSummary();
void summary;

I understand this is a draft and the types may be replaced entirely, so I'll leave this to your judgment on whether it's worth adding now or deferring until the real API shape lands.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 21, 2026

Review posted on PR #6628. The PR is well-structured with only one low-severity suggestion about adding type tests in test/types/. The types follow established naming conventions (AgentMemory* prefix), use the correct declare abstract class pattern consistent with other binding types like AiSearchNamespace and Workflow, and the generated snapshots are correctly produced from the source defines file.

github run

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.51%. Comparing base (9d1f25d) to head (2c960ab).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6628      +/-   ##
==========================================
- Coverage   70.89%   66.51%   -4.39%     
==========================================
  Files         438      405      -33     
  Lines      123821   115815    -8006     
  Branches    19486    19381     -105     
==========================================
- Hits        87785    77032   -10753     
- Misses      24486    27208    +2722     
- Partials    11550    11575      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Apr 21, 2026
- Rename emitted ambient type AgentMemory to AgentMemoryNamespace to
  match the type declared in workerd (cloudflare/workerd#6628) and
  follow the AiSearchNamespace precedent.
- Consolidate the AgentMemoryNamespace interface by importing it from
  agent-memory/client.ts in agent-memory/provisioning.ts instead of
  redeclaring a narrower shape there.
- Split agent-memory/client.ts into two layers: low-level helpers that
  take (complianceConfig, accountId, ...) and high-level wrappers that
  resolve auth via requireAuth. agent-memory/provisioning.ts now
  delegates to the low-level helpers, removing the duplicated fetch
  calls.
- Reorder the agent_memory block in deploy/config-diffs.ts so it sits
  alongside the related ai_search blocks.
petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Apr 22, 2026
- Rename emitted ambient type AgentMemory to AgentMemoryNamespace to
  match the type declared in workerd (cloudflare/workerd#6628) and
  follow the AiSearchNamespace precedent.
- Consolidate the AgentMemoryNamespace interface by importing it from
  agent-memory/client.ts in agent-memory/provisioning.ts instead of
  redeclaring a narrower shape there.
- Split agent-memory/client.ts into two layers: low-level helpers that
  take (complianceConfig, accountId, ...) and high-level wrappers that
  resolve auth via requireAuth. agent-memory/provisioning.ts now
  delegates to the low-level helpers, removing the duplicated fetch
  calls.
- Reorder the agent_memory block in deploy/config-diffs.ts so it sits
  alongside the related ai_search blocks.
petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Apr 25, 2026
- Rename emitted ambient type AgentMemory to AgentMemoryNamespace to
  match the type declared in workerd (cloudflare/workerd#6628) and
  follow the AiSearchNamespace precedent.
- Consolidate the AgentMemoryNamespace interface by importing it from
  agent-memory/client.ts in agent-memory/provisioning.ts instead of
  redeclaring a narrower shape there.
- Split agent-memory/client.ts into two layers: low-level helpers that
  take (complianceConfig, accountId, ...) and high-level wrappers that
  resolve auth via requireAuth. agent-memory/provisioning.ts now
  delegates to the low-level helpers, removing the duplicated fetch
  calls.
- Reorder the agent_memory block in deploy/config-diffs.ts so it sits
  alongside the related ai_search blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants