Installation

Install as Agent Plugin Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install iap-agent-platform-troubleshooting@skills-hub

Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled). Plugin iap-agent-platform-troubleshooting v1.0.0 follows the Agent Plugins spec.

Install with the gh extension
gh skills-hub install iap-agent-platform-troubleshooting

Don't have the extension? Run gh extension install samueltauil/skills-hub first.

Download and extract to your repository:

.github/skills/iap-agent-platform-troubleshooting/

Extract the ZIP to .github/skills/ in your repo. The folder name must match iap-agent-platform-troubleshooting for Copilot to auto-discover it.

Skill Files (13)

SKILL.md 14.5 KB
---
name: iap-agent-platform-troubleshooting
metadata:
  version: "1.0.0"
  category: Security
description: >-
  Diagnoses Identity-Aware Proxy (IAP) denials of outbound requests
  from Gemini Enterprise Agent Platform agents that run on Agent Runtime and
  send traffic through Agent Gateway. Use when an agent request fails
  with "Egress request is not authorized", when Cloud Audit Logs show an IAP
  egressViaIAP decision with granted false, when IAP audit entries are missing
  while debugging agent egress, or when Access policies, IAP allow policies,
  policy bindings, or Agent Registry entries might block agent egress. Don't
  use for Gemini model IAM permission errors (such as
  aiplatform.endpoints.predict), Agent Platform API errors, or Agent Runtime
  deployment or 500 errors (use agent-platform-troubleshooting instead). Don't
  use for setting up, creating, or connecting an Agent Gateway, or for IAP web
  apps, IAP TCP forwarding, or SSH.
---

# IAP troubleshooting for Gemini Enterprise Agent Platform

Find out why Identity-Aware Proxy (IAP) denies a request from a Gemini
Enterprise Agent Platform agent, and print the smallest fix for the
user to run.
This skill supports Agent Runtime (Reasoning Engine) agents that use agent
identity and send traffic through Agent Gateway.

## Operating contract

-   **Read only.** Run only the read commands in this skill and its
    references (`describe`, `list`, `get-iam-policy`,
    `search-target-policy-bindings`, and `logging read`), or the matching
    read-only MCP tools (see [Tool selection](#tool-selection)). The setup
    commands in [prerequisites.md](references/prerequisites.md) change only
    local CLI settings.
-   **Print fixes, never run them.** Don't run a command that creates,
    imports, updates, binds, enables, or deletes anything, even if the user
    asks you to. Print the remediation template for the root cause (see
    [Report](#report)), and let the user run it. Access policies and IAP allow
    policies apply to every agent whose traffic goes through Agent Gateway in
    that project, so a wrong change can block or expose other agents.
-   **Evidence first.** Copy principals, resource names, and hostnames from
    command output. Don't build them from memory.
-   **Stop on missing access.** If a read fails with `PERMISSION_DENIED`,
    report the missing role instead of working around it.

## Attribution

**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read [Usage Attribution](references/attribution.md). For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix `gcloud` with
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:iap-agent-platform-troubleshooting)"`
and append `agent-skills/1.0 (skill:iap-agent-platform-troubleshooting)` to
`User-Agent` headers.

## Tool selection

Prefer the read tools of a connected Google Cloud remote MCP server over the
matching `gcloud` read, because remote MCP servers apply IAM, authentication,
and audit logging to every call. Use `gcloud` for any read that no connected
MCP server covers.

-   **Cloud Logging:** run the log queries with `list_log_entries`. The
    queries in the references use `gcloud` syntax, so adapt each one: set
    `resourceNames` to `projects/{project_id}`, keep the filter, replace
    `--freshness` with a `timestamp>=` clause in the filter, and set
    `orderBy` to `timestamp desc` and `pageSize` to the `--limit` value.
    Don't pass `gcloud` flags such as `--freshness` to the tool.
-   **Agent Registry:** resolve destinations with its read tools, such as
    `list_endpoints`, `get_endpoint`, `list_mcp_servers`, and
    `get_mcp_server`.
-   **Cloud CLI:** run the `gcloud` reads in this skill through
    `run_gcloud_command`.
-   **IAP, Agent Gateway, and authorization policies:** no remote MCP server
    covers these, so read them with `gcloud`, directly or through the Cloud
    CLI MCP server.

The read-only contract covers MCP tools too: never call a tool that creates,
updates, or deletes anything, such as `create_binding` or `delete_service`.

## Prerequisites

The Google Cloud CLI must be
[installed](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt) and
authenticated for `{project_id}`. Load
[prerequisites.md](references/prerequisites.md) if it isn't, or when a read
fails with `PERMISSION_DENIED` or a disabled API. It covers
`gcloud auth login`, the APIs, the read-only roles, billing, and the default
region (`us-central1`). The diagnosis creates no resources, so there's nothing
to clean up.

## Required context

Collect these values. Ask the user for any that are missing.

| Value | Source |
| :--- | :--- |
| `{project_id}`, `{project_number}` | The agent's project, and the gateway's project if it's different |
| `{location}` | Region of the agent and Agent Gateway |
| `{engine_id}` | ID of the Agent Runtime agent |
| `{gateway}` | The Agent Gateway that carries the agent's traffic |
| Destination URL | The exact URL that the agent called |
| Error text and time | The agent's logs or the user's report |
| `{org_id}` | Needed only for the optional principal access boundary check |

If the agent and Agent Gateway are in different projects, use the agent's
project number in principals. Use the gateway's project for the gateway, its
authorization policies and extension, Access policies, and policy bindings. Run
the IAP audit query in the gateway's project, and in the agent's project if it
returns nothing.

Load [topology-agent-gateway.md](references/topology-agent-gateway.md) to
confirm the topology, the principal format, the agent log query, and 403
errors during startup. If the agent doesn't run on Agent Runtime behind Agent
Gateway, say that the topology isn't supported yet, and stop.

## Step 0: Classify the failure

Load [audit-logs.md](references/audit-logs.md). Run the IAP decision query for
the time of the failure, and match the entry to the request by principal,
destination, and time. Use the first row that matches. An IAP entry outranks
the error text, because the entry records the decision itself.

| Signal | Meaning | Next |
| :--- | :--- | :--- |
| IAP entry with `granted: false`, not dry run | IAP denied the request | Step 1, then Steps 2-4 |
| IAP entry with `dryRun: true` or `iamEnforcementMode: DRY_RUN` | IAP logged the decision but didn't block the request. A 403 comes from the gateway or the destination | Step 1, then Steps 2-4: find the source of any 403, and whether IAP would deny the request once enforced |
| IAP entry with `granted: true` | IAP allowed the request | Step 2, then the destination |
| No IAP entry, and the error is an IAM permission error on a model or Agent Platform API call, such as `aiplatform.endpoints.predict` denied | Not an IAP egress denial | Stop, and name `agent-platform-troubleshooting` |
| No IAP entry for the request | Data Access audit logs are off, or the gateway denied the request before IAP | Step 1 (logs check), then Step 2 |

## Step 1: Check telemetry

1.  Run the Data Access check in [audit-logs.md](references/audit-logs.md). If
    the logs are off, explain that past requests weren't recorded, print the
    "Enable Data Access audit logs for IAP" template, and stop until the user
    reproduces the failure.
2.  From the matching entry, record `principalSubject`, the destination, the
    policy version, and the CEL evaluation details if the entry has them. Read
    each from the field names in the fields table of
    [audit-logs.md](references/audit-logs.md), because entries use different
    layouts. The destination is `metadata.destination` when it's present, not
    `authorizationInfo[].resource`, which can name the gateway.
3.  If the entry has `metadata.destination.unregistered`, or
    `audited_resource_name` is `unregisteredResource` or ends in
    `unregisteredEndpoint`, the destination counts as unregistered: the hostname
    isn't registered, or, for an MCP server, the called tool isn't in its tool
    spec (see [agent-registry.md](references/agent-registry.md)). Keep that for
    Step 4.

## Step 2: Check the gateway chain

Load [gateway-setup.md](references/gateway-setup.md). Read the gateway, its
authorization policies, and its authorization extension.

-   If no authorization policy with `policyProfile: REQUEST_AUTHZ` lists the
    gateway in `target.resources`, the extension isn't executed and no IAP
    entry exists. That's the root cause.
-   Read the extension that the policy names, not the one you expect. Its
    `service` must be `iap.googleapis.com`. Record `metadata.iapPolicyVersion`,
    `metadata.iamEnforcementMode`, and `failOpen`, because they decide which
    policies IAP evaluates, whether it blocks, and whether a request passes
    when the call to IAP fails or times out.

## Step 3: Check policies and bindings

Load [policy-model.md](references/policy-model.md), and use the section for the
version from Step 2.

-   **V2 (Access policies):** read every policy bound to the project or the
    gateway, because a deny rule in any of them wins and a policy without a
    binding isn't enforced.
-   **V1 (IAP allow policies):** look for `roles/iap.egressor` granted to the
    agent's principal, or to a principal set that contains it, in the
    registry-wide policy and in the destination's own policy. A resource
    inherits the registry-wide grants, so a grant at either level applies.
-   **Allowed but still denied:** check principal access boundary policies
    (needs `{org_id}`) and principal set membership (see
    [topology-agent-gateway.md](references/topology-agent-gateway.md)).

## Step 4: Check the rule match

Load [cel-attributes.md](references/cel-attributes.md) and
[agent-registry.md](references/agent-registry.md).

1.  **Principal:** the rule lists the agent's exact `principal://` identifier,
    or a `principalSet://` that contains the agent: same trust domain, and the
    agent's project number or platform attribute, as listed in the principal set
    table of [topology-agent-gateway.md](references/topology-agent-gateway.md).
    If `principalSubject` holds a SPIFFE ID, build the identifier as described
    there. A project ID in place of the project number, in either form, or a URN
    identifier, never matches.
2.  **Destination:** resolve the URL in Agent Registry.
    -   Registered: the condition names the registry resource with `==` or
        `in`, exactly as the audit entry's `resource_id` or the Agent Registry
        list output shows it.
    -   Unregistered, Access policies (V2) only: the condition matches the
        host, the path, and the method (see
        [cel-attributes.md](references/cel-attributes.md)). IAP allow policies
        (V1) can't allow an unregistered destination: register it, and grant
        `roles/iap.egressor` only if no registry-wide grant covers the agent.
3.  **Condition:** for V2, use the CEL evaluation details from the audit entry
    to find the clause that failed. If the entry has no evaluation details,
    compare the entry's `resource_id` or `unregistered` values with each
    literal in the condition yourself.

## Report

Load only the remediation reference for the root cause:

| Root cause | Load |
| :--- | :--- |
| Data Access audit logs are off, or an API is disabled | [remediation-setup.md](references/remediation-setup.md) |
| The authorization policy doesn't target the gateway, or calls the wrong extension | [remediation-gateway.md](references/remediation-gateway.md) |
| An Access policy (V2) rule doesn't match or a DENY rule matches, a binding is missing, or the organization policy constraint blocks the binding | [remediation-access-policies.md](references/remediation-access-policies.md) |
| An IAP allow policy (V1) grant is missing, the destination or a hostname variant isn't registered, or an MCP tool is missing from the server's tool spec | [remediation-registry.md](references/remediation-registry.md) |

Use this template:

```markdown
## Root cause
{root_cause_quoting_the_mismatched_value}

## Fix (you run this)
{why_smallest_change}
{filled_in_template}
Required role: {role}

## Wait time
{wait_time}

## Verify
- [ ] Reproduce the request.
- [ ] A new IAP audit entry shows granted: true for {principal} and {destination_url}.
- [ ] {read_command_that_confirms_the_change}
```

In dry run, IAP blocks nothing yet. Say so in the root cause, and say that its
logged denials are the requests that enforcement would block, because users
run dry run to find these requests before they enforce. If the user needs the
request to succeed and the policies wouldn't allow it once enforced, print
that fix under "Before you turn on enforcement". Verify it with a read
command, because a dry-run entry's `granted` value doesn't show whether a
policy allows the request.

If the evidence doesn't prove one root cause, list what you checked, what's
still unknown, and the next read command. Don't print a fix.

## Validation loop

Before you send the report, check every item. If one fails, fix the report
and check again.

-   [ ] No command or MCP tool call that you made changed a resource. Every
    fix is printed for the user.
-   [ ] The fix is additive. It keeps existing bindings, rules, and clauses.
-   [ ] If a DENY rule causes the denial, the report says that the block might
    be deliberate and offers any change to that rule only as an option for
    the rule's owner to approve.
-   [ ] The principal is the agent's exact `principal://` identifier, in the
    Agent Runtime format.
-   [ ] Registry resource names in conditions use the project ID, copied from
    the audit entry's `resource_id` or from Agent Registry list output.
-   [ ] A binding fix targets the project that contains Agent Gateway.
-   [ ] Hostnames match exactly, every variant is covered, and methods are in
    the request's case, such as `'GET'`.
-   [ ] The fix allows only the hosts, paths, and methods that the logs show
    the agent calling, and keeps restrictions that the rule already has, such
    as a method limit, because they're often deliberate. If the user asks to
    loosen a rule, say whether the logs show that it's needed. Never print a
    rule that's looser than the logs require.
-   [ ] V1 fixes use `roles/iap.egressor`, never
    `roles/iap.tunnelResourceAccessor`, which grants IAP TCP forwarding, not
    egress.
-   [ ] No fix turns off IAP or switches enforcement to dry run, because that
    removes egress protection for every agent behind the gateway.
-   [ ] Every placeholder is filled in from command output.
-   [ ] Commands printed for the user don't include
    `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` or the attribution `User-Agent`
    string, because the tag is only for commands you run yourself (see
    [attribution.md](references/attribution.md)).
references/
agent-registry.md 6.1 KB
# Agent Registry lookups

IAP for agents matches each egress request against the Agent Registry
instances that Agent Gateway uses. A destination counts as registered only when
its hostname matches a registered interface URL exactly. Policies that name a
registry resource must use the name that Agent Registry assigned.

Sources:
[Troubleshoot Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-agent-gateway.md.txt),
[Set up Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/set-up-agent-gateway.md.txt),
[Register endpoints](https://docs.cloud.google.com/agent-registry/register-endpoints.md.txt),
[Register MCP servers](https://docs.cloud.google.com/agent-registry/register-mcp-servers.md.txt),
[Agent Registry locations](https://docs.cloud.google.com/agent-registry/locations.md.txt),
[IAP allow policies overview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/iam-overview.md.txt).

## Which registry to search

-   Search the registries listed in the gateway's `registries` field (see
    [gateway-setup.md](gateway-setup.md)). Use the project ID and location
    from each registry path as `{project_id}` and `{registry_location}`.
-   If the gateway uses a global and a regional or multi-regional registry,
    the regional or multi-regional entry takes precedence over a global entry
    with the same interface URL.
-   An agent in another project must be registered in the registry of the
    project where Agent Gateway runs.
-   Agents, MCP servers, and endpoints can't be registered manually in the `us`
    and `eu` multi-regions. Use a region or `global`.

## Resolve a destination by URL

```bash
gcloud agent-registry endpoints list \
    --location={registry_location} --project={project_id} \
    --format="json(name,interfaces)"
gcloud agent-registry mcp-servers list \
    --location={registry_location} --project={project_id} \
    --format="json(name,interfaces)"
gcloud agent-registry agents list \
    --location={registry_location} --project={project_id}
```

`{host}` is the hostname of the URL that the agent called. A resource matches
only if the hostname of one of its `interfaces[].url` values equals `{host}`
exactly. Compare the hostnames yourself instead of with `--filter`, because a
filter's `:` operator isn't an exact match. Use the full `name` in CEL.

To read one resource in full:

```bash
gcloud agent-registry mcp-servers describe {mcp_server_id} \
    --location={registry_location} --project={project_id}
gcloud agent-registry endpoints describe {endpoint_id} \
    --location={registry_location} --project={project_id}
gcloud agent-registry agents describe {agent_id} \
    --location={registry_location} --project={project_id}
```

-   Resource names have the form
    `projects/{project_id}/locations/{registry_location}/mcpServers/{mcp_server_id}`
    (or `endpoints/` or `agents/`). There's no `registries/` segment and no
    `--registry` flag. Policy conditions use this full `name`, not its
    basename.
-   If no resource matches in any registry that the gateway uses, the
    destination isn't registered. The IAP audit entry agrees: it has
    `metadata.destination.unregistered`, or its
    `labels."iap.googleapis.com/audited_resource_name"` is
    `unregisteredResource` or ends in `unregisteredEndpoint`.
-   Exception for MCP servers registered with a tool spec: a `tools/call` for a
    tool that isn't in the spec is also logged as unregistered, even though the
    hostname matches the server's interface URL. Compare the tool that the agent
    called with `tools[].name` in `mcp-servers describe` output before you call
    the host unregistered.

## Common causes

| Cause | Evidence | Fix |
| :--- | :--- | :--- |
| Hostname variant not registered | The URL in the gateway log, for example a regional or `mtls` hostname, matches no interface URL | Add the variant as an interface of the existing service (read the registration warning below). With Access policies (V2) only, you can instead allow it with a `destination.unregistered.host` condition |
| Destination not registered | No resource matches the URL | Register it (read the registration warning below). IAP allow policies (V1) can't allow an unregistered destination, so with V1, register it and then grant `roles/iap.egressor`. With Access policies (V2) only, you can instead allow it with `destination.unregistered.*` conditions ([cel-attributes.md](cel-attributes.md)) |
| Tool missing from the MCP server's tool spec | The audit entry is unregistered, but the host matches an MCP server's interface URL, and the called tool isn't in its `tools[].name` | Add the tool to the tool spec ("Add a tool to a registered MCP server" in [remediation-registry.md](remediation-registry.md)). Don't allow it with `destination.unregistered.*` clauses, which stop matching once the tool is added |
| Wrong resource ID in a rule | The name in the policy differs from `name` in the list output for that URL, for example a display name in place of the generated ID, or the project number in place of the project ID | Replace the name in the rule with the full `name` from the list output, not its basename |
| Wrong registry | The resource exists, but in a registry that the gateway doesn't use | Register it in a registry that the gateway uses |

**Registration warning:** after a hostname is registered,
`destination.unregistered.*` clauses in allow and deny rules no longer match
it. Before you print a registration or interface template, search the bound
Access policies for the hostname, and also print the matching change to a
`destination.agent_registry.*` condition. With IAP allow policies (V1), also
print the `roles/iap.egressor` grant for a newly registered resource.

-   Registering an endpoint creates a `Service` resource. Agent Registry then
    generates a read-only `Endpoint` resource. In policy conditions, use the
    endpoint's full `name` from `endpoints list`, not its basename.
-   A service with several `--interfaces` values is one endpoint, so a single
    IAP policy binding covers every interface URL.
-   The registration and interface templates are in
    [remediation-registry.md](remediation-registry.md).
attribution.md 1.9 KB
# Usage Attribution

**MUST READ**: Before executing any `gcloud`, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.

-   **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
    subcommand, with the metrics environment variable. Set it inline on each
    command because shell state may not persist between commands:

    ```bash
    CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:iap-agent-platform-troubleshooting)" \
    gcloud <command> [flags]
    ```

    Do not use `gcloud config set` for this: it would persist beyond the current
    task and mislabel unrelated usage.

-   **Direct HTTP, REST, and MCP Requests**: On direct HTTP calls to Google
    Cloud APIs (for example with `curl`) or HTTP requests to a remote MCP
    server, include
    `agent-skills/1.0 (skill:iap-agent-platform-troubleshooting)`
    in the `User-Agent` header. If a `User-Agent` header is already specified,
    append this string to the end of it rather than overwriting existing
    `User-Agent` data — the collection pipeline parses the
    `agent-skills/<version>` and `skill:<name>` tokens, so any rewording breaks
    attribution:

    ```
    User-Agent: <existing_user_agent> agent-skills/1.0 (skill:iap-agent-platform-troubleshooting)
    ```

-   **Constraint for Generated Code**: The tracking prefix is strictly for
    commands you execute directly in the terminal. Do NOT include this tracking
    prefix in generated scripts, Terraform templates, or code provided to the
    user for their own repositories.

-   **User Opt-Out**: If the user asks to disable or remove tracking or
    attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable
    and custom `User-Agent` suffix from all commands.
audit-logs.md 7.7 KB
# Cloud Audit Logs for IAP egress decisions

IAP for agents writes each egress authorization decision to Cloud Audit Logs as
a Data Access audit log entry. Data Access audit logs are off by default for
most services, so check the configuration before you trust an empty result.

## Contents

- [Check whether Data Access audit logs are on](#check-whether-data-access-audit-logs-are-on): Lines 21-39
- [Find IAP egress decisions](#find-iap-egress-decisions): Lines 41-72
- [Fields to record](#fields-to-record): Lines 74-98
- [What the signals mean](#what-the-signals-mean): Lines 100-124

Sources:
[Configure Data Access audit logs](https://docs.cloud.google.com/logging/docs/audit/configure-data-access.md.txt),
[Troubleshoot Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-agent-gateway.md.txt),
[Monitor Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/monitor-agent-gateway.md.txt),
[IAP roles and permissions](https://docs.cloud.google.com/iam/docs/roles-permissions/iap.md.txt),
[Logging query language](https://docs.cloud.google.com/logging/docs/view/logging-query-language.md.txt).

## Check whether Data Access audit logs are on

```bash
gcloud projects get-iam-policy {project_id} --format="json(auditConfigs)"
```

1.  The logs are on for IAP egress if the `iap.googleapis.com` and
    `allServices` entries in `auditConfigs` turn on all three Data Access log
    types between them: `ADMIN_READ`, `DATA_READ`, and `DATA_WRITE`. A type
    that either entry turns on counts.
2.  If any type is missing, check for an inherited setting before you conclude
    that the logs are off. A folder or organization can also turn the logs on,
    and this command shows only the project's own policy. Run the IAP decision
    query in the next section with `--freshness=30d`. If any IAP egress entry
    exists, the logs are on.
3.  Otherwise, the logs are off. Stop, explain that past requests weren't
    recorded, print the "Enable Data Access audit logs for IAP" template from
    [remediation-setup.md](remediation-setup.md), and ask the user to
    reproduce the failure after they apply it.

## Find IAP egress decisions

Read the logs of the project that contains Agent Gateway:

```bash
gcloud logging read '
  protoPayload.serviceName="iap.googleapis.com"
  protoPayload.authorizationInfo.permission:"egressViaIAP"' \
  --project={project_id} --freshness=1d --limit=20
```

The logged permission name varies by release:
`iap.googleapis.com/resources.egressViaIAP` or `iap.resources.egressViaIAP`
for Access policies (V2), and `iap.webServiceVersions.egressViaIAP` for IAP
allow policies (V1). Keep the `:` substring match, because an exact `=` match
on one name can return nothing.

Add one of these lines inside the filter to narrow the result. Field names
differ between releases and entry layouts, so the dry-run and version filters
test every known name:

| Filter line | Returns |
| :--- | :--- |
| `protoPayload.status.code!=0` | Denied decisions, enforced or dry run |
| `(protoPayload.metadata.dryRun=true OR protoPayload.request.dryRun=true OR protoPayload.metadata.iamEnforcementMode="DRY_RUN")` | Decisions logged in dry run, which IAP didn't enforce |
| `(protoPayload.metadata.policy_version="POLICY_VERSION_V2" OR protoPayload.metadata.iapPolicyVersion="v2")` | Decisions evaluated against Access policies |
| `protoPayload.request.httpRequest.url:"{host}"` | Decisions for one destination host |
| `protoPayload.metadata.mcp_attributes.base_protocol_method="true"` | MCP base-protocol requests only |

A narrow `--freshness` window can return zero rows even when entries exist.
Before you conclude that no entry exists, widen `--freshness` to cover the time
of the failure.

## Fields to record

Entries use different field layouts. Check each name in the order listed.

| Field | Meaning |
| :--- | :--- |
| `protoPayload.authorizationInfo[].granted` | `true` if IAP allowed the request, `false` if it denied it |
| `protoPayload.authenticationInfo.principalSubject` | The caller's SPIFFE ID or `principal://` identity. Copy a `principal://` value exactly. For a SPIFFE ID, see [topology-agent-gateway.md](topology-agent-gateway.md#agent-principal) |
| `protoPayload.metadata.destination.agent_registry.resource_id` | The registered destination that the request resolved to, such as `projects/{project_id}/locations/{location}/endpoints/{endpoint_id}`. It uses the project ID. Older entries put the destination in `protoPayload.authorizationInfo[].resource` instead |
| `protoPayload.metadata.destination.unregistered` | Present, with `host`, `path`, and `method`, when the hostname isn't registered in Agent Registry. Older entries show `unregisteredResource` in `labels."iap.googleapis.com/audited_resource_name"` instead, and some IAP allow policy (V1) entries show a name that ends in `unregisteredEndpoint` there, with no `metadata.destination` |
| `protoPayload.request.httpRequest.url`, `protoPayload.requestMetadata.requestAttributes.host` and `.path` | The URL that the agent called |
| `protoPayload.metadata.dryRun`, `protoPayload.request.dryRun`, or `protoPayload.metadata.iamEnforcementMode` | `true` or `DRY_RUN` means IAP logged the decision but didn't block the request. A dry-run entry can show `granted: true` for a request that the policies don't allow |
| `protoPayload.metadata.policy_version`, `protoPayload.request.policy_version`, or `protoPayload.metadata.iapPolicyVersion` | The policy model that IAP evaluated. `POLICY_VERSION_V2` or `v2` means Access policies |
| `protoPayload.status.code` | Non-zero for a denied request |

-   `authorizationInfo[].resource` and `audited_resource_name` can name the
    Agent Gateway rather than the destination. Read the destination from
    `metadata.destination` when it's present.
-   `metadata.unsatisfied_access_levels` also appears on granted entries.
    Don't report it as a cause of an egress denial.

Some Access policy (V2) entries include CEL evaluation details. Use them to
find the part of the condition that didn't match. Most entries have none, so
compare `resource_id` or the `unregistered` values with each literal in the
condition yourself.

## What the signals mean

-   **Entry with `granted: false`, not dry run:** IAP denied the request.
    Check the policy model and rules.
-   **Entry with `dryRun: true` or `iamEnforcementMode: DRY_RUN`:** IAP didn't
    block the request. A 403 in dry run likely comes from the gateway's egress
    proxy or from the destination. The entry's `granted` value doesn't show
    whether a policy allows the request, so compare the policies with the
    request (SKILL.md Steps 3-4) to find whether IAP would deny it once
    enforced. If requests pass that should be blocked, check which extension
    the gateway's authorization policy calls (see
    [gateway-setup.md](gateway-setup.md)).
-   **Entry with `granted: true`, not dry run:** IAP allowed the request. Look
    at the gateway decision and the destination.
-   **Many destinations denied at once, including the agent's own model call**
    (`{location}-aiplatform.mtls.googleapis.com` `generateContent`), often with
    `iamcredentials` and `telemetry` hosts: the rule doesn't match for any
    request. Check the principal and every registry name literal in the
    condition (SKILL.md Step 4) before you look at single hosts. The agent
    fails before it runs any tool, so the URL that the user reported might not
    appear in the logs.
-   **No entry for the request, logs on:** the gateway might have denied the
    request before IAP evaluated it, for example because the authorization
    chain is incomplete or another `REQUEST_AUTHZ` policy denied it first.
    Check the chain in [gateway-setup.md](gateway-setup.md).
cel-attributes.md 7.4 KB
# CEL attributes for policy conditions

Access policy (V2) rules hold their CEL expression in
`conditions."iap.googleapis.com".expression`. The rule's effect applies only
when the whole expression is true. IAP allow policies (V1) use other attribute
names; see [V1 condition attributes](#v1-condition-attributes).

## Contents

- [Registered destinations](#registered-destinations): Lines 23-33
- [MCP servers](#mcp-servers): Lines 35-46
- [Unregistered destinations](#unregistered-destinations): Lines 48-54
- [Matching rules](#matching-rules): Lines 56-83
- [Fix patterns](#fix-patterns): Lines 85-126
- [V1 condition attributes](#v1-condition-attributes): Lines 128-142

Sources:
[CEL attributes for IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/cel-attributes-uap.md.txt),
[Configure IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies-uap.md.txt),
[IAP allow policies overview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/iam-overview.md.txt),
[Configure IAP allow policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies.md.txt).

## Registered destinations

| Attribute | Values | Operators |
| :--- | :--- | :--- |
| `destination.is_registered` | `true`, `false` | `==`, `!=` |
| `destination.agent_registry.resource_type` | `'AGENT'`, `'ENDPOINT'`, `'MCP_SERVER'`, `'SKILL'` | `==`, `!=`, `in` |
| `destination.agent_registry.location` | Location ID, such as `'global'` or `'us-central1'` | `==`, `!=`, `in` |
| `destination.agent_registry.project_id` | Project ID | `==`, `!=`, `in` |
| `destination.agent_registry.agent.name` | `projects/{project_id}/locations/{location}/agents/{agent_name}` | `==`, `!=`, `in` |
| `destination.agent_registry.endpoint.name` | `projects/{project_id}/locations/{location}/endpoints/{endpoint_name}` | `==`, `!=`, `in` |
| `destination.agent_registry.mcp_server.name` | `projects/{project_id}/locations/{location}/mcpServers/{mcp_server_name}` | `==`, `!=`, `in` |

## MCP servers

| Attribute | Values | Operators |
| :--- | :--- | :--- |
| `destination.agent_registry.mcp_server.method` | JSON-RPC method of the request, such as `'initialize'`, `'tools/list'`, `'tools/call'`, `'prompts/get'`, or `'resources/read'` | `==`, `!=`, `in` |
| `destination.agent_registry.mcp_server.tool.name` | Tool name | `==`, `!=`, `in` |
| `destination.agent_registry.mcp_server.tool.annotations.read_only_hint` | `true`, `false` | `==`, `!=` |
| `destination.agent_registry.mcp_server.tool.annotations.destructive_hint` | `true`, `false` | `==`, `!=` |
| `destination.agent_registry.mcp_server.tool.annotations.idempotent_hint` | `true`, `false` | `==`, `!=` |
| `destination.agent_registry.mcp_server.tool.annotations.open_world_hint` | `true`, `false` | `==`, `!=` |
| `destination.agent_registry.mcp_server.prompt.name` | Prompt name | `==`, `!=`, `in` |
| `destination.agent_registry.mcp_server.resource.name` | Resource name | `==`, `!=`, `in` |

## Unregistered destinations

| Attribute | Values | Operators |
| :--- | :--- | :--- |
| `destination.unregistered.host` | Hostname, such as `'example.com'` | `==`, `!=`, `in`, `startsWith()`, `endsWith()`, `contains()` |
| `destination.unregistered.path` | Request path, such as `'/api/v1'` | `==`, `!=`, `in`, `startsWith()`, `endsWith()`, `contains()` |
| `destination.unregistered.method` | `'GET'`, `'POST'`, `'PUT'`, `'DELETE'` | `==`, `!=`, `in` |

## Matching rules

-   `startsWith()`, `endsWith()`, and `contains()` work only on
    `destination.unregistered.host` and `destination.unregistered.path`.
-   IAP compares the method exactly as the request sent it, normally
    uppercase, such as `'POST'`. The gateway log's `httpRequest.requestMethod`
    shows it (see [gateway-setup.md](gateway-setup.md)). Some documentation
    examples use lowercase, so copy the case from the gateway log. A rule with
    `'post'` never matches a POST request. Never tell the user to change the
    case of a rule that already matches.
-   `mcp_server.method` holds the MCP JSON-RPC method, such as `'tools/call'` or
    `'initialize'`. The public attribute table shows `'tools'` and `'prompts'`,
    but a condition such as `method == 'tools'` never matches.
-   `tool.name` and `tool.annotations.*` are set only on `tools/call` requests,
    from the registered tool spec. On `initialize`, `tools/list`, and other
    methods, the name is empty and every annotation is `false`. An allow rule
    that requires a tool attribute therefore doesn't allow the MCP handshake,
    and the client fails before it calls any tool.
-   Hostnames match exactly. `us-central1-aiplatform.googleapis.com` and
    `us-central1-aiplatform.mtls.googleapis.com` are different hosts, so the
    condition must cover every variant that the agent calls.
-   Resource names have no `registries/` segment. Copy the exact value from the
    audit entry's `metadata.destination.agent_registry.resource_id`, from the
    `name` in Agent Registry list output, or from a clause in the same policy
    that already matches, instead of building it by hand. Resource names use
    the project ID. A project number in its place never matches.
-   Compare the principal separately. The condition can't fix a principal that
    doesn't match the audit entry's `principalSubject`.

## Fix patterns

Keep the clauses that already work, and widen only the part that failed.

Add a missing hostname variant:

```text
destination.unregistered.host in ['us-central1-aiplatform.googleapis.com',
    'us-central1-aiplatform.mtls.googleapis.com']
```

Allow a path prefix and methods on an unregistered host:

```text
destination.unregistered.host == '{host}' &&
destination.unregistered.path.startsWith('{path_prefix}') &&
destination.unregistered.method in ['GET', 'POST']
```

Allow one registered MCP server:

```text
destination.agent_registry.mcp_server.name == '{mcp_server_name}'
```

Allow only read-only tools on that MCP server, and keep the handshake and tool
discovery working:

```text
destination.agent_registry.mcp_server.name == '{mcp_server_name}' &&
(destination.agent_registry.mcp_server.method != 'tools/call' ||
destination.agent_registry.mcp_server.tool.annotations.read_only_hint == true)
```

Allow every registered destination in one registry location. Use this pattern
only if the user explicitly asks for it, because it's broader than the smallest
fix:

```text
destination.is_registered == true &&
destination.agent_registry.location == '{registry_location}'
```

## V1 condition attributes

IAP allow policy conditions read attributes with `api.getAttribute()`, which
takes the attribute name and a default value:

| Attribute | Example |
| :--- | :--- |
| `iap.googleapis.com/mcp.toolName` | `api.getAttribute('iap.googleapis.com/mcp.toolName', '') == '{tool_name}'` |
| `iap.googleapis.com/mcp.resourceName` | `api.getAttribute('iap.googleapis.com/mcp.resourceName', '') == '{resource_name}'` |
| `iap.googleapis.com/mcp.promptName` | `api.getAttribute('iap.googleapis.com/mcp.promptName', '') == '{prompt_name}'` |
| `iap.googleapis.com/mcp.tool.isReadOnly` | `api.getAttribute('iap.googleapis.com/mcp.tool.isReadOnly', false) == true` |
| `iap.googleapis.com/mcp.tool.isDestructive`, `.isIdempotent`, `.isOpenWorld` | Same form as `isReadOnly` |
| `iap.googleapis.com/request.auth.type` | `api.getAttribute('iap.googleapis.com/request.auth.type', '') == 'MCP'` |

Don't mix V1 and V2 attribute names in one condition.
gateway-setup.md 6.9 KB
# Agent Gateway authorization chain

Agent Gateway sends an egress request to IAP for agents only when this chain is
complete:

1.  An authorization policy targets the gateway.
2.  That policy delegates the decision to an authorization extension.
3.  The extension calls `iap.googleapis.com`.

If a link is missing, the extension isn't executed and Cloud Audit Logs has no
IAP entry for the request. Read every link in the project that contains Agent
Gateway.

## Contents

- [Gateway](#gateway): Lines 30-41
- [Authorization policies](#authorization-policies): Lines 43-79
- [Authorization extension](#authorization-extension): Lines 81-103
- [Enforcement mode](#enforcement-mode): Lines 105-117
- [Gateway decision logs](#gateway-decision-logs): Lines 119-145

Sources:
[Set up Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/set-up-agent-gateway.md.txt),
[Delegate authorization](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/delegate-authorization.md.txt),
[Troubleshoot Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-agent-gateway.md.txt),
[Troubleshoot IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-iam-policies-uap.md.txt),
[Monitor Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/monitor-agent-gateway.md.txt),
[Authorization extensions REST reference](https://docs.cloud.google.com/service-extensions/docs/reference/rest/v1/projects.locations.authzExtensions.md.txt).

## Gateway

```bash
gcloud network-services agent-gateways describe {gateway} \
    --location={location} --project={project_id}
```

-   Record the full `name`. Authorization policies must list it exactly.
-   `registries` lists the Agent Registry instances that the gateway uses: at
    most two, and if there are two, one is `global` and the other is regional
    or multi-regional. Look up destinations in them with
    [agent-registry.md](agent-registry.md).

## Authorization policies

```bash
gcloud network-security authz-policies list \
    --location={location} --project={project_id}
gcloud network-security authz-policies describe {authz_policy} \
    --location={location} --project={project_id}
```

The policy that delegates to IAP has these values:

| Field | Expected value |
| :--- | :--- |
| `target.resources` | Contains the gateway's full name |
| `policyProfile` | `REQUEST_AUTHZ` |
| `action` | `CUSTOM` |
| `customProvider.authzExtension.resources` | Contains the authorization extension's full name |

-   If no policy targets the gateway, the extension isn't executed. That's the
    root cause. Print the "Point the authorization policy at the gateway"
    template from [remediation-gateway.md](remediation-gateway.md).
-   If the policy names a different extension than you expect, read that
    extension. A leftover extension can still call IAP, but with another
    `iapPolicyVersion`, so that IAP evaluates the other policy model and can
    deny requests that the intended policies allow, or in `DRY_RUN`, so that
    IAP blocks nothing.
-   The authorization policy is in the same project as the extension.
-   A gateway accepts at most four authorization policies, whatever their
    profile (`REQUEST_AUTHZ` or `CONTENT_AUTHZ`). Custom policies with the
    same profile run in no guaranteed order.
-   Policies with `action: ALLOW` or `action: DENY` are the gateway's own MCP
    rules, and they can deny a request without IAP. They're evaluated after
    the `REQUEST_AUTHZ` policy that delegates to IAP, so IAP has already
    allowed any request that they deny. If `ALLOW` policies target the
    gateway, a request that matches none of them is denied. Without
    `baseProtocolMethodsOption: MATCH_BASE_PROTOCOL_METHODS`, the agent can't
    establish an MCP session.

## Authorization extension

```bash
gcloud service-extensions authz-extensions describe {authz_extension} \
    --location={location} --project={project_id}
```

| Field | Value | Meaning |
| :--- | :--- | :--- |
| `service` | `iap.googleapis.com` | The extension sends decisions to IAP for agents |
| `metadata.iapPolicyVersion` | `V2` | IAP evaluates IAM Unified Access Policies (Access policies) |
| `metadata.iapPolicyVersion` | `V1` | IAP evaluates IAP allow policies |
| `metadata.iamEnforcementMode` | `DRY_RUN` | IAP logs decisions but doesn't block requests |
| `metadata.iamEnforcementMode` | Absent or `ENFORCE` | IAP blocks the requests that it denies |
| `failOpen` | Absent or `false` | If the call to IAP fails or times out, the request fails |
| `failOpen` | `true` | If the call to IAP fails or times out, the request continues without an IAP decision |

-   `iapPolicyVersion` is required. Record it, and read only the matching
    section of [policy-model.md](policy-model.md).
-   If `service` isn't `iap.googleapis.com`, the chain doesn't reach IAP for
    agents. Report that, and stop.
-   The Agent Platform setup guides set `failOpen: false`. If it's `true`,
    report it as a risk, even when it isn't the root cause.

## Enforcement mode

-   **`DRY_RUN`:** IAP writes disallowed requests to Cloud Audit Logs but
    doesn't block them. A 403 in dry run likely comes from the gateway's
    egress proxy, such as its other authorization policies, or from the
    destination. Check the gateway logs in the next section.
-   **Requests pass that should be blocked:** the extension is in dry run, or
    no policy binding covers the gateway's project or the gateway (see
    [policy-model.md](policy-model.md)). To enforce, the user removes
    `iamEnforcementMode: "DRY_RUN"` from the extension and imports it again.
    Print the "Turn on enforcement" template from
    [remediation-gateway.md](remediation-gateway.md) only if the user asks to
    turn on enforcement. It isn't a fix for a denial.

## Gateway decision logs

Agent Gateway writes these logs in dry run too.

```bash
gcloud logging read '
  resource.type="networkservices.googleapis.com/Gateway"
  resource.labels.gateway_type="SECURE_WEB_GATEWAY"
  resource.labels.location="{location}"
  resource.labels.gateway_name="{gateway}"
  httpRequest.status=403
  -httpRequest.requestMethod="CONNECT"' \
  --project={project_id} --freshness=1d --limit=20
```

| Field | Meaning |
| :--- | :--- |
| `httpRequest.requestUrl` | The URL that the agent called. Its hostname must match a registered interface exactly |
| `jsonPayload.authzPolicyInfo.policies.result` | The overall authorization result, `ALLOWED` or `DENIED` |

-   Entries can also include `serviceExtensionsInfo`, which names the
    authorization extension that handled the request.
-   To find hostnames blocked while the agent starts, remove the
    `resource.labels.location`, `resource.labels.gateway_name`, and
    `-httpRequest.requestMethod="CONNECT"` lines.
-   Widen `--freshness` to cover the time of the failure before you conclude
    that no entry exists.
policy-model.md 8.9 KB
# Policy models

The authorization extension's `metadata.iapPolicyVersion` names the model that
IAP evaluates: `V2` for IAM Unified Access Policies (Access policies), `V1` for
IAP allow policies. Read the extension first
([gateway-setup.md](gateway-setup.md)), then use the sections for that version,
plus the section that applies to both versions.

## Contents

- [V2: How Access policies are evaluated](#v2-how-access-policies-are-evaluated): Lines 29-45
- [V2: Read policies and bindings](#v2-read-policies-and-bindings): Lines 47-88
- [V2: Organization policy constraint](#v2-organization-policy-constraint): Lines 90-101
- [V2: Errors from Access policy commands](#v2-errors-from-access-policy-commands): Lines 103-113
- [Both versions: principal access boundary (optional)](#both-versions-principal-access-boundary-optional): Lines 115-131
- [V1: IAP allow policies](#v1-iap-allow-policies): Lines 133-145
- [V1: Scopes](#v1-scopes): Lines 147-165

Sources:
[IAM Unified Access Policies overview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/iam-overview-uap.md.txt),
[Configure IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies-uap.md.txt),
[Manage IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/manage-iam-policies-uap.md.txt),
[Troubleshoot IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-iam-policies-uap.md.txt),
[Troubleshoot Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-agent-gateway.md.txt),
[IAP allow policies overview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/iam-overview.md.txt),
[Configure IAP allow policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies.md.txt),
[Policy bindings REST reference](https://docs.cloud.google.com/iam/docs/reference/rest/v3/projects.locations.policyBindings.md.txt).

## V2: How Access policies are evaluated

-   Access policies take effect when they're bound to the project that
    contains Agent Gateway, or to the gateway itself. Every gateway in that
    project enforces every policy bound to the project.
-   Each rule has an `effect` (`ALLOW` or `DENY`), `principals`, an
    `operation` with the permission `iap.googleapis.com/resources.egressViaIAP`,
    and `conditions` keyed by `iap.googleapis.com` that hold a CEL
    `expression`. The effect applies only when the whole expression is true.
-   `excludedPrincipals` removes principals from a rule even if `principals`
    lists them.
-   Deny rules are evaluated first. If a deny rule's condition is true, the
    request is blocked even when an allow rule also matches.
-   A broader allow rule, for example one bound for the whole project without
    conditions, can grant access that a narrower rule was meant to limit.
-   Policies created in the Google Cloud console are bound to the project
    automatically.

## V2: Read policies and bindings

```bash
gcloud iam access-policies list --location=global --project={project_id}
gcloud iam access-policies describe {policy} \
    --location=global --project={project_id}
gcloud iam policy-bindings search-target-policy-bindings \
    --target=//cloudresourcemanager.googleapis.com/projects/{project_number} \
    --location=global --project={project_id}
```

The target search doesn't return bindings on the gateway. A binding belongs to
the closest Resource Manager resource to its target, so a binding on the
gateway belongs to the gateway's project. List every binding in that project:

```bash
gcloud iam policy-bindings list \
    --location=global --project={project_id} \
    --format="json(name,policy,policyKind,target)"
```

Keep the entries whose `policyKind` is `ACCESS` and whose `target.resource`
exactly equals the project
(`//cloudresourcemanager.googleapis.com/projects/{project_number}`, or the same
with `{project_id}`) or the gateway
(`//networkservices.googleapis.com/projects/{project_id}/locations/{location}/agentGateways/{gateway}`).
Compare the strings yourself instead of with `--filter`. Then read every bound
policy.

-   Read every policy bound to the project or the gateway, not only the one
    that the user names. A deny rule in any bound policy wins.
-   A policy without a binding to the gateway's project or to the gateway isn't
    enforced. Print the "Bind an Access policy to the project" template from
    [remediation-access-policies.md](remediation-access-policies.md).
-   For each rule, check `principals` and `excludedPrincipals` against the
    agent: a `principal://` entry must equal the agent's identifier from the
    audit entry, and a `principalSet://` entry must contain it (see the
    principal set table in
    [topology-agent-gateway.md](topology-agent-gateway.md)). Then compare the
    condition with the request, using [cel-attributes.md](cel-attributes.md).
-   If no rule allows the agent, print the "Change Access policy rules"
    template, or "Create an Access policy" if the project has no policy.

## V2: Organization policy constraint

```bash
gcloud org-policies describe iam.managed.disableAccessPolicyBinding \
    --project={project_id} --effective
```

-   While this managed constraint is enforced, Access policies can't be bound
    to the project. It's enforced by default in new organizations.
-   If it's enforced and the binding is missing, the fix has two steps: the
    user overrides the constraint for the project, then creates the binding.
    Print both templates in that order.

## V2: Errors from Access policy commands

| Error | Meaning | Fix |
| :--- | :--- | :--- |
| `POLICY_NOT_FOUND` or 404 | The policy name is wrong | List the policies and copy the name |
| `TOO_MANY_ACCESS_POLICY_BINDINGS_PER_TARGET` | The project has too many bindings | Consolidate rules into fewer policies, and delete unused bindings |
| `TOO_MANY_ACCESS_POLICY_BINDINGS_TO_POLICY` | One policy has too many bindings | Bind it at a broader scope and narrow it with CEL conditions |
| `TOO_MANY_CONDITIONS` | A rule has too many conditions | Combine them with `&&`, `\|\|`, or `in`, or split the rule |
| 412 or `ABORTED` | The etag is out of date | Read the policy again and use the new etag |
| The last rule can't be deleted | A policy needs at least one rule | Delete the policy instead |
| A policy can't be deleted | It still has bindings | Delete its bindings first |

## Both versions: principal access boundary (optional)

Check this when an Access policy (V2) or an IAP allow policy (V1) allows the
agent but IAP still denies the request. Agent Gateway can use IAP to enforce
principal access boundary policies with either model. Principal access boundary
policies take precedence over IAM allow policies: the request fails if an
active boundary policy leaves the destination out of the agent's scope.

```bash
gcloud iam principal-access-boundary-policies list \
    --organization={org_id} --location=global
```

For each policy, check whether `details.rules[].resources[]` puts the
destination in the agent's scope. If a policy leaves it out, report the policy
as a likely cause, and ask the user to confirm that it's bound to the agent's
principal set.

## V1: IAP allow policies

-   IAP allow policies grant `roles/iap.egressor` (IAP-secured Egressor) on
    Agent Registry resources. Members are `principal://` or `principalSet://`
    identifiers.
-   Never grant `roles/iap.tunnelResourceAccessor` (IAP-secured Tunnel User).
    It grants access to IAP TCP forwarding tunnels, not egress.
-   IAP allow policies apply only to registered resources. Binding a policy to
    an unregistered resource fails with `NOT_FOUND`. The public troubleshooting
    guide covers unregistered endpoints with Access policies.
-   Target resources by the IDs that Agent Registry assigns (see
    [agent-registry.md](agent-registry.md)), never by URN identifiers.
-   A policy on a regional registry applies only to resources in that region.

## V1: Scopes

| Scope | Read command |
| :--- | :--- |
| Registry-wide | `gcloud iap web get-iam-policy --resource-type=agent-registry --region={registry_location} --project={project_id}` |
| One MCP server | Add `--mcp-server={mcp_server_id}` |
| One endpoint | Add `--endpoint={endpoint_id}` |
| One agent | Add `--agent={agent_id}` |

-   IAP allow policies follow the IAM resource hierarchy: a resource inherits
    the registry-wide policy, and its own policy adds grants to it. A grant at
    either level gives the agent access, so read both.
-   A response with an `etag` but no `bindings` means that no policy exists at
    that scope.
-   A binding with a `condition` grants access only when the expression is
    true. V1 conditions use `api.getAttribute()`; see
    [cel-attributes.md](cel-attributes.md).
-   To fix a missing grant, print the "Grant roles/iap.egressor" template from
    [remediation-registry.md](remediation-registry.md).
prerequisites.md 4.2 KB
# Prerequisites

Set up the environment before you run any check.

## Google Cloud CLI

1.  Install the Google Cloud CLI by following the
    [installation guide](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt).
2.  Update the installed components, so that the `agent-registry`,
    `iam access-policies`, and `iap web` command groups are current:

    ```bash
    gcloud components update
    ```

    The commands in this skill were checked against Google Cloud CLI 588.0.0.

3.  Authenticate and select the project that contains the agent:

    ```bash
    gcloud auth login
    gcloud config set project {project_id}
    ```

Every command in this skill also passes `--project` explicitly, so a different
active configuration can't send a read to the wrong project. If Agent Gateway
runs in a different project from the agent, use the gateway's project ID for
gateway, authorization, Access policy, and IAP audit log reads.

## APIs

A project that already runs Agent Gateway normally has these APIs enabled. The
diagnosis never enables an API. If a read fails because an API is disabled,
print the "Enable an API" template from
[remediation-setup.md](remediation-setup.md) for the user.

| API | Used for |
| :--- | :--- |
| `iap.googleapis.com` | IAP for agents decisions and V1 IAP allow policies |
| `iam.googleapis.com` | Access policies and policy bindings |
| `networkservices.googleapis.com` | Agent Gateway and its authorization extension |
| `networksecurity.googleapis.com` | Authorization policies |
| `agentregistry.googleapis.com` | Agent Registry resources |
| `aiplatform.googleapis.com` | Agent Runtime |
| `logging.googleapis.com` | IAP audit entries, gateway logs, and agent logs |

## Read-only roles

Ask the user to confirm that the account running the checks has one of these
role sets on the project. Use the default unless the organization requires
narrower grants.

| Option | Roles | Notes |
| :--- | :--- | :--- |
| Default | `roles/iam.securityAuditor`, `roles/iam.accessPolicyViewer`, `roles/agentregistry.viewer` | Security Auditor covers the gateway, authorization policy and extension, V1 IAP allow policies, Data Access audit logs, and the principal access boundary list. The other two cover Access policies and Agent Registry |
| Granular | `roles/logging.privateLogViewer`, `roles/compute.networkViewer`, `roles/iam.securityReviewer`, `roles/iam.accessPolicyViewer`, `roles/agentregistry.viewer`, `roles/orgpolicy.policyViewer` | Same coverage with narrower grants |

Neither option grants `resourcemanager.projects.searchPolicyBindings`, which
the policy binding search on the project needs (see
[policy-model.md](policy-model.md)). Also ask for a custom role with only that
permission on the project, instead of a broad basic role such as Viewer.

The optional principal access boundary check lists policies at the organization
level. It needs `roles/iam.securityAuditor` or
`roles/iam.principalAccessBoundaryViewer` granted on the organization.

If a read returns `PERMISSION_DENIED`, stop and report which role from this
table is missing. Don't try other commands to work around it, because partial
evidence leads to a wrong root cause.

Fixes need admin roles. Each remediation template names the role that the user
running it needs.

## Billing

The project must have an active billing account attached. The diagnosis itself
creates no resources. Enabling Data Access audit logs adds log volume that might
be charged; see
[Google Cloud Observability pricing](https://cloud.google.com/products/observability/pricing).

## Region

Use the location where the agent, Agent Gateway, and Agent Registry run. If the
user doesn't know it, start with `us-central1`, the region in the public
examples, and confirm it against the agent's resource name. Access policies and
policy bindings always use `--location=global`. An Agent Registry instance can
be regional, multi-regional, or `global`. For availability, see
[Google Cloud locations](https://cloud.google.com/about/locations).

## Cleanup

The diagnosis creates nothing, so there's nothing to delete. If the user turns
on Data Access audit logs only for this investigation, they can remove the
`iap.googleapis.com` entry from `auditConfigs` afterward with the same
read-modify-write steps that added it.
remediation-access-policies.md 5.8 KB
# Remediation: Access policies (V2)

These templates change resources. Print them for the user to run; never run
them.

## Contents

- [If a DENY rule causes the denial](#if-a-deny-rule-causes-the-denial): Lines 15-22
- [Override the organization policy constraint](#override-the-organization-policy-constraint): Lines 24-49
- [Bind an Access policy to the project](#bind-an-access-policy-to-the-project): Lines 51-68
- [Create an Access policy](#create-an-access-policy): Lines 70-108
- [Change Access policy rules](#change-access-policy-rules): Lines 110-145
- [Wait times](#wait-times): Lines 147-153

## If a DENY rule causes the denial

Treat the block as possibly deliberate, because deny rules are how
administrators put guardrails on every agent. Name the policy and the rule,
quote its `description`, and say that keeping the block is a valid outcome.
Print a change only as an option for the rule's owner to approve. The narrowest
one adds the agent's exact principal to the rule's `excludedPrincipals`;
changing the condition affects every agent.

## Override the organization policy constraint

Role: Organization Policy Administrator (`roles/orgpolicy.policyAdmin`).

This turns off an organization guardrail for the project, so tell the user to
get approval from the organization policy owner before running it. Print it
only when the constraint blocks the binding that the fix needs.

Write `policy.yaml`:

```yaml
name: projects/{project_id}/policies/iam.managed.disableAccessPolicyBinding
spec:
  rules:
  - enforce: false
```

```bash
gcloud org-policies set-policy policy.yaml
gcloud org-policies describe iam.managed.disableAccessPolicyBinding \
    --project={project_id} --effective
```

The second command confirms the override. Then print the binding template.
Source:
[Create and manage organization policies](https://docs.cloud.google.com/organization-policy/create-organization-policies.md.txt).

## Bind an Access policy to the project

Roles: Access Policy Admin (`roles/iam.accessPolicyAdmin`) and Project IAM
Admin (`roles/resourcemanager.projectIamAdmin`).

`{policy_name}` is the policy's full `name` from
`gcloud iam access-policies describe`.

```bash
gcloud iam policy-bindings create {binding_id} \
    --policy={policy_name} \
    --target-resource=//cloudresourcemanager.googleapis.com/projects/{project_number} \
    --policy-kind=access --location=global --project={project_id}
```

If it fails because of the organization policy constraint, print the override
template first. Source:
[Configure IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies-uap.md.txt).

## Create an Access policy

Role: Access Policy Admin (`roles/iam.accessPolicyAdmin`).

Write `rules.json`. Copy `{principal}` from the audit entry's
`principalSubject`, and build `{cel_expression}` from
[cel-attributes.md](cel-attributes.md).

```json
[
  {
    "description": "{rule_description}",
    "effect": "ALLOW",
    "principals": ["{principal}"],
    "operation": {
      "permissions": ["iap.googleapis.com/resources.egressViaIAP"]
    },
    "conditions": {
      "iap.googleapis.com": {
        "expression": "{cel_expression}"
      }
    }
  }
]
```

```bash
gcloud iam access-policies create {policy} --details-rules=rules.json \
    --location=global --project={project_id} --validate-only
gcloud iam access-policies create {policy} --details-rules=rules.json \
    --location=global --project={project_id}
```

The first command only validates and creates nothing. When the rules are
valid, gcloud prints `done` for the operation and then reports `NOT_FOUND` for
the policy, because it reads back a policy that validation didn't create. Tell
the user to expect this. A failed operation with `INVALID_ARGUMENT` means the
rules need fixing. Then print the binding template. Source:
[Configure IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies-uap.md.txt).

## Change Access policy rules

Role: Access Policy Admin (`roles/iam.accessPolicyAdmin`).

`--details-rules` replaces the policy's whole rule list, so the file must
contain every rule.

1.  Save the policy, and note its `etag`:

    ```bash
    gcloud iam access-policies describe {policy} \
        --location=global --project={project_id} --format=json > policy.json
    ```

2.  Extract the rules and the etag, then change only the rule that failed in
    `rules.json`, for example by adding a hostname variant or a principal.
    Keep the other rules unchanged:

    ```bash
    jq '.details.rules' policy.json > rules.json
    jq -r '.etag' policy.json
    ```

    Without `jq`, copy the `details.rules` array into `rules.json` by hand.
3.  Validate, then apply:

    ```bash
    gcloud iam access-policies update {policy} --details-rules=rules.json \
        --etag={etag} --location=global --project={project_id} --validate-only
    gcloud iam access-policies update {policy} --details-rules=rules.json \
        --etag={etag} --location=global --project={project_id}
    ```

A 412 or `ABORTED` error means the etag is out of date. Start again from step
1. Source:
[Manage IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/manage-iam-policies-uap.md.txt).

## Wait times

| Change | Wait |
| :--- | :--- |
| Organization policy | Up to 15 minutes ([Apply organization policies](https://docs.cloud.google.com/organization-policy/apply-policies.md.txt)) |
| Principal set membership | A few minutes ([Troubleshoot Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-agent-gateway.md.txt)) |
| Access policies and bindings | No published figure, and a change can take a few minutes to apply. Retest after a few minutes, and look for a new audit entry |
remediation-gateway.md 3.5 KB
# Remediation: gateway authorization chain

These templates change resources. Print them for the user to run; never run
them.

## Point the authorization policy at the gateway

Roles: Network Security Admin (`roles/networksecurity.admin`), plus the
`networkservices.agentGateways.use` permission on the gateway.

`import` replaces the whole authorization policy, so start from the current
policy when one exists. The authorization policy must be in the same project
as the extension.

1.  Save the current policy:

    ```bash
    gcloud network-security authz-policies describe {authz_policy} \
        --location={location} --project={project_id} --format=yaml \
        > authz-policy.yaml
    ```

2.  In `authz-policy.yaml`, add this entry under `target.resources`, and keep
    the existing entries. Delete the `createTime` and `updateTime` lines,
    because `import` rejects output-only fields. Keep every other field.

    ```yaml
      - "projects/{project_id}/locations/{location}/agentGateways/{gateway}"
    ```

    If the policy calls the wrong extension, replace the entry under
    `customProvider.authzExtension.resources` with
    `projects/{project_id}/locations/{location}/authzExtensions/{authz_extension}`
    instead. If the new extension enforces and the old one ran in dry run,
    this turns on enforcement, so give the warning from
    [Turn on enforcement](#turn-on-enforcement).

    If no authorization policy exists yet, write the whole file instead:

    ```yaml
    name: {authz_policy}
    target:
      resources:
      - "projects/{project_id}/locations/{location}/agentGateways/{gateway}"
    policyProfile: REQUEST_AUTHZ
    action: CUSTOM
    customProvider:
      authzExtension:
        resources:
        - "projects/{project_id}/locations/{location}/authzExtensions/{authz_extension}"
    ```

3.  Import it:

    ```bash
    gcloud network-security authz-policies import {authz_policy} \
        --source=authz-policy.yaml --location={location} --project={project_id}
    ```

A gateway accepts at most four custom authorization policies. Source:
[Delegate authorization](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/delegate-authorization.md.txt).

## Turn on enforcement

Role: Service Extensions Admin (`roles/networkservices.serviceExtensionsAdmin`).

Print this only if the user asks to turn on enforcement. It isn't a fix for a
denial.

Before enforcing, ask the user to review the disallowed requests that IAP
logged in dry run. Enforcement blocks every request that the policies don't
allow, including the Google services that the agent calls at startup.

1.  Save the extension:

    ```bash
    gcloud service-extensions authz-extensions describe {authz_extension} \
        --location={location} --project={project_id} --format=yaml \
        > authz-extension.yaml
    ```

2.  In `authz-extension.yaml`, delete the `iamEnforcementMode: "DRY_RUN"` line
    under `metadata`. Also delete the `createTime` and `updateTime` lines,
    because `import` rejects output-only fields. Keep every other field.
3.  Import it:

    ```bash
    gcloud service-extensions authz-extensions import {authz_extension} \
        --source=authz-extension.yaml --location={location} \
        --project={project_id}
    ```

Source:
[Troubleshoot IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-iam-policies-uap.md.txt).

## Wait time

A gateway chain change has no published figure and can take a few minutes to
apply. Retest after a few minutes, and look for a new audit entry.
remediation-registry.md 5.4 KB
# Remediation: IAP allow policies (V1) and Agent Registry

These templates change resources. Print them for the user to run; never run
them.

## Grant roles/iap.egressor

For IAP allow policies (V1). Role: IAP Policy Admin (`roles/iap.admin`).

This adds one binding and keeps the others. A resource gets the registry-wide
grants plus its own, so grant on the destination: the agent gets only the
access that the logs show it needs. A registry-wide grant (no resource flag)
covers every registered resource in `{registry_location}`. Print it only if the
user wants that scope, state the scope in the report, and offer a `--condition`
that narrows it (see
[V1 condition attributes](cel-attributes.md#v1-condition-attributes)).

```bash
gcloud iap web add-iam-policy-binding \
    --resource-type=agent-registry --region={registry_location} \
    {resource_flag} --member={principal} --role=roles/iap.egressor \
    --project={project_id}
```

-   `{resource_flag}`: `--mcp-server={mcp_server_id}`,
    `--endpoint={endpoint_id}`, or `--agent={agent_id}`, with the ID from the
    audit entry's `resource_id`. Leave it out for a registry-wide grant.
-   For a conditional grant, add
    `--condition=expression={cel_expression},title={title}`. If the expression
    contains commas, change the separator:
    `--condition=^:^title={title}:expression={cel_expression}`.

Source:
[Configure IAP allow policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies.md.txt).

## Register a destination in Agent Registry

Role: Agent Registry API Editor (`roles/agentregistry.editor`).

Register the endpoint in a registry that the gateway uses, in a region or
`global`, not the `us` or `eu` multi-region. `{protocol}` is `http-json`,
`grpc`, or `jsonrpc`.

After registration, `destination.unregistered.*` clauses in allow and deny
rules no longer match that host:

-   Before you print this template, search the bound Access policies for the
    hostname. For each clause that names it, also print the matching change to
    a `destination.agent_registry.*` condition, with "Change Access policy
    rules" in [remediation-access-policies.md](remediation-access-policies.md).
-   With IAP allow policies (V1), if no registry-wide `roles/iap.egressor`
    grant covers the agent, also print the "Grant roles/iap.egressor"
    template, so that the agent can reach the new resource.

```bash
gcloud agent-registry services create {service_id} \
    --location={registry_location} --project={project_id} \
    --display-name="{display_name}" --endpoint-spec-type=no-spec \
    --interfaces=url={url},protocolBinding={protocol}
```

To group several URLs into one endpoint and one IAP policy binding, repeat
`--interfaces`. For MCP servers, follow
[Register MCP servers](https://docs.cloud.google.com/agent-registry/register-mcp-servers.md.txt).
Source:
[Register endpoints](https://docs.cloud.google.com/agent-registry/register-endpoints.md.txt).

## Add a hostname variant to a registered service

Role: Agent Registry API Editor (`roles/agentregistry.editor`).

This adds an interface to the service that the endpoint was registered from,
so existing policies on that endpoint also cover the new URL.

After the update, `destination.unregistered.*` clauses in allow and deny rules
no longer match the new hostname:

-   Before you print this template, search the bound Access policies for the
    hostname. For each clause that names it, also print the matching change to
    a `destination.agent_registry.*` condition, with "Change Access policy
    rules" in [remediation-access-policies.md](remediation-access-policies.md).
-   With IAP allow policies (V1), if no `roles/iap.egressor` grant on the
    endpoint or registry-wide gives the agent access, also print the "Grant
    roles/iap.egressor" template.

```bash
gcloud agent-registry services update {service_id} \
    --location={registry_location} --project={project_id} \
    --add-interfaces=protocolBinding={protocol},url={url}
```

For all flags, see `gcloud agent-registry services update --help`.

## Add a tool to a registered MCP server

Role: Agent Registry API Editor (`roles/agentregistry.editor`).

Use this only for an MCP server registered with
`--mcp-server-spec-type=tool-spec`, because the spec type can't change after
registration. Servers that GKE or Cloud Run registered automatically have a
read-only tool list that comes from the server, so this template doesn't apply
to them.

The update replaces the whole spec, so `toolspec.json` must list every tool that
the server provides, not only the missing one. Build it from the server's own
`tools/list` response, which has the same format.

```bash
gcloud agent-registry services update {service_id} \
    --location={registry_location} --project={project_id} \
    --mcp-server-spec-content=toolspec.json
```

`{service_id}` is the name that the server was registered with (see
`gcloud agent-registry services list`), not the generated MCP server ID. The
spec is limited to 10 KB. Source:
[Register MCP servers](https://docs.cloud.google.com/agent-registry/register-mcp-servers.md.txt).

## Wait times

| Change | Wait |
| :--- | :--- |
| IAP allow policy (V1) binding | Typically 2 minutes, sometimes 7 minutes or longer ([Access change propagation](https://docs.cloud.google.com/iam/docs/access-change-propagation.md.txt)) |
| Agent Registry | No published figure, and a change can take a few minutes to apply. Retest after a few minutes, and look for a new audit entry |
remediation-setup.md 2.1 KB
# Remediation: APIs and audit logs

These templates change resources. Print them for the user to run; never run
them.

## Enable an API

Role: Service Usage Admin (`roles/serviceusage.serviceUsageAdmin`).

```bash
gcloud services enable {api} --project={project_id}
```

Source:
[Enable and disable services](https://docs.cloud.google.com/service-usage/docs/enable-disable.md.txt).

## Enable Data Access audit logs for IAP

Role: the `resourcemanager.projects.setIamPolicy` permission on the project,
for example through Project IAM Admin (`roles/resourcemanager.projectIamAdmin`).

1.  Save the project's IAM policy:

    ```bash
    gcloud projects get-iam-policy {project_id} --format=json > policy.json
    ```

2.  In `policy.json`, turn on all three Data Access log types for IAP. Don't
    change `bindings` or `etag`. This is the entry:

    ```json
    {
      "service": "iap.googleapis.com",
      "auditLogConfigs": [
        { "logType": "ADMIN_READ" },
        { "logType": "DATA_READ" },
        { "logType": "DATA_WRITE" }
      ]
    }
    ```

    If `auditConfigs` already has an `iap.googleapis.com` entry, add the
    missing `logType` values to it. Otherwise append this object, and create
    the list if it's missing. Don't edit an `allServices` entry, because that
    turns the log types on for every service. Never add a second
    `auditConfigs` key or a second `iap.googleapis.com` entry.

3.  Write the policy back. This replaces the project's whole IAM policy, so
    the file must still contain every binding. If the command fails because
    the policy changed after step 1, start again from step 1.

    ```bash
    gcloud projects set-iam-policy {project_id} policy.json
    ```

4.  Reproduce the failure, then run the IAP decision query in
    [audit-logs.md](audit-logs.md).

Data Access audit logs add log volume, which might be charged. Source:
[Configure Data Access audit logs](https://docs.cloud.google.com/logging/docs/audit/configure-data-access.md.txt).

## Wait time

An audit configuration change has no published figure and can take a few
minutes to apply. Retest after a few minutes, and look for a new audit entry.
topology-agent-gateway.md 7.5 KB
# Topology: Agent Runtime with Agent Gateway

This skill supports one topology: an Agent Runtime (Reasoning Engine) agent that
runs with agent identity and sends outbound requests through Agent Gateway,
where IAP for agents makes the authorization decision through an authorization
extension.

## Contents

- [Request path](#request-path): Lines 23-35
- [Agent principal](#agent-principal): Lines 37-68
- [Agent log query](#agent-log-query): Lines 70-102
- [403 errors during startup](#403-errors-during-startup): Lines 104-128
- [Resource names](#resource-names): Lines 130-142
- [Unsupported topologies](#unsupported-topologies): Lines 144-151

Sources:
[Troubleshoot Agent Gateway](https://docs.cloud.google.com/gemini-enterprise-agent-platform/troubleshooting/troubleshoot-agent-gateway.md.txt),
[Use Agent Identity with Agent Runtime](https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale/runtime/agent-identity.md.txt),
[Configure IAM Unified Access Policies](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/policies/configure-iam-policies-uap.md.txt),
[IAP roles and permissions](https://docs.cloud.google.com/iam/docs/roles-permissions/iap.md.txt).

## Request path

Agent Runtime agent -> Agent Gateway -> authorization policy -> authorization
extension (`iap.googleapis.com`) -> IAP evaluates Access policies (V2) or IAP
allow policies (V1) -> destination.

Egress is default-deny. A request succeeds only if every layer allows it: the
agent identity has the IAP `egressViaIAP` permission on the destination
(directly or through a principal set), an authorization policy targets the
gateway, and every other authorization engine on the gateway allows the
request. Access policies (V2) check `iap.resources.egressViaIAP`. IAP allow
policies (V1) check `iap.webServiceVersions.egressViaIAP`, which
`roles/iap.egressor` grants.

## Agent principal

```text
principal://agents.global.org-{org_id}.system.id.goog/resources/aiplatform/projects/{project_number}/locations/{location}/reasoningEngines/{engine_id}
```

-   A project without an organization uses the trust domain
    `agents.global.proj-{project_number}.system.id.goog`.
-   The path contains the project number, not the project ID.
-   Copy the value from `protoPayload.authenticationInfo.principalSubject` in
    the IAP audit entry instead of building it by hand. The field can also
    hold the agent's SPIFFE ID. IAM policies take the `principal://`
    identifier instead, so in that case fill in the format above with values
    from command output.
-   Identifiers in URN format (`urn:agent:...`) are used only for inventory and
    catalog lookup. IAM policies never use them.
-   An agent deployed without agent identity runs as a service account. That
    case is outside this skill's topology; say so.

Principal sets for groups of Agent Runtime agents:

| Scope | Principal set |
| :--- | :--- |
| All agents in a project (organization) | `principalSet://agents.global.org-{org_id}.system.id.goog/attribute.platformContainer/aiplatform/projects/{project_number}` |
| All agents in a project (no organization) | `principalSet://agents.global.proj-{project_number}.system.id.goog/attribute.platformContainer/aiplatform/projects/{project_number}` |
| All Agent Runtime agents in the organization | `principalSet://agents.global.org-{org_id}.system.id.goog/attribute.platform/aiplatform` |

A rule that uses a principal set can still miss the agent. A newly added
identity can take a few minutes to be recognized as a member, and an identity
that lacks the attributes that the set requires can be silently excluded. To
test, the user grants the agent's exact `principal://` identifier directly. If
that works, the cause is the principal set.

## Agent log query

Confirm the error text in the agent's own logs:

```bash
gcloud logging read '
  resource.type="aiplatform.googleapis.com/ReasoningEngine"
  resource.labels.location="{location}"
  resource.labels.reasoning_engine_id="{engine_id}"
  textPayload:"403"' \
  --project={project_id} --freshness=1d --limit=20
```

-   `Egress request is not authorized` in `textPayload` means Agent Gateway
    rejected the egress request. The full message looks like this:

    ```text
    {"code": 403, "message": "403 Forbidden. {'message': 'Egress request is not authorized.', 'status': 'Forbidden'}"}
    ```

    A `streamQuery` call returns the same denial as a stream event. When the
    agent's model call is denied, this event arrives before any tool runs:

    ```text
    {"errorCode": "PERMISSION_DENIED", "errorMessage": "Egress request is not authorized. If Identity-Aware Proxy (IAP) or Agent Gateway egress security is enabled, verify your IAM bindings ..."}
    ```

-   A 403 with any other text might mean that the destination rejected the
    call directly, rather than Agent Gateway. Check the gateway 403 query in
    [gateway-setup.md](gateway-setup.md) before you call it out of scope.

-   Set `--freshness` to cover the time of the failure, for example
    `--freshness=7d` for an older incident.

## 403 errors during startup

When IAP enforces, it also blocks calls that the agent makes to Google services
at startup, unless those hostnames are registered and the agent has the IAP
`egressViaIAP` permission on them. Find the blocked hostnames with the
gateway 403 query in [gateway-setup.md](gateway-setup.md), without the
location, gateway name, and CONNECT lines. Hostnames that commonly need
registration:

-   `https://{location}-aiplatform.mtls.googleapis.com` (Agent Runtime and
    Sessions)
-   `https://cloudresourcemanager.mtls.googleapis.com` and
    `https://cloudresourcemanager.mtls.googleapis.com/`
-   `https://telemetry.mtls.googleapis.com/` (if Google Cloud Observability is
    on)
-   `https://logging.googleapis.com/` (if Cloud Logging is on)
-   `https://monitoring.googleapis.com/` and `https://monitoring.mtls.googleapis.com/`
-   `https://cloudtrace.googleapis.com/` and `https://cloudtrace.mtls.googleapis.com/`
-   `https://secretmanager.googleapis.com/` and
    `https://secretmanager.mtls.googleapis.com/`

Startup errors such as `Failed to convert project number to project ID` in the
`aiplatform.googleapis.com/reasoning_engine_stderr` log aren't IAP denials. They
mean the agent identity lacks basic roles. Route them to
`agent-platform-troubleshooting`.

## Resource names

| Resource | Name format |
| :--- | :--- |
| Agent Gateway | `projects/{project_id}/locations/{location}/agentGateways/{gateway}` |
| Authorization extension | `projects/{project_id}/locations/{location}/authzExtensions/{authz_extension}` |
| Agent Registry instance | `//agentregistry.googleapis.com/projects/{project_id}/locations/{registry_location}` |
| Policy binding target (project) | `//cloudresourcemanager.googleapis.com/projects/{project_number}` |
| Policy binding target (gateway) | `//networkservices.googleapis.com/projects/{project_id}/locations/{location}/agentGateways/{gateway}` |

Agent Runtime agents are regional and are usually registered in a regional
registry in their deployment region. An agent in another project must be
registered in the registry of the project where Agent Gateway runs.

## Unsupported topologies

Gemini Enterprise agents, Cloud Run agents, agents that use Workload Identity
Federation principals, and agents that don't send traffic through Agent Gateway
aren't covered yet. Say that the topology isn't supported, and for general Agent
Platform troubleshooting name `agent-platform-troubleshooting`. Don't adapt this
skill's log filters or principal formats to them, because they differ by
platform.

License (Apache-2.0)

View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE