Skip to content

[Agents extension] Toolbox support#7640

Draft
trangevi wants to merge 15 commits intomainfrom
trangevi/toolbox
Draft

[Agents extension] Toolbox support#7640
trangevi wants to merge 15 commits intomainfrom
trangevi/toolbox

Conversation

@trangevi
Copy link
Copy Markdown
Member

Adding the ability to create a toolbox as a part of agent creation.

trangevi and others added 10 commits March 24, 2026 15:59
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
- Remove ToolboxToolDefinition struct (replaced by []any tools)
- Remove deriveConnectionName (orphaned after init refactor)
- Migrate ToolKind constants to snake_case, remove converter functions
- Remove 7 dead functions from service_target_agent.go (deployToolboxes,
  enrichToolboxFromConnections, resolveToolboxEnvironmentVariables,
  resolveMapValues, resolveAnyValue, upsertToolset,
  registerToolboxEnvironmentVariables) and their tests
- Fix provision path: correct FOUNDRY_TOOLBOX_* env var prefix, add
  env var resolution and connection enrichment, update-on-conflict
  for upsertToolset (409 -> update instead of skip)
- Extract marshalAndSetEnvVar shared helper to reduce duplication
- Consolidate toolboxMCPEndpointEnvKey (remove duplicate from init.go)
- Fix GetValues API call to use correct GetEnvironmentRequest type

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “toolbox” (Foundry Toolsets) support to the azure.ai.agents extension so toolboxes and their backing connections can be defined in manifests / project config and provisioned automatically as part of agent creation.

Changes:

  • Extends agent/project configuration & schema to support toolboxes, toolConnections, and project connections.
  • Implements post-provision toolbox provisioning (Toolsets API) and env-var wiring for connections/toolboxes.
  • Enhances agent manifest parsing (new resource kinds, new tool kinds) and manifest parameter handling (including secret: true).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
cli/azd/pkg/azapi/azure_resource_types.go Adds a resource-type constant/display name for Foundry project connections.
cli/azd/extensions/azure.ai.agents/schemas/azure.ai.agent.json Extends JSON schema with toolboxes/toolConnections/connections definitions.
cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent.go Auto-injects toolbox MCP endpoint env vars during hosted agent deploy.
cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent_test.go Adds tests for toolbox/service env-var key normalization.
cli/azd/extensions/azure.ai.agents/internal/project/config.go Adds strongly-typed config models for toolboxes and connections.
cli/azd/extensions/azure.ai.agents/internal/project/config_test.go Adds round-trip tests for toolbox/toolConnection config serialization.
cli/azd/extensions/azure.ai.agents/internal/pkg/azure/foundry_toolsets_client.go Introduces a Toolsets/Toolboxes API client for create/get/delete.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/registry_api/helpers.go Adds masked prompting support for secret: true manifest parameters.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml.go Adds new resource/tool kinds and supports record-format parameter schemas.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml_test.go Adds JSON round-trip tests for new YAML model types.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse.go Parses toolbox/connection resources and new tool kinds.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse_test.go Adds parsing tests for toolbox/connection resources and parameters layouts.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/map.go Updates default protocol version mapping for hosted agents.
cli/azd/extensions/azure.ai.agents/internal/exterrors/codes.go Adds toolbox/connection error codes and operation identifiers.
cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go Adds postprovision toolbox provisioning + connection env-var serialization helpers.
cli/azd/extensions/azure.ai.agents/internal/cmd/listen_test.go Adds unit tests for credential normalization and connection-id resolution helpers.
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Moves parameter processing earlier; extracts toolboxes/connections into azure.yaml config; injects toolbox env vars.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go Adds tests for toolbox/connection extraction and env-var injection behaviors.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go Updates offered/default protocol versions.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code_test.go Updates tests to match protocol version changes.

Comment on lines +356 to +357
// Use masked input for secret parameters
value, err = promptForSecretValue(property.Name, isRequired)
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

promptForSecretValue is invoked for secret: true parameters even when noPrompt is enabled. In non-interactive/CI scenarios this will block or fail (and term.ReadPassword also fails if stdin isn’t a TTY). Please make secret prompting respect noPrompt (e.g., use default if present, or return a clear error instructing how to provide the value), and consider checking term.IsTerminal before attempting masked input.

Suggested change
// Use masked input for secret parameters
value, err = promptForSecretValue(property.Name, isRequired)
// Use masked input for secret parameters only when prompting is allowed and stdin is a terminal
if noPrompt {
if defaultValue != nil {
value = defaultValue
} else {
err = fmt.Errorf("secret parameter %s requires a value; provide it explicitly or define a default when running with prompts disabled", property.Name)
}
} else if !term.IsTerminal(int(os.Stdin.Fd())) {
if defaultValue != nil {
value = defaultValue
} else {
err = fmt.Errorf("secret parameter %s requires interactive input, but stdin is not a terminal; provide it explicitly or define a default", property.Name)
}
} else {
value, err = promptForSecretValue(property.Name, isRequired)
}

Copilot uses AI. Check for mistakes.
trangevi and others added 4 commits April 10, 2026 11:00
Signed-off-by: trangevi <trangevi@microsoft.com>
* Add unit tests and testdata for azure.ai.agents extension

Add 86 new unit tests across 5 previously untested or undertested packages
in the azure.ai.agents extension, raising total test count from 183 to 269.

Coverage improvements:
- agent_yaml: 23.1% -> 53.8% (map.go YAML-to-API mapping fully tested)
- registry_api: 0% -> 28.8% (tool conversion, parameter conversion, merge)
- agent_api: 0% -> tested (JSON round-trip for all model types)
- cmd: 23.0% -> 23.6% (copyDirectory, copyFile, buildAgentEndpoint)

New test files:
- agent_yaml/map_test.go: 44 tests for YAML-to-API transform functions
- registry_api/helpers_test.go: 35 tests for pure conversion helpers
- agent_api/models_test.go: 24 JSON serialization round-trip tests
- cmd/init_copy_test.go: directory/file copy logic tests
- cmd/agent_context_test.go: endpoint construction test
- agent_yaml/testdata_test.go: fixture-based parsing + regression tests

New testdata fixtures (7 YAML files):
- 3 valid agents (minimal prompt, full prompt, hosted)
- 1 MCP tools agent
- 3 invalid manifests (no kind, no model, empty template)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* refactor: replace ptr[T] helper with Go 1.26 new(val) in tests

Replace the generic ptr[T](v T) *T helper function with Go 1.26's
built-in new(val) pattern in models_test.go and helpers_test.go,
consistent with map_test.go and AGENTS.md conventions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* remove outdated comment

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: trangevi <trangevi@microsoft.com>

const (
toolboxesApiVersion = "v1"
toolboxesFeatureHeader = "Toolsets=V1Preview"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Change to Toolboxes=V1Preview

Signed-off-by: trangevi <trangevi@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create hosted agent toolsets

3 participants