Skip to content

Commit 02c9713

Browse files
authored
[Agents Extension] Remove prompt agent handling (#8040)
* Initial changes to remove prompt agents Signed-off-by: trangevi <trangevi@microsoft.com> * cleanup Signed-off-by: trangevi <trangevi@microsoft.com> * PR comments Signed-off-by: trangevi <trangevi@microsoft.com> * PR comments Signed-off-by: trangevi <trangevi@microsoft.com> --------- Signed-off-by: trangevi <trangevi@microsoft.com>
1 parent 6293e57 commit 02c9713

24 files changed

Lines changed: 386 additions & 3366 deletions

cli/azd/extensions/azure.ai.agents/internal/cmd/init.go

Lines changed: 3 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"azureaiagent/internal/exterrors"
2525
"azureaiagent/internal/pkg/agents/agent_yaml"
26-
"azureaiagent/internal/pkg/agents/registry_api"
2726
"azureaiagent/internal/project"
2827

2928
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
@@ -594,7 +593,7 @@ func (a *InitAction) Run(ctx context.Context) error {
594593
}
595594

596595
// Prompt for manifest parameters (e.g. tool credentials) after project selection
597-
agentManifest, err = registry_api.ProcessManifestParameters(
596+
agentManifest, err = agent_yaml.ProcessManifestParameters(
598597
ctx, agentManifest, a.azdClient, a.flags.NoPrompt,
599598
)
600599
if err != nil {
@@ -721,13 +720,8 @@ func getExistingEnvironment(ctx context.Context, envName string, azdClient *azde
721720
}
722721

723722
// manifestHasModelResources returns true if the manifest contains any model resources
724-
// that need deployment configuration. Prompt agents always have a model. Hosted agents
725-
// only need model config if they have resources with kind "model".
723+
// that need deployment configuration (i.e. resources with kind "model").
726724
func manifestHasModelResources(manifest *agent_yaml.AgentManifest) bool {
727-
if _, ok := manifest.Template.(agent_yaml.PromptAgent); ok {
728-
return true
729-
}
730-
731725
if manifest.Resources != nil {
732726
for _, resource := range manifest.Resources {
733727
if _, ok := resource.(agent_yaml.ModelResource); ok {
@@ -1152,67 +1146,6 @@ func (a *InitAction) isGitHubUrl(manifestPointer string) bool {
11521146
strings.Contains(hostname, "github")
11531147
}
11541148

1155-
type RegistryManifest struct {
1156-
registryName string
1157-
manifestName string
1158-
manifestVersion string // Defaults to "" if not specified in URL
1159-
}
1160-
1161-
func (a *InitAction) isRegistryUrl(manifestPointer string) (bool, *RegistryManifest) {
1162-
// Check if it matches the format "azureml://registries/{registryName}/agentmanifests/{manifestName}[/versions/{manifestVersion}]"
1163-
if !strings.HasPrefix(manifestPointer, "azureml://") {
1164-
return false, nil
1165-
}
1166-
1167-
// Remove the "azureml://" prefix
1168-
path := strings.TrimPrefix(manifestPointer, "azureml://")
1169-
1170-
// Split by "/" to get all path components
1171-
parts := strings.Split(path, "/")
1172-
1173-
// Should have either 4 parts (without version) or 6 parts (with version)
1174-
// Format 1: "registries", registryName, "agentmanifests", manifestName
1175-
// Format 2: "registries", registryName, "agentmanifests", manifestName, "versions", manifestVersion
1176-
if len(parts) != 4 && len(parts) != 6 {
1177-
return false, nil
1178-
}
1179-
1180-
// Validate the expected path structure for the first 4 parts
1181-
if parts[0] != "registries" || parts[2] != "agentmanifests" {
1182-
return false, nil
1183-
}
1184-
1185-
// All basic parts should be non-empty
1186-
registryName := strings.TrimSpace(parts[1])
1187-
manifestName := strings.TrimSpace(parts[3])
1188-
1189-
if registryName == "" || manifestName == "" {
1190-
return false, nil
1191-
}
1192-
1193-
var manifestVersion string
1194-
1195-
// If we have 6 parts, validate the version structure
1196-
if len(parts) == 6 {
1197-
if parts[4] != "versions" {
1198-
return false, nil
1199-
}
1200-
manifestVersion = strings.TrimSpace(parts[5])
1201-
if manifestVersion == "" {
1202-
return false, nil
1203-
}
1204-
} else {
1205-
// If no version specified, default to ""
1206-
manifestVersion = ""
1207-
}
1208-
1209-
return true, &RegistryManifest{
1210-
registryName: registryName,
1211-
manifestName: manifestName,
1212-
manifestVersion: manifestVersion,
1213-
}
1214-
}
1215-
12161149
func (a *InitAction) downloadAgentYaml(
12171150
ctx context.Context, manifestPointer string, targetDir string) (*agent_yaml.AgentManifest, string, error) {
12181151
if manifestPointer == "" {
@@ -1394,62 +1327,11 @@ func (a *InitAction) downloadAgentYaml(
13941327
}
13951328

13961329
content = []byte(contentStr)
1397-
} else if isRegistry, registryManifest := a.isRegistryUrl(manifestPointer); isRegistry {
1398-
// Handle registry URLs
1399-
manifestClient := registry_api.NewRegistryAgentManifestClient(registryManifest.registryName, a.credential)
1400-
1401-
var versionResult *registry_api.Manifest
1402-
if registryManifest.manifestVersion == "" {
1403-
// No version specified, get latest version from GetAllLatest
1404-
log.Printf("No version provided for manifest '%s', retrieving latest version", registryManifest.manifestName)
1405-
1406-
allManifests, err := manifestClient.GetAllLatest(ctx)
1407-
if err != nil {
1408-
return nil, "", fmt.Errorf("getting latest manifests: %w", err)
1409-
}
1410-
1411-
// Find the manifest with matching name
1412-
for _, manifest := range allManifests {
1413-
if manifest.Name == registryManifest.manifestName {
1414-
versionResult = &manifest
1415-
break
1416-
}
1417-
}
1418-
1419-
if versionResult == nil {
1420-
return nil, "", fmt.Errorf("manifest '%s' not found in registry '%s'", registryManifest.manifestName, registryManifest.registryName)
1421-
}
1422-
} else {
1423-
// Specific version requested
1424-
fmt.Println(output.WithGrayFormat("Downloading manifest from registry..."))
1425-
log.Printf("Downloading manifest from registry: %s", manifestPointer)
1426-
1427-
manifest, err := manifestClient.GetManifest(ctx, registryManifest.manifestName, registryManifest.manifestVersion)
1428-
if err != nil {
1429-
return nil, "", fmt.Errorf("getting materialized manifest: %w", err)
1430-
}
1431-
versionResult = manifest
1432-
}
1433-
1434-
// Process the manifest into a maml format
1435-
processedManifest, err := registry_api.ProcessRegistryManifest(ctx, versionResult, a.azdClient)
1436-
if err != nil {
1437-
return nil, "", fmt.Errorf("processing manifest with parameters: %w", err)
1438-
}
1439-
1440-
log.Print("Retrieved and processed manifest from registry")
1441-
1442-
// Convert to YAML bytes for the content variable
1443-
manifestBytes, err := yaml.Marshal(processedManifest)
1444-
if err != nil {
1445-
return nil, "", fmt.Errorf("marshaling agent manifest to YAML: %w", err)
1446-
}
1447-
content = manifestBytes
14481330
} else {
14491331
// If we reach here, the manifest pointer didn't match any known type
14501332
return nil, "", exterrors.Validation(
14511333
exterrors.CodeInvalidManifestPointer,
1452-
fmt.Sprintf("manifest pointer '%s' is not a valid local file path, GitHub URL, or registry URL", manifestPointer),
1334+
fmt.Sprintf("manifest pointer '%s' is not a valid local file path or GitHub URL", manifestPointer),
14531335
"provide a valid URL or an existing local agent.yaml/agent.yml path",
14541336
)
14551337
}
@@ -1494,14 +1376,6 @@ func (a *InitAction) downloadAgentYaml(
14941376
}
14951377
}
14961378

1497-
_, isPromptAgent := agentManifest.Template.(agent_yaml.PromptAgent)
1498-
if isPromptAgent {
1499-
agentManifest, err = agent_yaml.ProcessPromptAgentToolsConnections(ctx, agentManifest, a.azdClient)
1500-
if err != nil {
1501-
return nil, "", fmt.Errorf("failed to process prompt agent tools connections: %w", err)
1502-
}
1503-
}
1504-
15051379
// Create target directory if it doesn't exist
15061380
//nolint:gosec // project scaffold directory should be readable and traversable
15071381
if err := os.MkdirAll(targetDir, 0755); err != nil {

cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"azureaiagent/internal/exterrors"
1313
"azureaiagent/internal/pkg/agents/agent_yaml"
14-
"azureaiagent/internal/pkg/agents/registry_api"
1514
"azureaiagent/internal/project"
1615

1716
"github.com/azure/azure-dev/cli/azd/pkg/azdext"
@@ -773,17 +772,8 @@ func (a *InitAction) ProcessModels(ctx context.Context, manifest *agent_yaml.Age
773772
}
774773

775774
deploymentDetails := []project.Deployment{}
776-
paramValues := registry_api.ParameterValues{}
775+
paramValues := agent_yaml.ParameterValues{}
777776
switch agentDef.Kind {
778-
case agent_yaml.AgentKindPrompt:
779-
agentDef := manifest.Template.(agent_yaml.PromptAgent)
780-
781-
modelDeployment, err := a.getModelDeploymentDetails(ctx, agentDef.Model)
782-
if err != nil {
783-
return nil, nil, fmt.Errorf("failed to get model deployment details: %w", err)
784-
}
785-
deploymentDetails = append(deploymentDetails, *modelDeployment)
786-
paramValues["deploymentName"] = modelDeployment.Name
787777
case agent_yaml.AgentKindHosted:
788778
for _, resource := range manifest.Resources {
789779
resourceBytes, err := yaml.Marshal(resource)
@@ -809,7 +799,7 @@ func (a *InitAction) ProcessModels(ctx context.Context, manifest *agent_yaml.Age
809799
}
810800
}
811801

812-
updatedManifest, err := registry_api.InjectParameterValuesIntoManifest(manifest, paramValues)
802+
updatedManifest, err := agent_yaml.InjectParameterValuesIntoManifest(manifest, paramValues)
813803
if err != nil {
814804
return nil, nil, fmt.Errorf("failed to inject deployment names into manifest: %w", err)
815805
}

cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -775,34 +775,6 @@ func TestInjectToolboxEnvVarsIntoDefinition_NoopForNilManifest(t *testing.T) {
775775
}
776776
}
777777

778-
func TestInjectToolboxEnvVarsIntoDefinition_NoopForPromptAgent(t *testing.T) {
779-
t.Parallel()
780-
781-
manifest := &agent_yaml.AgentManifest{
782-
Template: agent_yaml.PromptAgent{
783-
AgentDefinition: agent_yaml.AgentDefinition{
784-
Kind: agent_yaml.AgentKindPrompt,
785-
Name: "prompt-agent",
786-
},
787-
},
788-
Resources: []any{
789-
agent_yaml.ToolboxResource{
790-
Resource: agent_yaml.Resource{Name: "tools", Kind: agent_yaml.ResourceKindToolbox},
791-
Tools: []any{map[string]any{"type": "bing_grounding"}},
792-
},
793-
},
794-
}
795-
796-
if err := injectToolboxEnvVarsIntoDefinition(manifest); err != nil {
797-
t.Fatalf("unexpected error: %v", err)
798-
}
799-
800-
// Template should be unchanged (still a PromptAgent, no EnvironmentVariables field)
801-
if _, ok := manifest.Template.(agent_yaml.PromptAgent); !ok {
802-
t.Error("Expected template to remain a PromptAgent")
803-
}
804-
}
805-
806778
func TestInjectToolboxEnvVarsIntoDefinition_NoopWithoutToolboxes(t *testing.T) {
807779
t.Parallel()
808780

@@ -1066,14 +1038,6 @@ func TestManifestHasModelResources(t *testing.T) {
10661038
manifest *agent_yaml.AgentManifest
10671039
expected bool
10681040
}{
1069-
{
1070-
name: "prompt agent always has model resources",
1071-
manifest: &agent_yaml.AgentManifest{
1072-
Name: "test-prompt",
1073-
Template: agent_yaml.PromptAgent{},
1074-
},
1075-
expected: true,
1076-
},
10771041
{
10781042
name: "hosted agent with model resource",
10791043
manifest: &agent_yaml.AgentManifest{
@@ -1194,11 +1158,6 @@ func TestResolvePositionalArg(t *testing.T) {
11941158
arg: "http://example.com/agent.yaml",
11951159
isManifest: true,
11961160
},
1197-
{
1198-
name: "azureml registry URL is manifest",
1199-
arg: "azureml://registries/myReg/agentmanifests/myManifest",
1200-
isManifest: true,
1201-
},
12021161
{
12031162
name: "custom scheme URL is manifest",
12041163
arg: "custom://some/resource",

cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models.go

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ const (
2323
type AgentKind string
2424

2525
const (
26-
AgentKindPrompt AgentKind = "prompt"
27-
AgentKindHosted AgentKind = "hosted"
28-
AgentKindContainerApp AgentKind = "container_app"
29-
AgentKindWorkflow AgentKind = "workflow"
26+
AgentKindHosted AgentKind = "hosted"
27+
AgentKindWorkflow AgentKind = "workflow"
3028
)
3129

3230
// AgentEventType represents the types of events that can be handled
@@ -81,56 +79,6 @@ type ImageBasedHostedAgentDefinition struct {
8179
Image string `json:"image"`
8280
}
8381

84-
// ContainerAppAgentDefinition represents a container app agent
85-
type ContainerAppAgentDefinition struct {
86-
AgentDefinition
87-
ContainerProtocolVersions []ProtocolVersionRecord `json:"container_protocol_versions"`
88-
ContainerAppResourceID string `json:"container_app_resource_id"`
89-
IngressSubdomainSuffix string `json:"ingress_subdomain_suffix"`
90-
}
91-
92-
// ResponseTextFormatConfiguration represents text format configuration
93-
type ResponseTextFormatConfiguration struct {
94-
// Implementation depends on OpenAI package structure
95-
// This is a placeholder for the actual OpenAI response format configuration
96-
Type string `json:"type,omitempty"`
97-
}
98-
99-
// Reasoning represents OpenAI reasoning configuration
100-
type Reasoning struct {
101-
// Implementation depends on OpenAI package structure
102-
// This is a placeholder for the actual OpenAI reasoning structure
103-
Effort string `json:"effort,omitempty"`
104-
}
105-
106-
// ToolArgumentBinding represents binding configuration for tool arguments
107-
type ToolArgumentBinding struct {
108-
ToolName *string `json:"tool_name,omitempty"`
109-
ArgumentName string `json:"argument_name"`
110-
}
111-
112-
// StructuredInputDefinition represents a structured input definition
113-
type StructuredInputDefinition struct {
114-
Description *string `json:"description,omitempty"`
115-
DefaultValue any `json:"default_value,omitempty"`
116-
ToolArgumentBindings []ToolArgumentBinding `json:"tool_argument_bindings,omitempty"`
117-
Schema any `json:"schema,omitempty"`
118-
Required *bool `json:"required,omitempty"`
119-
}
120-
121-
// PromptAgentDefinition represents a prompt-based agent
122-
type PromptAgentDefinition struct {
123-
AgentDefinition
124-
Model string `json:"model"`
125-
Instructions *string `json:"instructions,omitempty"`
126-
Temperature *float32 `json:"temperature,omitempty"`
127-
TopP *float32 `json:"top_p,omitempty"`
128-
Reasoning *Reasoning `json:"reasoning,omitempty"`
129-
Tools []any `json:"tools,omitempty"` // Must be a type of Tool
130-
Text *ResponseTextFormatConfiguration `json:"text,omitempty"`
131-
StructuredInputs map[string]StructuredInputDefinition `json:"structured_inputs,omitempty"`
132-
}
133-
13482
// CreateAgentVersionRequest represents a request to create an agent version
13583
type CreateAgentVersionRequest struct {
13684
Description *string `json:"description,omitempty"`

0 commit comments

Comments
 (0)