Session management commands and file command improvements#7574
Session management commands and file command improvements#7574therealjohn wants to merge 16 commits intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds new CLI surface and API client support for hosted agent session lifecycle management, while refining file command ergonomics and harmonizing session flag naming.
Changes:
- Introduces
sessionsCLI commands (create/show/list/delete) and corresponding agent API operations/models. - Improves
filesUX:remove→delete(alias preserved) and adds positional path support; adjusts upload default remote path behavior. - Renames
--sessionto--session-idacross relevant commands and updates tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations_test.go | Adds API-level tests for new session operations behavior (notably DeleteSession status code handling). |
| cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations.go | Adds session lifecycle HTTP operations; updates upload/download file content endpoint path. |
| cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models.go | Adds new session lifecycle models and enums used by operations/CLI output. |
| cli/azd/extensions/azure.ai.agents/internal/exterrors/codes.go | Adds new error codes and operation names for session flows. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/session_test.go | Adds command structure, formatting, and error classification tests for sessions. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/session.go | Implements sessions cobra commands and formatting helpers. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/root.go | Registers the new sessions command on the root command. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/monitor_test.go | Updates tests for renamed --session-id flag. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/monitor.go | Renames monitor flag from --session to --session-id. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/files_test.go | Updates tests for delete subcommand and renamed --session-id flag. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/files.go | Implements delete (alias remove), positional args for file commands, and updates session flag naming. |
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations.go
Show resolved
Hide resolved
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations.go
Show resolved
Hide resolved
…nsuring consistency with --session-id usage
jongio
left a comment
There was a problem hiding this comment.
CI is red - golangci-lint fails on operations_test.go. Plus a stale flag reference in help text.
Issues to address:
- operations_test.go:20 - unused
bodyfield onfakeTransport+ gofmt misalignment on line 27 (both fail CI) - files.go:79 - parent
filescommand help still says--sessioninstead of--session-id - operations_test.go:88 -
context.Background()should bet.Context()(rest of file uses it)
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations_test.go
Show resolved
Hide resolved
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations_test.go
Show resolved
Hide resolved
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations_test.go
Show resolved
Hide resolved
jongio
left a comment
There was a problem hiding this comment.
The session CRUD implementation is clean and follows existing patterns well. All previous feedback items have been addressed and CI is green. Two minor notes below - neither is blocking.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations_test.go
Show resolved
Hide resolved
jongio
left a comment
There was a problem hiding this comment.
Issues to address:
- session.go:421 -
sessions deletedoesn't handle 404 likesessions showdoes
Co-authored-by: Jon Gallant <2163001+jongio@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Two items - one CI-blocking, one coverage gap.
…04 and 500 responses
jongio
left a comment
There was a problem hiding this comment.
Session CRUD implementation follows the files command patterns well and tests are thorough.
A few non-blocking notes:
-
printSessionTablewill show blankVersion: (type: )if the server returns emptyVersionIndicatorfields. Could check for empty strings and show "-" to match howformatUnixTimestamphandles zero values. -
persistSessionIDsilently drops all errors. Fine as best-effort, but a debug log would help diagnose cases where session auto-detection doesn't work on subsequent commands. -
The copilot bot's comments about
errors.AsTypenot compiling are wrong - it's valid Go 1.26 per this repo's AGENTS.md.
wbreza
left a comment
There was a problem hiding this comment.
Code Review — PR #7574
Session management commands and file command improvements by @therealjohn
Summary
Well-structured session CRUD implementation following established extension patterns. Clean error handling with proper LocalError/ServiceError classification, correct 200/204 handling for delete, and complete --session → --session-id rename. One minor naming inconsistency below — no blocking issues.
🟡 Medium (1 finding)
filesFlags.sessionfield name doesn't match--session-idflag — The struct field issession stringbut the flag is--session-id. Sessions commands use matching field names. Minor inconsistency — no functional impact.
✅ What Looks Good
- Session CRUD with proper error codes (
CodeSessionNotFound,CodeSessionCreateFailed, etc.) - 404 → friendly
LocalErrorwith suggestion, 500 →ServiceError— correct extension pattern - Delete handles both 200 OK and 204 No Content correctly
--session→--session-idrename complete across all commands- Positional args with backward-compatible flag fallback for file commands
errors.AsTypeused correctly for error classification- Comprehensive test coverage: API-level (200/204/500), error classification, command structure
- Prior review items all resolved
| Priority | Count |
|---|---|
| Medium | 1 |
| Total | 1 |
Overall Assessment: Comment — clean implementation, no blocking issues.
Review performed with GitHub Copilot CLI
| } | ||
|
|
||
| func newSessionCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ |
Adds azd ai agent sessions CRUD commands for managing hosted agent sessions, improves error handling, and enhances file command UX.
Session management (sessions)
File command improvements
azd ai agent files upload --file ./input.csv # flag (still works)
Flag consistency
Bug fixes
Tests
Fixes #7429 Fixes #7519