<!-- SPDX-License-Identifier: Apache-2.0 -->
**Status:** stable · **Owner:** Developer Relations · **License:** Apache-2.0

# Playbook 4 — Agent-Gateway + KYE

> You run agents behind a cloud **agent gateway** — AWS Bedrock AgentCore, a
> Cloudflare Agents deployment, an API gateway in front of your own runtime.
> The gateway already makes a *routing/admission* decision. This playbook shows
> how to **wrap that decision with KYE authority evidence** so the gateway's
> verdict becomes a replay-verifiable authority record.

## 1. The problem

A cloud agent-gateway decides *whether to admit and route* a request — quota,
auth token, model selection, guardrail pass. That is an operational decision. It
is **not** a record of *who was authorised to act on whose behalf, for what
purpose*, and it is not verifiable from public keys by a third party.

KYE complements the gateway, it does not replace it. The gateway keeps doing its
job; KYE captures the *authority* dimension the gateway was never designed to
carry, and seals it as evidence. This is an **integration**, not a "KYE vs your
gateway" choice.

## 2. The pattern

```
inbound agent request
        │
        ▼
  cloud agent-gateway decision        (admit / route / guardrail — vendor's job)
        │  gateway verdict + metadata
        ▼
  KYE binding at task-start           → kye.agent.governance.v1
        │  (agent_id, purpose, scope, mcp_allow_list)
        ▼
  for each privileged step the agent takes inside the gateway session:
        │  emit tool-call + decision-map → kye.evidence.*.v1
        ▼
  carry the gateway verdict into the evidence  (sealed alongside KYE's outcome,
        │                                       so the gateway decision is replayable)
        ▼
  KYE completion at task-end          → kye.agent.completion.v1
```

The key move is the **carry**: the gateway's native verdict (the AgentCore
admission result, the Cloudflare Agents decision, your API-gateway response) is
recorded *inside* the KYE evidence, exactly like a policy-engine verdict is in
[Playbook 3](./policy-resolver-integration.md). The gateway decision becomes one
more sealed input the Evidence Pack can replay, not a black box.

### Where the wrap goes

| Gateway | KYE binding goes… | The verdict you carry |
|---|---|---|
| AWS Bedrock AgentCore | at session start, before the agent loop | the AgentCore gateway/identity decision |
| Cloudflare Agents | in the Worker entry, before tool dispatch | the Agents routing/guardrail result |
| Your API gateway | in the handler, after admission | the gateway's auth + routing response |

In every case the gateway runs first and unchanged; KYE wraps the session and
seals the verdict.

## 3. The public artefacts

This is the [`govern-your-agent`](./govern-your-agent.md) emission pattern with
the gateway verdict added as a carried input. The envelope shapes are the public
agent-governance examples:

- Binding → [`governance-content-author-1.json`](../../examples/agent-governance/governance-content-author-1.json)
  (`kye.agent.governance.v1`)
- Completion → [`completion-content-author-1.json`](../../examples/agent-governance/completion-content-author-1.json)
  (`kye.agent.completion.v1`)

Carrying a third-party verdict into the evidence reuses the same
`records_raw_*_verdict` discipline shown in the
[policy-engine adapters](../../examples/policy-engine-adapters/) — the gateway
decision is sealed, not summarised.

The runnable version is the
[`agentcore-adapter`](../agent-dev-kit-templates/agentcore-adapter/) starter
template, which wraps a mocked AgentCore-style gateway verdict end-to-end.

## 4. What stays KYE-side

This playbook discloses the **integration pattern** and the public envelope
shapes. How the carried gateway verdict is canonicalised and sealed into a
Replay-Proof™ Evidence Pack is patent-track and not disclosed here. Your code
captures the gateway verdict and emits the public envelopes; the KYE Reference
Gateway™ (or the SDK's local signer) seals them.

## Next

- Back to [Playbook 1 — govern-your-agent](./govern-your-agent.md) for the base
  emission pattern.
- Scaffold it: [`agentcore-adapter` template](../agent-dev-kit-templates/agentcore-adapter/).
