Documentation
¶
Overview ¶
Package agentdetect provides functionality to detect when azd is invoked by known AI coding agents (Claude Code, Codex, Cursor, GitHub Copilot, Gemini, OpenCode) and enables automatic adjustment of behavior (e.g., no-prompt mode).
Index ¶
Constants ¶
const DisableAgentDetectEnvVar = "AZD_DISABLE_AGENT_DETECT"
DisableAgentDetectEnvVar is the environment variable that, when set to any non-empty value, disables all agent detection. This is used by functional tests that spawn azd as a child process and need to test interactive prompt behavior without the parent process tree (which may include an AI agent like Copilot CLI) triggering no-prompt mode.
Variables ¶
This section is empty.
Functions ¶
func IsRunningInAgent ¶
func IsRunningInAgent() bool
IsRunningInAgent returns true if azd was invoked by a known AI coding agent.
func ResetDetection ¶
func ResetDetection()
ResetDetection clears the cached detection result. This is primarily useful for testing.
Types ¶
type AgentInfo ¶
type AgentInfo struct {
// Type is the identified agent type.
Type AgentType
// Name is a human-readable name for the agent.
Name string
// Source indicates how the agent was detected.
Source DetectionSource
// Detected is true if an agent was detected.
Detected bool
// Details contains additional detection information (e.g., matched env var or process name).
Details string
}
AgentInfo contains information about a detected AI coding agent.
func GetCallingAgent ¶
func GetCallingAgent() AgentInfo
GetCallingAgent detects if azd was invoked by a known AI coding agent. The result is cached after the first call.
type AgentType ¶
type AgentType string
AgentType represents a known AI coding agent.
const ( // AgentTypeUnknown indicates no agent was detected. AgentTypeUnknown AgentType = "" // AgentTypeClaudeCode is Anthropic's Claude Code agent. AgentTypeClaudeCode AgentType = "claude-code" // AgentTypeCodex is OpenAI's Codex agent. AgentTypeCodex AgentType = "codex" // AgentTypeCursor is Cursor's coding agent. AgentTypeCursor AgentType = "cursor" // AgentTypeGitHubCopilotCLI is GitHub's Copilot CLI agent. AgentTypeGitHubCopilotCLI AgentType = "github-copilot-cli" // AgentTypeGitHubCopilotApp is GitHub's Copilot App agent. AgentTypeGitHubCopilotApp AgentType = "github-copilot-app" // AgentTypeGitHubCopilotVSCode is GitHub Copilot agent mode in VS Code. AgentTypeGitHubCopilotVSCode AgentType = "github-copilot-vscode" // AgentTypeVSCodeCopilot is the GitHub Copilot for Azure extension in VS Code. AgentTypeVSCodeCopilot AgentType = "vscode-copilot" // AgentTypeGemini is Google's Gemini CLI. AgentTypeGemini AgentType = "gemini" // AgentTypeOpenCode is the OpenCode AI coding CLI. AgentTypeOpenCode AgentType = "opencode" )
func (AgentType) DisplayName ¶
DisplayName returns a human-readable name for the agent type.
type DetectionSource ¶
type DetectionSource string
DetectionSource indicates how an agent was detected.
const ( // DetectionSourceNone indicates no detection occurred. DetectionSourceNone DetectionSource = "" // DetectionSourceEnvVar indicates detection via environment variable. DetectionSourceEnvVar DetectionSource = "env-var" // DetectionSourceParentProcess indicates detection via parent process inspection. DetectionSourceParentProcess DetectionSource = "parent-process" // DetectionSourceUserAgent indicates detection via AZURE_DEV_USER_AGENT. DetectionSourceUserAgent DetectionSource = "user-agent" )