Add MemoryProvider.EnsureMemoryStoreCreated create-if-missing helper to Foundry provider - #627
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an exported helper on the Foundry MemoryProvider to provision the configured memory store on-demand, enabling Go callers to “create-if-missing” without using the internal Foundry client directly.
Changes:
- Added
(*MemoryProvider).EnsureMemoryStoreCreated(...)which GETs the configured store and POSTs a default definition on HTTP 404. - Added a table-driven test covering the exists / missing / non-404-error paths using the recording transport harness.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| provider/foundryprovider/memory.go | Adds EnsureMemoryStoreCreated to create the configured Foundry memory store when missing. |
| provider/foundryprovider/memory_test.go | Adds table tests validating no-op on 200, create on 404, and error propagation on non-404. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _, err = p.client.CreateMemoryStore(ctx, p.memoryStoreName, def, options) | ||
| return err |
There was a problem hiding this comment.
Good catch — fixed in 02acc77: CreateMemoryStore now treats an HTTP 409 conflict as success, so a concurrent create between the GET (404) and the POST is a no-op. Added a test case covering the conflict path.
e08b330 to
ba37c1f
Compare
This comment has been minimized.
This comment has been minimized.
ba37c1f to
923dfdd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
NewMemoryProvider required an existing Foundry memory store. Add a create-if-missing helper that gets the store and provisions a default store backed by the given chat and embedding model deployments only when it is absent (HTTP 404), matching the memory-store provisioning ergonomics in the .NET and Python Foundry providers. Other retrieval errors are returned unchanged.
…nt create Treat an HTTP 409 conflict from CreateMemoryStore as success to close the TOCTOU race between the GET (404) and the POST.
02acc77 to
4703445
Compare
This comment has been minimized.
This comment has been minimized.
# Conflicts: # provider/foundryprovider/memory.go # provider/foundryprovider/memory_test.go
Head branch was pushed to by a user without write access
Go API Consistency Review — PR #627Scope: Upstream parity check✅ .NET — aligned
public async Task EnsureMemoryStoreCreatedAsync(
string chatModel,
string embeddingModel,
string? description = null,
CancellationToken cancellationToken = default)The Go signature
|
Adds an exported
EnsureMemoryStoreCreated(ctx, chatModel, embeddingModel string, description *string) errormethod to the FoundryMemoryProvider.What
GetMemoryStore.MemoryStoreDefaultDefinitionbacked by the given chat and embedding model deployments, applyingdescriptionwhen non-nil, and returns the create error.Why
NewMemoryProviderdocuments thatmemoryStoreNamemust name an existing store, leaving no ergonomic way to provision one from Go. The .NET and Python Foundry providers expose an equivalent create-if-missing helper over their memory-store clients; this brings the Go port to parity so callers can bootstrap a store without dropping down to the internalazaiprojectsclient.How tested
Table test in
memory_test.gousing the existing recording-transport harness:/memory_storeswith the chat/embedding model names and description in the body, returns nil.