Skip to content

Add --call-id flag to send x-agent-foundry-call-id header on local invokes#8780

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/remove-isolationkeysource
Open

Add --call-id flag to send x-agent-foundry-call-id header on local invokes#8780
Copilot wants to merge 6 commits into
mainfrom
copilot/remove-isolationkeysource

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

azd ai agent invoke had no way to pass a call ID to a locally running agent. This adds a --call-id flag that sends the value as the x-agent-foundry-call-id header for local invocations only; it is never sent on remote Foundry requests.

Changes

  • Header constant — Add AgentFoundryCallIDHeader = "x-agent-foundry-call-id" in agent_api/operations.go.
  • Flag — Add --call-id to invoke, threaded through invokeFlags.
  • Application — New applyLocalCallIDHeader helper sets the header on both local paths (responsesLocal, invocationsLocal). Remote paths are untouched, so the header stays local-only.
  • Help text + CHANGELOG — Document the flag's local-only scope.
  • Tests — Verify the header is present (per protocol) when --call-id is set and absent when omitted.
# Sent as x-agent-foundry-call-id to the local agent
azd ai agent invoke --local --call-id call-123 "Hello!"

# Ignored on remote
azd ai agent invoke --call-id call-123 "Hello!"

Closes #8796

Copilot AI and others added 2 commits June 22, 2026 17:13
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
…vokes

Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
@ankitbko

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

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

This PR updates the azure.ai.agents azd extension invocation flows by adding a local-only call ID header for azd ai agent invoke, while also refactoring the extension’s “isolation” header/flag story to a single --user-identity flag used across commands.

Changes:

  • Add --call-id to azd ai agent invoke and send it as x-agent-foundry-call-id on --local invokes (both responses + invocations protocols).
  • Replace the prior isolation-key flags (--user-isolation-key, --chat-isolation-key, and --isolation-key) with a single --user-identity flag, mapping to x-agent-user-id (local) and x-ms-user-identity (remote).
  • Update tests, help text, changelog, and Fig completion snapshots to reflect the new flags/headers.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations.go Replaces isolation header constants/options with user-identity headers and adds the call-id header constant.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations_test.go Updates request-option/header assertions to the new user-identity header model.
cli/azd/extensions/azure.ai.agents/internal/cmd/user_identity.go Introduces shared --user-identity flag plumbing and helpers for local/remote header application; adds local call-id helper.
cli/azd/extensions/azure.ai.agents/internal/cmd/invoke.go Adds --call-id and applies local headers only on local invoke paths; switches remote header application to user identity.
cli/azd/extensions/azure.ai.agents/internal/cmd/invoke_test.go Updates tests to the new user-identity option model and propagation checks.
cli/azd/extensions/azure.ai.agents/internal/cmd/invoke_call_id_test.go Adds coverage to verify x-agent-foundry-call-id behavior for local invokes.
cli/azd/extensions/azure.ai.agents/internal/cmd/session.go Removes old isolation/session-ownership flags and migrates session commands to --user-identity.
cli/azd/extensions/azure.ai.agents/internal/cmd/session_test.go Updates session command flag tests to reflect the new --user-identity flag surface.
cli/azd/extensions/azure.ai.agents/internal/cmd/files.go Migrates file commands from isolation flags to --user-identity.
cli/azd/extensions/azure.ai.agents/internal/cmd/files_test.go Updates file command flag tests for --user-identity.
cli/azd/extensions/azure.ai.agents/internal/cmd/monitor.go Migrates monitor command from isolation flags to --user-identity.
cli/azd/extensions/azure.ai.agents/internal/cmd/monitor_test.go Updates monitor command flag tests for --user-identity.
cli/azd/extensions/azure.ai.agents/internal/cmd/isolation_headers.go Removes the old isolation flags implementation.
cli/azd/extensions/azure.ai.agents/internal/cmd/update.go Updates warning text to reference x-ms-user-identity.
cli/azd/extensions/azure.ai.agents/CHANGELOG.md Documents the new --call-id flag and the breaking --user-identity flag consolidation.
cli/azd/cmd/testdata/TestFigSpec.ts Updates completions snapshot to remove old isolation flags and add --user-identity (but needs --call-id added as well).
Comments suppressed due to low confidence (1)

cli/azd/cmd/testdata/TestFigSpec.ts:1046

  • [azd-code-reviewer] The Fig completion snapshot for azd ai agent invoke doesn’t include the new --call-id flag, so TestFigSpec (and related snapshot-based checks) will likely fail and users won’t see the new option in completions.
								{
									name: ['--timeout', '-t'],
									description: 'Request timeout in seconds (0 for no timeout)',
									args: [
										{
											name: 'timeout',
										},
									],
								},
								{
									name: ['--user-identity'],
									description: 'User identity header value (sent as x-agent-user-id for local invocations and x-ms-user-identity for remote requests)',
									args: [
										{
											name: 'user-identity',
										},
									],
								},
								{

## Unreleased

- Add a `--call-id` flag to `azd ai agent invoke` that sends the `x-agent-foundry-call-id` header on `--local` invocations only. It is ignored for remote Foundry requests.
- Replace the per-command Foundry isolation-key flags (`--user-isolation-key`, `--chat-isolation-key`, and the session-ownership `--isolation-key`) with a single `--user-identity` flag. The value is sent as the `x-agent-user-id` header for `--local` invocations and as `x-ms-user-identity` for all remote Foundry requests. This is a breaking change with no backward-compatible flag retention.
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved. I merged latest origin/main, fixed the conflict in cli/azd/extensions/azure.ai.agents/internal/cmd/invoke_test.go, and pushed commit 4f987a5.

Copilot AI requested a review from ankitbko June 24, 2026 06:35

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The isolation-key simplification and new --call-id flag both look correct. Local vs. remote header routing is clean, and the SessionRequestOptions consolidation removes real complexity.

One thing to address: the --call-id flag is registered on the invoke command but doesn't appear in the FigSpec snapshot (cli/azd/cmd/testdata/TestFigSpec.ts). The snapshot has the isolation-key removals and user-identity renames, but no call-id addition. Run UPDATE_SNAPSHOTS=true go test ./cmd -run 'TestFigSpec|TestUsage' to regenerate.

return fmt.Errorf("failed to create request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
applyLocalUserIdentityHeader(req, &a.flags.userIdentityFlags)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[LOW] applyLocalUserIdentityHeader is new here (local paths didn't set user-identity headers before this PR). The --call-id behavior has a dedicated test (invoke_call_id_test.go), but no test verifies that x-agent-user-id is sent on local requests when --user-identity is set. Consider extending the call-id test to also assert the user-identity header, or adding a sibling test file for it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot work on it

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.

Addressed in 9e497b5: extended local invoke tests to assert x-agent-user-id is sent when --user-identity is set (for both local protocols), and added a request-sent assertion so cases can’t pass before sending a request.

@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

@therealjohn therealjohn 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.

@trangevi note the breaking changes here.

user-isolation-key -> user-identity
chat-isolation-key -> removed
call-id -> added

Isolation Key concept has changed now in Foundry.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI and others added 2 commits June 24, 2026 12:54
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --call-id flag to azd ai agent invoke for local invocations

6 participants