Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/azd/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,16 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
// AI & LLM components
container.MustRegisterSingleton(llm.NewManager)
container.MustRegisterSingleton(llm.NewModelFactory)
container.MustRegisterSingleton(llm.NewSessionConfigBuilder)
container.MustRegisterSingleton(func() *llm.CopilotClientManager {
return llm.NewCopilotClientManager(nil)
})
container.MustRegisterScoped(agent.NewCopilotAgentFactory)
container.MustRegisterScoped(agent.NewAgentFactory)
container.MustRegisterScoped(consent.NewConsentManager)
container.MustRegisterNamedSingleton("ollama", llm.NewOllamaModelProvider)
container.MustRegisterNamedSingleton("azure", llm.NewAzureOpenAiModelProvider)
container.MustRegisterNamedSingleton("copilot", llm.NewCopilotProvider)
registerGitHubCopilotProvider(container)

// Agent security manager
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func promptInitType(
console.Message(ctx, "\nThe azd agent feature has been enabled to support this new experience."+
" To turn off in the future run `azd config unset alpha.llm`.")

err = azdConfig.Set("ai.agent.model.type", "github-copilot")
err = azdConfig.Set("ai.agent.model.type", "copilot")
if err != nil {
return initUnknown, fmt.Errorf("failed to set ai.agent.model.type config: %w", err)
}
Expand Down
2 changes: 2 additions & 0 deletions cli/azd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/github/copilot-sdk/go v0.1.26-preview.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/goph/emperror v0.17.2 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
Expand Down
7 changes: 7 additions & 0 deletions cli/azd/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/getzep/zep-go v1.0.4 h1:09o26bPP2RAPKFjWuVWwUWLbtFDF/S8bfbilxzeZAAg=
github.com/getzep/zep-go v1.0.4/go.mod h1:HC1Gz7oiyrzOTvzeKC4dQKUiUy87zpIJl0ZFXXdHuss=
github.com/github/copilot-sdk/go v0.1.25 h1:SJ/jSoesbpjDEBcvMkoCG+xITvgvnhxnd6oJdmNQnOs=
github.com/github/copilot-sdk/go v0.1.25/go.mod h1:qc2iEF7hdO8kzSvbyGvrcGhuk2fzdW4xTtT0+1EH2ts=
github.com/github/copilot-sdk/go v0.1.26-preview.0 h1:UErdFjDBUXGinDmc+J8KoVlmdXJkdqcx6D6pu3Na2GE=
github.com/github/copilot-sdk/go v0.1.26-preview.0/go.mod h1:qc2iEF7hdO8kzSvbyGvrcGhuk2fzdW4xTtT0+1EH2ts=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down Expand Up @@ -223,6 +227,8 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down Expand Up @@ -264,6 +270,7 @@ github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRt
github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+/6zw=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down
38 changes: 29 additions & 9 deletions cli/azd/internal/agent/agent_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (

// AgentFactory is responsible for creating agent instances
type AgentFactory struct {
consentManager consent.ConsentManager
llmManager *llm.Manager
console input.Console
securityManager *security.Manager
consentManager consent.ConsentManager
llmManager *llm.Manager
console input.Console
securityManager *security.Manager
copilotAgentFactory *CopilotAgentFactory
}

// NewAgentFactory creates a new instance of AgentFactory
Expand All @@ -34,17 +35,36 @@ func NewAgentFactory(
console input.Console,
llmManager *llm.Manager,
securityManager *security.Manager,
copilotAgentFactory *CopilotAgentFactory,
) *AgentFactory {
return &AgentFactory{
consentManager: consentManager,
llmManager: llmManager,
console: console,
securityManager: securityManager,
consentManager: consentManager,
llmManager: llmManager,
console: console,
securityManager: securityManager,
copilotAgentFactory: copilotAgentFactory,
}
}

// CreateAgent creates a new agent instance
func (f *AgentFactory) Create(ctx context.Context, opts ...AgentCreateOption) (Agent, error) {
// Check if the configured model type is 'copilot' — if so, delegate to CopilotAgentFactory
defaultModelContainer, err := f.llmManager.GetDefaultModel(ctx)
if err == nil && defaultModelContainer.Type == llm.LlmTypeCopilot {
log.Println("[agent-factory] Model type is 'copilot', delegating to CopilotAgentFactory")
copilotOpts := []CopilotAgentOption{}
for _, opt := range opts {
base := &agentBase{}
opt(base)
if base.debug {
copilotOpts = append(copilotOpts, WithCopilotDebug(true))
}
}
return f.copilotAgentFactory.Create(ctx, copilotOpts...)
}

log.Printf("[agent-factory] Using langchaingo agent (model type: %s)", defaultModelContainer.Type)

cleanupTasks := map[string]func() error{}

cleanup := func() error {
Expand Down Expand Up @@ -77,7 +97,7 @@ func (f *AgentFactory) Create(ctx context.Context, opts ...AgentCreateOption) (A
}

// Default model gets the chained handler to expose the UX experience for the agent
defaultModelContainer, err := f.llmManager.GetDefaultModel(ctx, llm.WithLogger(chainedHandler))
defaultModelContainer, err = f.llmManager.GetDefaultModel(ctx, llm.WithLogger(chainedHandler))
if err != nil {
defer cleanup()
return nil, err
Expand Down
Loading