Skip to content

[Agents Extension] Add support for logs and status commands - #6895

Merged
trangevi merged 8 commits into
mainfrom
trangevi/logs-commands
Feb 26, 2026
Merged

[Agents Extension] Add support for logs and status commands#6895
trangevi merged 8 commits into
mainfrom
trangevi/logs-commands

Conversation

@trangevi

@trangevi trangevi commented Feb 25, 2026

Copy link
Copy Markdown
Member
> azd ai agent status --name basic-sample --version 1
{
  "object": "agent.container",
  "id": "basic-sample-1",
  "status": "Failed",
  "max_replicas": 1,
  "min_replicas": 1,
  "error_message": "[ContainerProbesFailed] User Error: Container readiness probes failed. State: ActivationFailed (provisioning: Provisioned, health: Unhealthy), Container error (state: Waiting): Container is crashing immediately after startup. For troubleshooting, see https://aka.ms/troubleshoot-hosted-agents .",
  "created_at": "2026-02-24T00:36:20.2033920Z",
  "updated_at": "2026-02-24T00:46:32.4319836Z",
  "container": {
    "health_state": "Unhealthy",
    "provisioning_state": "Succeeded",
    "state": "ActivationFailed",
    "updated_on": "2026-02-25T20:45:52+00:00",
    "replicas": [
      {
        "name": "c788a9d3767b4086b938668f70314f51--d5dn6gc-5c8476c7b-kpjtc",
        "state": "NotRunning",
        "container_state": "Waiting"
      }
    ]
  }
}
> azd ai agent logs --name basic-sample --account-name ai-account-g3dr7aadbaujq --project-name ai-project-basic-sample-dev --version 1 -f
2026-02-25T17:05:03.68369  Connecting to the container 'agent-container'...
2026-02-25T17:05:03.85254  Successfully Connected to container: 'agent-container' [Revision: 'c788a9d3767b4086b938668f70314f51--d5dn6gc', Replica: 'c788a9d3767b4086b938668f70314f51--d5dn6gc-5c8476c7b-kpjtc']
2026-02-25T17:03:07.8151294Z stderr F Traceback (most recent call last):
2026-02-25T17:03:07.8151724Z stderr F   File "/app/user_agent/agent.py", line 6, in <module>
2026-02-25T17:03:07.8152837Z stderr F     from agent_framework import WorkflowBuilder
2026-02-25T17:03:07.8152936Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/__init__.py", line 12, in <module>
2026-02-25T17:03:07.8152983Z stderr F     from ._agents import *  # noqa: F403
2026-02-25T17:03:07.8153007Z stderr F     ^^^^^^^^^^^^^^^^^^^^^^
2026-02-25T17:03:07.8153028Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/_agents.py", line 18, in <module>
2026-02-25T17:03:07.8153104Z stderr F     from ._clients import BaseChatClient, ChatClientProtocol
2026-02-25T17:03:07.8153127Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/_clients.py", line 11, in <module>
2026-02-25T17:03:07.8153502Z stderr F     from ._memory import AggregateContextProvider, ContextProvider
2026-02-25T17:03:07.8153555Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/_memory.py", line 11, in <module>
2026-02-25T17:03:07.8154129Z stderr F     from ._types import ChatMessage
2026-02-25T17:03:07.8154181Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/_types.py", line 22, in <module>
2026-02-25T17:03:07.8155036Z stderr F     from ._tools import ToolProtocol, ai_function
2026-02-25T17:03:07.8155102Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/_tools.py", line 32, in <module>
2026-02-25T17:03:07.8156145Z stderr F     from .observability import (
2026-02-25T17:03:07.8156403Z stderr F   File "/usr/local/lib/python3.11/site-packages/agent_framework/observability.py", line 1780, in <module>
2026-02-25T17:03:07.8171032Z stderr F     SpanAttributes.LLM_REQUEST_MODEL,
2026-02-25T17:03:07.8171157Z stderr F     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-02-25T17:03:07.8172141Z stderr F AttributeError: type object 'SpanAttributes' has no attribute 'LLM_REQUEST_MODEL'. Did you mean: 'LLM_REQUEST_TYPE'?

Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>

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 adds two new commands to the Azure AI Agents extension: logs and status. These commands enable users to retrieve logs and status information from hosted agent containers.

Changes:

  • Adds GetAgentContainerLogStream API operation to stream logs from agent containers with support for different log types (console/system) and configurable tail length
  • Introduces new model structs (AgentContainerReplicaState, AgentContainerDetails) and enhances AgentContainerObject to support detailed container runtime information
  • Implements shared AgentContext helper for common agent command patterns including endpoint resolution and client creation
  • Adds status command with JSON and table output formats to display agent container status, replica configuration, and error messages
  • Adds logs command to fetch console or system logs from agent containers
  • Includes comprehensive test coverage for both commands

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
operations.go Adds GetAgentContainerLogStream method to fetch logs via streaming API endpoint
models.go Adds AgentContainerReplicaState and AgentContainerDetails structs; extends AgentContainerObject with ID and Container fields
agent_context.go New shared context helper encapsulating endpoint resolution, credential creation, and client factory for agent commands
status.go Implements status command with JSON/table output formats to display container status and runtime details
status_test.go Comprehensive unit tests for status command, including flag validation, output formatting, and endpoint resolution
get_logs.go Implements logs command with validation for tail (1-300) and type (console/system) parameters
get_logs_test.go Unit tests for logs command covering flag validation, boundary conditions, and default values
root.go Registers new status and logs commands with the root command

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/monitor.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/get_logs.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/monitor.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations.go Outdated
@rajeshkamal5050

rajeshkamal5050 commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

@tg-msft @therealjohn @wbreza @kristenwomack @JeffreyCA

Remember we discussed about using already existing core command naming conventions for status and logs as show and monitor respectively.

  • azd ai agent show
  • azd ai agent monitor

This will enable us to eventually have overriding behaviors like we did for azd deploy. So we can land at azd show, azd monitor etc

Signed-off-by: trangevi <trangevi@microsoft.com>

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

pretty cool - I will take this as inspiration to add stream to the appservice extension

trangevi and others added 4 commits February 26, 2026 08:51
Signed-off-by: trangevi <trangevi@microsoft.com>
…pi/operations.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
@trangevi
trangevi enabled auto-merge (squash) February 26, 2026 19:56
@trangevi
trangevi merged commit 02175b7 into main Feb 26, 2026
19 checks passed
@trangevi
trangevi deleted the trangevi/logs-commands branch February 26, 2026 21:33
@trangevi trangevi linked an issue Mar 3, 2026 that may be closed by this pull request
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.

[ai agent extension] Add ability to get hosted agent logs and status

4 participants