Add --call-id flag to send x-agent-foundry-call-id header on local invokes#8780
Add --call-id flag to send x-agent-foundry-call-id header on local invokes#8780Copilot wants to merge 6 commits into
Conversation
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
…vokes Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
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-idtoazd ai agent invokeand send it asx-agent-foundry-call-idon--localinvokes (both responses + invocations protocols). - Replace the prior isolation-key flags (
--user-isolation-key,--chat-isolation-key, and--isolation-key) with a single--user-identityflag, mapping tox-agent-user-id(local) andx-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 invokedoesn’t include the new--call-idflag, soTestFigSpec(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>
Resolved. I merged latest |
jongio
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
therealjohn
left a comment
There was a problem hiding this comment.
@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>
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
azd ai agent invokehad no way to pass a call ID to a locally running agent. This adds a--call-idflag that sends the value as thex-agent-foundry-call-idheader for local invocations only; it is never sent on remote Foundry requests.Changes
AgentFoundryCallIDHeader = "x-agent-foundry-call-id"inagent_api/operations.go.--call-idtoinvoke, threaded throughinvokeFlags.applyLocalCallIDHeaderhelper sets the header on both local paths (responsesLocal,invocationsLocal). Remote paths are untouched, so the header stays local-only.--call-idis set and absent when omitted.Closes #8796