scripts/show_agent_status.py¶
Purpose¶
Consolidated Agent Identity status and health check. Combines local state
(.entrabot-state.json, .env-derived configuration) with live Microsoft
Graph queries to report on the Blueprint, Agent Identity, Agent User,
sponsors, permission grants, Blueprint certificates, licenses, and storage
configuration in one command — the canonical way to answer "is my Agent
Identity chain healthy?"
Requirements¶
- Python 3.12+ with
entrabotandazure-identityinstalled (pip install -e ".[provisioning]"). - The Provisioner app must already be bootstrapped:
.entrabot-state.jsonat the repo root needsPROVISIONER_CLIENT_IDandTENANT_ID, and the Provisioner's certificate private key must be present in the OS keystore (Keychain / Windows Certificate Store / Secret Service viakeyring). This command mints its Graph token from the Provisioner's certificate credential (CertificateCredential+client_credentials) — it does not use the Agent User three-hop flow. If the Provisioner isn't bootstrapped, runpython3 scripts/entra_provisioning.py(or fullsetup.sh) first. - Works on macOS, Linux, and Windows.
Usage¶
python scripts/show_agent_status.py
python scripts/show_agent_status.py --json
python scripts/show_agent_status.py --health-only
python scripts/show_agent_status.py --health-only --strict
python scripts/show_agent_status.py --help
Options¶
--json— print the full snapshot (state, platform info, storage config, sponsors, licenses, permission grants, key credentials, and health checks) as a single JSON object instead of the formatted text report.--health-only— print only the pass/fail/warn/skip health checks, skipping the detailed sections. Always returns a non-zero exit code if any check fails, regardless of--strict.--strict— return exit code1when any health check has failed; has no visible effect on output, only on the exit code. Implied by--health-only.
No positional arguments.
Effects¶
- Reads
.entrabot-state.jsonkeys:TENANT_ID,PROVISIONER_CLIENT_ID,PROVISIONER_CERT_THUMBPRINT,BLUEPRINT_APP_ID,BLUEPRINT_OBJECT_ID,BLUEPRINT_CERT_THUMBPRINT,AGENT_ID,AGENT_OBJECT_ID,AGENT_USER_ID,AGENT_USER_UPN, andAGENT_USER_WORK_IQ_LICENSE_SKU. - Reads storage configuration from the process environment /
.envviaentrabot.config.get_config(). - Issues read-only Graph GET requests (no writes to Graph or local state):
/servicePrincipals/{agentOid}/microsoft.graph.agentIdentity/sponsors(beta)/subscribedSkusand/users/{agentUserId}(assigned licenses, v1.0)/oauth2PermissionGrants?$filter=clientId eq '...' and principalId eq '...'(v1.0)/servicePrincipals/{resourceId}per distinct grant resource, to resolve display names/applications/{blueprintObjectId}for BlueprintkeyCredentials(v1.0)- Recomputes the SHA-256 JWT thumbprint of every Blueprint key credential
locally and compares it against
BLUEPRINT_CERT_THUMBPRINTto detect certificate drift between Entra and local state. - All output goes to stdout — the formatted text report, the health-only
list, or the
--jsonpayload. The single error path (Provisioner token acquisition failure) also prints to stdout (ERROR: Cannot acquire token: ...), not stderr.
Exit behavior¶
- Returns
1if the Provisioner Graph token cannot be acquired (ProvisionerBootstrapError). - Otherwise returns
1when(--strict or --health-only)is true and at least one health check hasstatus == "fail". - Returns
0in every other case — including runs where checks reportwarnorskipbut nofail, and non-strict, non-health-only runs regardless of check outcomes. --helpexits0(argparse default).
Common failures¶
ERROR: Cannot acquire token: ...— the Provisioner app isn't bootstrapped, or its certificate is missing from the local OS keystore. Runpython3 scripts/entra_provisioning.pyorsetup.sh.- "State completeness" check fails — one or more required keys is
missing from
.entrabot-state.json; re-runsetup.sh. - "Certificate" check warns "not found in Entra" — the local
BLUEPRINT_CERT_THUMBPRINTdoesn't match any key credential currently on the Blueprint app, typically after an out-of-band cert rotation; seeverify_blueprint_cert.py. - "Sponsors" / "Licenses" / "Permissions" checks fail — use
add_agent_sponsor.py,assign_agent_user_licenses.py, orgrant_consent.pyrespectively.
Related commands¶
status.sh/status-windows.ps1— thin wrappers that bootstrap the venv and call this command.health_check.py— compatibility wrapper that forwards to--health-only.show_permissions.py— a focused view of just the permission grants, using the same Provisioner-cert token.- Platform docs: Agent Identity Blueprints and Users
- Architecture: Identity and Token Flow
- Operations scripts index