Skip to content

Add MemoryProvider.EnsureMemoryStoreCreated create-if-missing helper to Foundry provider - #627

Merged
George Adams (gdams) merged 3 commits into
microsoft:mainfrom
PratikDhanaveFork:foundry-ensure-memory-store
Aug 5, 2026
Merged

Add MemoryProvider.EnsureMemoryStoreCreated create-if-missing helper to Foundry provider#627
George Adams (gdams) merged 3 commits into
microsoft:mainfrom
PratikDhanaveFork:foundry-ensure-memory-store

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Adds an exported EnsureMemoryStoreCreated(ctx, chatModel, embeddingModel string, description *string) error method to the Foundry MemoryProvider.

What

  • Retrieves the configured memory store via GetMemoryStore.
  • If it exists, the call is a no-op (returns nil).
  • If it is missing (HTTP 404), creates a MemoryStoreDefaultDefinition backed by the given chat and embedding model deployments, applying description when non-nil, and returns the create error.
  • Any other retrieval error is returned unchanged.

Why

NewMemoryProvider documents that memoryStoreName must 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 internal azaiprojects client.

How tested

Table test in memory_test.go using the existing recording-transport harness:

  • GET returns 200 -> returns nil, no POST.
  • GET returns 404 -> POST /memory_stores with the chat/embedding model names and description in the body, returns nil.
  • GET returns a non-404 error -> error propagated, no create issued.

Copilot AI review requested due to automatic review settings July 23, 2026 05:46
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner July 23, 2026 05:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread provider/foundryprovider/memory.go Outdated
Comment on lines +140 to +141
_, err = p.client.CreateMemoryStore(ctx, p.memoryStoreName, def, options)
return err

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 23, 2026
@github-actions github-actions Bot added the public-api-change Pull Request changes public APIs label Jul 24, 2026
@github-actions

This comment has been minimized.

@github-actions

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.
@github-actions

This comment has been minimized.

# Conflicts:
#	provider/foundryprovider/memory.go
#	provider/foundryprovider/memory_test.go
auto-merge was automatically disabled August 4, 2026 05:40

Head branch was pushed to by a user without write access

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Go API Consistency Review — PR #627

Scope: provider/foundryprovider/memory.go — new exported method EnsureMemoryStoreCreated

Upstream parity check

✅ .NET — aligned

dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs exposes:

public async Task EnsureMemoryStoreCreatedAsync(
    string chatModel,
    string embeddingModel,
    string? description = null,
    CancellationToken cancellationToken = default)

The Go signature EnsureMemoryStoreCreated(ctx context.Context, chatModel, embeddingModel string, description *string) error is semantically identical:

  • Same positional arguments (chatModel, embeddingModel, optional description)
  • *string for description mirrors .NET nullable string?
  • context.Context replaces CancellationToken per Go idioms
  • error return matches .NET throwing on create failure
  • Create-if-missing logic (GET → 404 → POST) matches the internal .NET helper MemoryStoreExtensions.CreateMemoryStoreIfNotExistsAsync

⚠️ Python — no equivalent yet

python/packages/foundry/agent_framework_foundry/_memory_provider.py (FoundryMemoryProvider) does not expose an ensure_memory_store_created method. The PR description states Python has an equivalent, but the source only has before_run/after_run hooks — no create-if-missing public method.

This is a gap in the Python SDK, not a divergence introduced by this PR. The Go implementation correctly tracks the .NET surface. A follow-up to the upstream Python package would bring Python to parity.

Summary

This PR is approved for cross-repo parity against the .NET Foundry provider. The public-api-change label is correctly present. No parity issues are introduced by this change.

Generated by Go API Consistency Review Agent · sonnet46 · 28.9 AIC · ⌖ 5.66 AIC · ⊞ 5.7K ·

@gdams
George Adams (gdams) added this pull request to the merge queue Aug 5, 2026
Merged via the queue into microsoft:main with commit aa1b99f Aug 5, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants