/agent365:a365-code-validator Optional: path to agent project, or agent id / blueprint id to include in the reportfrom agent365
Validates Agent 365 observability code to diagnose missing MAC Activity telemetry. Checks exporter activation, runtime identity binding, S2S token shape, semantic span coverage, and blueprint grants. Read-only by default; asks before applying fixes.
Ships in agent365. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Trigger phrases — any of these will activate this skill automatically:
- "validate a365 code"
- "run a365 code validator"
- "check a365 observability code"
- "debug a365 activity missing"
- "debug MAC activity for this agent"
- "validate Agent 365 telemetry"
- "check why Agent Activity is empty"
- "check A365 exporter flags"
- "validate gen_ai agent id"
- "check A365 span types"
This skill performs a report-first validation of an existing agent codebase to answer:
"If this agent runs now, will its spans reach the A365 backend and become eligible for MAC Activity?"
It is designed for incident response. It checks the exact classes of bugs that cause silent or confusing A365 Activity failures:
gen_ai.agent.id set to a Blueprint ID instead of the runtime Agent Identity / Source Agent ID.No source code is modified during validation. After the report, the skill asks whether to apply safe fixes, create a fix plan only, or stop.
This report may be pasted into a customer or partner thread, so it must be safe to share: never print internal cluster/database names, Kusto queries, private endpoint or route templates, correlation IDs, or real tenant/agent IDs. Report file/function names and public, supportable signals only. This is non-negotiable — it holds even when a user asks for "just the raw details."
Show the user this checklist BEFORE Phase 1. Exactly one task is in progress at a time. Claude Code uses
TaskCreate/TaskUpdate; VS Code Copilot Chat / GitHub Copilot CLI should show and update a markdown checklist.
TaskCreate: "Detect stack and A365 artifacts"
TaskCreate: "Run static A365 code validator"
TaskCreate: "Inspect identity binding and semantic spans"
TaskCreate: "Check live blueprint permissions and runtime state"
TaskCreate: "Summarize blockers and next fixes"
TaskCreate: "Offer guided remediation"
Mark task in progress: "Detect stack and A365 artifacts"
Read, in parallel when possible:
.a365-workspace-detection.local.json if presenta365.config.jsona365.generated.config.json.env, .env.example, .env.production, .env.localappsettings.json, appsettings.Development.jsonpackage.jsonrequirements.txt, pyproject.toml*.csprojDetect:
| Signal | Meaning |
|---|---|
microsoft-opentelemetry | Python A365 distro present |
@microsoft/opentelemetry | Node.js A365 distro present |
Microsoft.OpenTelemetry | .NET A365 distro present |
agentBlueprintId / agenticAppId | Distinguish Blueprint ID from runtime Agent Identity |
ENABLE_A365_OBSERVABILITY_EXPORTER / EnableAgent365Exporter | Runtime exporter gate |
authMode | Selects how the app-only telemetry token is sourced (export is S2S in every mode) and which workload auth applies |
Mark task complete.
Mark task in progress: "Run static A365 code validator"
Run the validator from the target project root.
When running from the plugin source (Claude Code / marketplace plugin), use:
node ${CLAUDE_PLUGIN_ROOT}/hooks/stop/validate-a365-code-validator.js
If the runtime cannot expand ${CLAUDE_PLUGIN_ROOT}, run with the absolute plugin path:
node /path/to/agent365-skills/plugins/agent365/hooks/stop/validate-a365-code-validator.js
When running from an open-standard .agents/skills/a365-code-validator/ install, use the
standalone copy that ships with the skill:
node .agents/skills/a365-code-validator/references/a365-code-validator.js
Parse the JSON output. Treat findings by severity:
| Severity | Meaning |
|---|---|
critical | Known MAC Activity blocker — fix before expecting activity |
high | Likely export or identity failure |
medium | Risky or env-dependent — verify before incident closure |
low / info | Useful context |
Important: Findings are not stop-hook failures. A validation run is successful when it accurately reports what is wrong.
Mark task complete.
Mark task in progress: "Inspect identity binding and semantic spans"
Read the reference checklist:
${CLAUDE_PLUGIN_ROOT}/skills/a365-code-validator/references/validation-checklist.md
Then inspect source for these required MAC Activity inputs:
Python must have either explicit code:
use_microsoft_opentelemetry(
enable_a365=True,
a365_enable_observability_exporter=True,
a365_use_s2s_endpoint=True,
)
or a runtime env guarantee:
ENABLE_A365_OBSERVABILITY_EXPORTER=true
Node.js must have:
useMicrosoftOpenTelemetry({
a365: {
enabled: true,
enableObservabilityExporter: true,
useS2SEndpoint: true,
},
});
.NET must have:
"EnableAgent365Exporter": true
Verify the same runtime Agent Identity is used consistently:
token azp/appid/oid == route /agents/{agentId} == span gen_ai.agent.id
The following is wrong for S2S/MAC Activity:
gen_ai.agent.id = <blueprint id>
Blueprint belongs in:
microsoft.a365.agent.blueprint.id
MAC Activity needs supported A365 operations:
invoke_agent
chat
execute_tool
output_messages
Generic HTTP spans alone are not enough. Flag code that only sets baggage but never creates or auto-generates supported semantic spans.
If the developer expects MAC Activity or Defender agent-activity views (not just exporter HTTP 200), inspect whether real runs carry the public Agent 365 activity attributes:
| Attribute | What to validate |
|---|---|
gen_ai.agent.name | Human-readable agent name exists; otherwise UI can show a GUID/blank |
gen_ai.conversation.id | Present on every span; for non-chat agents use a logical run/job/incident ID |
microsoft.channel.name | Present on every span; use msteams for Teams, or a product/source value such as icm, web, scheduler |
microsoft.session.id | Prefer a stable run/session ID; optional, but useful for grouping |
user.id | Human caller OID for HumanToAgent; do not confuse it with the agent's own user |
microsoft.agent.user.id | Agent's own Agent User OID when testing AI teammate / Agent-User / OBO |
gen_ai.input.messages / gen_ai.output.messages | Present on invoke/chat/output spans where applicable |
| Tool details | gen_ai.tool.name, gen_ai.tool.type, gen_ai.tool.call.id, gen_ai.tool.call.arguments, gen_ai.tool.call.result |
| Model details | gen_ai.request.model, gen_ai.provider.name on chat spans |
When reviewing a mixed app, separate the two objectives:
S2S/export success proves telemetry plumbing.
AI teammate/HumanToAgent or EventToAgent run context proves Activity/reporting eligibility.
Do not require Teams-specific values for autonomous agents; require equivalent logical run context instead.
Caller identity caveat: for HumanToAgent, user.id is the caller ID used for "who ran
this agent" reporting. If it is missing or set to the agent identity / agent user instead
of the human caller object ID, export can succeed while caller/user Activity remains blank
or incomplete.
Do not expose or require internal service URLs in the report. Validate only the structural
intent. Telemetry export uses the service-to-service (S2S) route with an app-only token for
the runtime Agent Identity in every auth mode. authMode only changes how that token is
sourced:
| Auth mode | Structural expectation |
|---|---|
| S2S / application | S2S export mode; app-only token from the FMI chain for the configured Agent Identity |
| OBO / agentic-user (incl. AI Teammate) | S2S export mode; app-only token for the turn's Agent Identity from the hosting connection's blueprint credential. OBO / Agentic User tokens are for workload calls (MCP / Graph) only |
Report whether the code selects the S2S transport mode (useS2SEndpoint: true /
a365_use_s2s_endpoint=True / o.Agent365.UseS2SEndpoint = true) in every auth mode, without
printing backend route templates. For Python, prefer a365_use_s2s_endpoint=True in code rather
than relying only on A365_USE_S2S_ENDPOINT=true in the runtime environment.
Flag delegated telemetry as high: the S2S route rejects any token carrying scp, and the
legacy delegated route needs admin consent. Signals are:
AgenticTokenCacheInstance.refreshObservabilityToken(...) (often wrapped
in a preloadObservabilityToken helper), or a tokenResolver that reads
AgenticTokenCacheInstance.getObservabilityToken(...).RegisterObservability(..., new AgenticTokenStruct(...), ...), any new AgenticTokenStruct(...)
(for example an A365OtelWrapper helper), or an IExporterTokenCache<AgenticTokenStruct> dependency.exchange_token(..., scopes=get_observability_authentication_scope(), ...) feeding a
telemetry token cache, cache_agentic_token(...), or an a365_token_resolver backed by
AgenticTokenCache / get_cached_agentic_token.tokenResolver, a365_token_resolver,
or o.Agent365.TokenResolver). The S2S route then has no app-only token to export with. A
resolver symbol elsewhere, such as an unused import, does not count.For Python, also flag (high) an app-only prefetch(self.connection_manager, ...) when nothing
assigns self.connection_manager. CloudAdapter does not expose its connection manager, so
every prefetch fails.
The fix is the app-only resolver from the instrument-observability references, not an OBS
permission grant.
Also check the token shape: the S2S observability token must come from the FMI exchange
(principal == runtime Agent Identity, no scp), not a bare client-credentials call — see
checklist §5 for the failure signatures.
Do not claim that application app roles can never inherit from blueprints. Current public
Entra Agent ID docs describe both inheritableScopes and inheritableRoles. If a repo or
tenant shows delegated scope inheritance working but S2S app roles requiring direct assignment,
report it as a provisioning/configuration behavior to verify, not as the intended scalable model.
Mark task complete.
Mark task in progress: "Check live blueprint permissions and runtime state"
The static validator can only inspect files. When the project has a non-empty
agentBlueprintId and tenantId, complement it with the a365 CLI's read-only Microsoft
Graph diagnostics. These commands verify the tenant state without changing permissions:
a365 query-entra blueprint-scopes
a365 query-entra inheritance
blueprint-scopes lists the delegated scopes and application roles actually granted on
the Blueprint service principal. This is the authoritative permissions view; do not infer
grants from requiredResourceAccess.inheritance verifies that every configured resource uses kind=allAllowed for scopes and
roles and that the Blueprint service principal has something to inherit. It exits non-zero
when any resource has Effective inheritance: NONE or BROKEN.Run these checks by default only when:
a365 query-entra inheritance --help confirms the installed CLI supports the command,The validator must not install or update the CLI, start an interactive sign-in, run
a365 setup permissions, or issue Graph POST/PATCH/DELETE requests. If a prerequisite is
missing, report Blueprint permissions as not checked, explain why, and provide the two
commands for the developer to run after a365-setup refreshes the CLI/login.
If the local config is missing, copied from another project, or suspected stale, use the read-only name-based resolver instead:
a365 query-entra blueprint-scopes --agent-name "<agent-name>" --tenant-id "<tenant-id>"
a365 query-entra inheritance --agent-name "<agent-name>" --tenant-id "<tenant-id>"
Compare the live Blueprint ID printed by the command with the local agentBlueprintId, but
do not print either real ID in the support-safe report:
| Result | Classification |
|---|---|
| Live and local Blueprint IDs resolve to the same Blueprint | current |
| Local ID is not found, but name-based lookup resolves a different Blueprint | critical stale/copied config |
| Neither lookup resolves a Blueprint | high tenant/setup gap |
| Graph returns 401/403 or the caller lacks the required Entra role | not checked authentication/authorization gap, not proof that the Blueprint is broken |
Interpret observability authorization for the S2S route, which every auth mode uses:
| Tenant state | Classification |
|---|---|
Agent instance registered (agentRegistrationId present in a365.generated.config.json, or registration confirmed by a365 setup all) | OK — registered instances are authorized without Agent365.Observability.OtelWrite (subject to service policy) |
| AI Teammate | OK — authorized by its Blueprint's registration without Agent365.Observability.OtelWrite (subject to service policy); it has no agentRegistrationId to check |
Application role Agent365.Observability.OtelWrite granted on the Blueprint (inherited by agent identities) | OK — the S2S route also accepts it |
| Blueprint agent with neither registration nor the application role evident | high — export will likely return 403 insufficient_scope; recommend a365 setup all --agent-registration-only |
Only the delegated Agent365.Observability.OtelWrite scope is granted | Informational — it only matters to legacy delegated-route exporters; flag the code for migration instead (§3.5) |
Do not treat a missing OtelWrite grant as a blocker for a registered blueprint agent or an AI
Teammate: newer Agent 365 CLI versions skip Observability API permissions for both, and older
versions may still grant them harmlessly. Treat a
non-zero inheritance result for another required resource as high. Permission names and
resource display names are safe to summarize, but redact tenant, Blueprint, application,
service-principal, and agent IDs.
For remediation, report the CLI guidance without applying it:
a365 setup requirements when the output points to a missing wids claim or CLI consent.a365 setup all --agent-registration-only (idempotent) when a blueprint agent instance is
not registered (the flag does not apply to AI Teammates). If an AI Teammate's export still
returns 403 insufficient_scope, point to the OtelWrite application-role fallback in
instrument-observability. Run the relevant a365 setup permissions ... flow as a Global Administrator to
reconcile other grants and inheritance.a365-setup so the developer can explicitly choose the
correct reuse/re-run/fresh path. Do not rewrite the ID automatically.References:
Generate commands appropriate for the project.
For Azure App Service:
az webapp config appsettings list `
-g <resource-group> `
-n <app-name> `
--query "[?name=='ENABLE_A365_OBSERVABILITY_EXPORTER' || name=='EnableAgent365Exporter' || name=='A365_USE_S2S_ENDPOINT']"
For local PowerShell:
$env:ENABLE_A365_OBSERVABILITY_EXPORTER="true"
$env:OTEL_LOG_LEVEL="INFO"
$env:A365_OBSERVABILITY_LOG_LEVEL="debug"
Select-String .a365-observability.log -Pattern "Agent365Exporter|identity groups|Obtained token|export|No token|No eligible"
If backend verification is required, keep customer-facing validation on public/supportable surfaces:
partialSuccess empty/null where applicable,CloudAppEvents shows the expected AgentId /
TargetAgentId / AlternateId after indexing.If the user is on an internal service team, they may also use their team's approved dashboard/playbook to confirm request acceptance and downstream delivery, but do not print those internal queries or endpoints in the validator report.
(Report only support-safe signals — see Output is support-safe above.)
Most "exporter returns 200/sent but nothing shows in MAC" incidents are not code bugs.
When the code checks above pass, have the user confirm, in the target tenant:
Provenance (verified 2026-07-06): the observability resource-SP GUID, the
Agent365.Observability.OtelWritescope, and the ingestion-lag figure below are preview-era Agent 365 facts and will change. Re-verify against current Agent 365 onboarding docs before quoting them to a customer.
az ad sp show --id 9b975845-388f-4429-889e-eab1ef63949c
returns a service principal in the tenant. A 404 / AADSTS500011 ("resource principal … not
found") means the observability app isn't provisioned there — an onboarding step, not a code fix.insufficient_scope from the S2S route with a valid
app-only token means the service could not authorize the agent by registration (and it has no
OtelWrite application role). For blueprint agents, registration is the expected fix, not a
permission grant: a365 setup all --agent-registration-only. AI Teammates are authorized by
their Blueprint's registration; if they still get 403, a Global Administrator grants the
OtelWrite application role on the Blueprint (see instrument-observability).CloudAppEvents populates before the admin center; give it ~5 min.Mark task complete: "Check live blueprint permissions and runtime state".
Mark task in progress: "Summarize blockers and next fixes"
Return a concise report. Default to the short format below; include the optional details block only when the user asks for deeper debugging or when a blocker needs a code pointer to be actionable.
## A365 Code Validator Result
**Status:** PASS / PASS WITH RISKS / BLOCKED
**Blockers**
1. **<short title>** — <one-sentence impact>.
Fix: <one-sentence fix>.
2. **<short title>** — <one-sentence impact>.
Fix: <one-sentence fix>.
**High-risk checks**
- <short item> — <why to verify>.
**Identity binding**
- Runtime agent id: <source / missing / from config>
- Blueprint id: <source / missing / from config>
- Verdict: <correct | wrong | unclear>
**Blueprint permissions**
- Live Blueprint: <current | stale/missing | not checked>
- Grants: <verified summary | missing required permission | not checked>
- Effective inheritance: <OK | NONE | BROKEN | not checked>
**Semantic spans**
- Found: <invoke_agent/chat/execute_tool/output_messages or "none">
- Missing: <ops or "none">
**Recommended fix order**
1. <fix root cause first>
2. <then fix config/env>
3. <then verify spans/identity>
**Optional details**
- Files: `<file>:<line or function>`, ...
- Blueprint check: <read-only command result or reason it was skipped>
- Runtime check: <local/App Service env check or SDK log grep>
- Backend verification: use the team's approved telemetry playbook; do not paste internal
cluster names, private endpoints, or correlation IDs into this report.
Style rules:
a365 publish unless the agent is an AI Teammate / M365 package flow;
blueprint-based observability does not use a365 publish.Mark task complete.
Mark task in progress: "Offer guided remediation"
If there are no critical or high findings, say:
No blocking fixes needed. Keep the runtime verification commands handy for live validation.
Then mark the task complete and stop.
If there are critical or high findings, ask the user with AskUserQuestion:
I found blockers. What would you like me to do next?
Options:
| Option | Meaning |
|---|---|
apply_safe_fixes | Apply only low-risk, deterministic code/config-template fixes |
make_fix_plan | Produce an implementation plan, no edits |
report_only | Stop after the report |
Default: make_fix_plan.
Only apply these automatically when the user chooses apply_safe_fixes:
Blueprint permissions are never a safe code fix. Do not run
a365 setup permissions, mutate Graph, grant admin consent, or rewrite a Blueprint ID from this skill. Report the mismatch and hand off toa365-setupor the appropriate administrator.
Python exporter kwarg
use_microsoft_opentelemetry(...) or builds kwargs for that call and already
sets enable_a365=True, add the explicit exporter flag:
a365_enable_observability_exporter=True
or:
kwargs["a365_enable_observability_exporter"] = True
Environment templates
ENABLE_A365_OBSERVABILITY_EXPORTER=true
*-obs-delegated-token), i.e. the exporter already gets an app-only token. Moving an
exporter that still sends a delegated token to the S2S route breaks export, because the S2S
route rejects scp tokens. In that case, bundle the flag with the resolver swap below, which
needs a second confirmation. Do not invent a setting name.Config field scaffolding for runtime agent identity
agent_identity_app_id / AGENT_IDENTITY_APP_ID..env.example if present.Ask a focused follow-up before editing:
Which runtime agent identity config name to use
AGENT_IDENTITY_APP_ID / agent_identity_app_id.Token resolver wiring
instrument-observability references (hosting-connection
resolver for obo / agentic-user, FMI token service for s2s), together with the S2S
transport flag. Change both at once, never the flag alone. Do not request an OBS
permission grant as the fix.Semantic spans
invoke_agent / output_messages scopes first, or also wrap
tools and LLM calls.After applying fixes, show:
**Applied fixes**
- ...
**Still needs user input**
- ...
**Validation to rerun**
- `validate a365 code`
- runtime exporter log check
Run the smallest available project tests if the edited repo has an obvious test command and the user did not decline validation. Otherwise, state that no obvious test command was run.
Mark task complete.
What SKILL.md sets; muted values are Claude Code's defaults
sonnetnpx claudepluginhub microsoft/agent365-skills --plugin agent3658 skills in this plugin
/a365-setupEntry point for general Agent 365 (A365) registration and CLI setup — use this skill whenever the user wants to "set up A365", "register agent", "create blueprint", or general A365 onboarding for non-AI-Teammate agents (Register, Observability paths). Verifies and installs the CLI, validates Azure prerequisites, then delegates to make-a365-agent or make-ai-teammate at Step 3. Does NOT run a365 setup all inline — setup is run by the delegated skill. Supports .NET AgentFramework, Node.js LangChain, and Python agents.
/add-workiq-toolsAdds WorkIQ MCP tool servers to an existing .NET AgentFramework, Node.js, or Python agent using the A365 CLI. Runs a365 develop list-available to show the catalog, adds selected servers via a365 develop add-mcp-servers (which writes ToolingManifest.json), wires McpToolRegistrationService in the agent code, and guides the user through the permissions handoff. Non-destructive and idempotent.
/instrument-observabilityInstruments Microsoft Agent 365 observability into existing .NET AgentFramework, Node.js, or Python agents. Adds OTel-based tracing, context propagation, A365 exporter, manual instrumentation scopes (InvokeAgentScope, InferenceScope, ExecuteToolScope — required for store publishing), and updates configuration files. Asks a two-stage question — agent kind (AI Teammate or Agent (Non AI Teammate)) and auth mode — to determine how the telemetry token is sourced. Every agent exports over the S2S route with an app-only token for the exporting agent identity: `obo` / `agentic-user` agents get an app-only token resolver that reuses the agent's hosting connection (blueprint credential), and `s2s` agents get a scaffold token-service file that acquires and refreshes the Observability API token via the FMI chain (.NET, Node.js, and Python). No OBS permission or admin consent is needed for registered blueprint agent instances. Non-destructive and idempotent.
/make-a365-agentProvisions a non-AI Teammate agent with Agent 365 — use this skill for Register and Observability paths. Runs a365 setup all to create the Blueprint and Entra ID permissions. After setup, always offers instrument-observability (optional) and add-workiq-tools (optional, skipped automatically when authMode = s2s) as add-ons. Supports .NET AgentFramework, Node.js, and Python agents. Normally delegated to from a365-setup after CLI and Azure prerequisites are confirmed. Can also be invoked directly when those steps are already done.
/make-ai-teammateTransforms a non-M365 agent into a Microsoft Agent 365 AI Teammate. Supports all major frameworks across .NET (AgentFramework, Semantic Kernel), Node.js (LangChain, OpenAI Agents SDK, Claude SDK, Semantic Kernel, Google ADK), and Python (AgentFramework, LangChain, OpenAI, Claude, Semantic Kernel, Google ADK). Adds the hosting layer (Express/CloudAdapter for Node.js, ASP.NET Core for .NET, aiohttp for Python), AgentApplication class with message routing and typing indicators, email notifications, and all required packages and env vars. Wraps existing LLM code — does not replace it. Requires a365-setup to have been run first.
/purview-dlp-integrationIntegrate Microsoft Purview DLP (data loss prevention) + audit into an existing Microsoft Agent 365 (A365 SDK) agent, so sensitive prompts are blocked before the LLM and responses can be audited. Use when a user wants to add Purview DLP to an AI agent, block sensitive data (credit cards, SSNs, PII) in agent turns, enforce data protection/compliance on an A365 AgentApplication, call the Graph processContent API, or wire a DLP gate into agent code. Bundles drop-in guards for Node.js/TypeScript, Python, and .NET, minimal wiring for each, a PowerShell script to create the AI-apps DLP policy, a Purview portal/tenant enablement guide, and verification + troubleshooting. Works with A365 agents in Node.js (@microsoft/agents-hosting), Python (microsoft-agents-hosting-*), and .NET (Microsoft.Agents.*).
Other plugins' skills for the same job