feat: add MemoryClient for control plane + data plane passthrough#108
feat: add MemoryClient for control plane + data plane passthrough#108Hweinstock wants to merge 1 commit intoaws:mainfrom
Conversation
d2979e0 to
b4de70e
Compare
b4de70e to
33131b3
Compare
33131b3 to
348f528
Compare
348f528 to
2cf0750
Compare
2cf0750 to
c313fd0
Compare
c313fd0 to
7426b20
Compare
7426b20 to
f279131
Compare
f279131 to
d52638d
Compare
d52638d to
5dac0fc
Compare
5dac0fc to
54196ff
Compare
54196ff to
3e1f10c
Compare
3e1f10c to
21ec2eb
Compare
21ec2eb to
7ccb703
Compare
7ccb703 to
05cfe89
Compare
05cfe89 to
3a62c5d
Compare
3a62c5d to
27f582e
Compare
27f582e to
680233d
Compare
| return Array.from(branches.values()) | ||
| } | ||
|
|
||
| memory(memoryId: string): ScopedMemory { |
There was a problem hiding this comment.
I like this design, but I dont understand the benefits of having a ScopeMemory. Could you explain why a customer just provide the memoryId themselves each time they call createEvent and similar functions?
There was a problem hiding this comment.
mostly verbosity, there is no reason they can't manually provide an ID each time. I saw it as concise way to combine a memory-scoped client, and a raw SDK client into a single interface. The same functionality is split between clients in the existing python implementation.
Happy to leave it out, if we think its awkward/wont be used.
71ebaf4 to
680233d
Compare
680233d to
c28b662
Compare
c28b662 to
18dd5ee
Compare
| * @returns `true` if the condition was met, `false` if timed out (only when `timeoutErrorMessage` is not set) | ||
| * @throws Error with `timeoutErrorMessage` if provided and timeout expires | ||
| */ | ||
| export async function pollUntil( |
| function fakeControlPlane(overrides: Record<string, (input: unknown) => unknown>): Record<string, unknown> { | ||
| return new Proxy({} as Record<string, unknown>, { | ||
| get: (_, method) => overrides[method as string] ?? (() => Promise.resolve({})), | ||
| }) | ||
| } | ||
|
|
||
| function fakeDataPlane(overrides: Record<string, (input: unknown) => unknown>): Record<string, unknown> { | ||
| return new Proxy({} as Record<string, unknown>, { | ||
| get: (_, method) => overrides[method as string] ?? (() => Promise.resolve({})), | ||
| }) | ||
| } |
There was a problem hiding this comment.
SUPER NIT: is there any reason these are diff, they are both the same implementation just diff names.
It could be something like fakeClient(....)
Per review feedback on PR #108: drop the memory-scoped interface since customers can pass memoryId directly to each MemoryClient method without meaningful verbosity savings. Removes: - MemoryClient.memory(memoryId) factory - ScopedMemory interface and export - Scoping-focused tests Tests now call getLastKTurns and listBranches directly with memoryId. Also applies prettier formatting to PR #108 files that were flagged by the format:check hook. Confidence: high Scope-risk: narrow
chore: merge PR #108 MemoryClient into feat/agentcore-memory
Description
Add MemoryClient for Bedrock AgentCore Memory, covering both control plane and data plane operations.
Uses a Proxy with declaration merging to expose a curated set of AWS SDK methods as direct passthroughs on the client.
.memory(memoryId)returns a scoped ScopedMemory that auto-injects the memoryId into every call, reducing repetition when operating on a single memory.Convenience methods for common workflows:
createOrGetMemory— idempotent create (falls back to get on conflict)createMemoryAndWait/deleteMemoryAndWait— polling wrapperswaitForMemories— polls until LTM extraction produces recordsgetLastKTurns— retrieves the last K conversation turns grouped by USER boundarieslistBranches— aggregates branch info from eventsCore design decisions vs Python SDK:
NOTE: Not yet published into the vended SDK, no entry in the package.json exports map. Will be added once integration tests are in place.
Testing
Unit tests use dependency injection (injectable SDK clients via
MemoryClientConfig) with simple fakes to avoid mocks. Tests verify:Type of Change
New feature
Checklist
#125
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.