Documentation
¶
Overview ¶
Package foundryprovider provides Microsoft Foundry provider integrations for agents.
Index ¶
- func NewAgent(endpoint string, credential azcore.TokenCredential, target AgentTarget, ...) *agent.Agent
- func WithClientHeader(name string, value string) agent.Option
- func WithClientHeaders(headers map[string]string) agent.Option
- type AgentConfig
- type AgentTarget
- type MemoryProvider
- func (p *MemoryProvider) EnsureMemoryStoreCreated(ctx context.Context, chatModel, embeddingModel string, description *string) error
- func (p *MemoryProvider) EnsureStoredMemoriesDeleted(ctx context.Context, session *agent.Session) error
- func (p *MemoryProvider) Invoked(ctx context.Context, invoked agent.InvokedContext) error
- func (p *MemoryProvider) Invoking(ctx context.Context, invoking agent.InvokingContext) ([]*message.Message, []agent.Option, error)
- type MemoryProviderConfig
- type ModelDeployment
- type ServerAgent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAgent ¶
func NewAgent(endpoint string, credential azcore.TokenCredential, target AgentTarget, config AgentConfig) *agent.Agent
NewAgent creates an agent.Agent backed by Microsoft Foundry.
The endpoint must be the Foundry project endpoint. When target is ServerAgent, NewAgent builds the server-side agent endpoint from the project endpoint and agent name.
func WithClientHeader ¶
WithClientHeader adds a single x-client-* header to a Foundry agent run.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
agent.Config
// ToolAutoCall configures automatic function-tool invocation. When nil, defaults
// are used.
ToolAutoCall *toolautocall.Config
// Instructions are provided to Foundry as system instructions for project Responses API agents.
// They are ignored for server-side Foundry prompt agents, whose instructions are owned by the service.
Instructions string
// DisableStoreOutput disables service-side Responses output storage.
// Use this when local session history providers own conversation state.
DisableStoreOutput bool
// OpenAIOptions configure the OpenAI-compatible per-agent client. Foundry-owned
// endpoint, authentication, and protocol options take precedence.
OpenAIOptions []option.RequestOption
}
AgentConfig contains configuration for Foundry-backed agents.
type AgentTarget ¶
type AgentTarget interface {
// contains filtered or unexported methods
}
AgentTarget identifies which Foundry agent mode NewAgent should use.
type MemoryProvider ¶
type MemoryProvider struct {
// contains filtered or unexported fields
}
MemoryProvider backs an agent.ContextProvider with Foundry memory stores.
func NewMemoryProvider ¶
func NewMemoryProvider(endpoint string, credential azcore.TokenCredential, memoryStoreName string, scope func(*agent.Session) string, config MemoryProviderConfig) *MemoryProvider
NewMemoryProvider creates a Foundry memory provider backed by a Microsoft Foundry Projects memory store.
The returned provider is attached to an agent with:
agent.Config{ContextProviders: []agent.ContextProvider{provider}}
The endpoint must be a project-scoped Microsoft Foundry endpoint, and memoryStoreName must name an existing Foundry memory store. The scope callback is invoked for each run and must return the Foundry memory scope that partitions stored memories, such as a user or tenant identifier. A blank scope is treated as a configuration error and panics when used.
func (*MemoryProvider) EnsureMemoryStoreCreated ¶
func (p *MemoryProvider) EnsureMemoryStoreCreated(ctx context.Context, chatModel, embeddingModel string, description *string) error
EnsureMemoryStoreCreated provisions the configured Foundry memory store when it does not already exist. It first retrieves the store; if the store is present the call is a no-op. When the store is missing (HTTP 404) it creates a default memory store backed by the given chat and embedding model deployments, applying description when non-nil. The helper is idempotent: if another process creates the store between the retrieval and the create, the resulting HTTP 409 conflict is treated as success. Any other retrieval or create error is returned unchanged.
func (*MemoryProvider) EnsureStoredMemoriesDeleted ¶
func (p *MemoryProvider) EnsureStoredMemoriesDeleted(ctx context.Context, session *agent.Session) error
EnsureStoredMemoriesDeleted deletes every memory stored for the session's scope in the backing Foundry memory store. The scope is resolved with the provider's scope callback, so a blank scope is treated as a configuration error and panics, matching the contract documented on NewMemoryProvider. A store that holds no memories for the scope responds with HTTP 404, which is treated as success. Any other error is returned to the caller.
func (*MemoryProvider) Invoked ¶
func (p *MemoryProvider) Invoked(ctx context.Context, invoked agent.InvokedContext) error
Invoked is called after an agent run to persist the request and response messages as memory updates in the Foundry memory store.
func (*MemoryProvider) Invoking ¶
func (p *MemoryProvider) Invoking(ctx context.Context, invoking agent.InvokingContext) ([]*message.Message, []agent.Option, error)
Invoking is called before an agent run. It searches the Foundry memory store for memories relevant to the incoming messages and returns them as additional context to inject into the run.
type MemoryProviderConfig ¶
type MemoryProviderConfig struct {
// ClientOptions configures the underlying Microsoft Foundry Projects client.
ClientOptions azcore.ClientOptions
// Logger receives provider diagnostics.
Logger *slog.Logger
// ContextPrompt prefixes retrieved memories injected into the run. The default
// prompt is "## Memories\nConsider the following memories when answering user questions:".
ContextPrompt *string
// MaxMemories limits the number of memories returned by search. Nil uses the
// default of 5.
MaxMemories *int32
// SearchInputFilter filters messages used to search for relevant memories. The
// default is [messagefilter.ExternalOnly].
SearchInputFilter messagefilter.Filter
// StorageInputRequestMessageFilter filters request messages before they are stored as
// memories. The default is [messagefilter.ExternalOnly].
StorageInputRequestMessageFilter messagefilter.Filter
// StorageInputResponseMessageFilter filters response messages before they are stored as
// memories. The default is [messagefilter.PassThrough].
StorageInputResponseMessageFilter messagefilter.Filter
// UpdateDelay controls Foundry memory extraction delay in seconds. The default is 0,
// which submits memory updates immediately.
UpdateDelay int32
}
MemoryProviderConfig configures a Foundry memory provider.
type ModelDeployment ¶
type ModelDeployment string
ModelDeployment identifies project Responses API mode for NewAgent.
type ServerAgent ¶
type ServerAgent string
ServerAgent identifies an existing server-side Foundry agent by name for NewAgent.