Architecture and request sequence
Read the architecture as text
- Agent request: Tool, tenant and target
- Trusted identity: Verified subject and actor
- Policy gateway: Deny unless all checks pass
- Resource boundary: Known owned object
- Provider adapter: Narrow read operation
- Agent request → Policy gateway: requested action
- Trusted identity → Policy gateway: verified claims
- Policy gateway → Resource boundary: authorized scope
- Resource boundary → Provider adapter: resolved target
Read the sequence as text
- Agent → Gateway: Request worker health
- Gateway → Identity: Obtain trusted claims
- Gateway → Provider: Read authorized target
- Provider → Gateway: Return health result
- Gateway → Agent: Return result and audit outcome
Separate authentication from policy evaluation
Authentication establishes who or what presented a request and whether its credentials are valid. Authorization decides whether that established identity may perform the requested operation on the specified resource. The teaching module starts at the second boundary: Claims is a fixture object supplied by trusted code. It does not parse, sign or verify access tokens and must not be exposed directly as a network authentication mechanism.
The policy considers issuer, audience, subject, actor, tenant, scopes and expiry. Subject represents the delegated user in this example; actor identifies the incident agent acting on that user's behalf. Keeping both visible supports an audit question that a shared service account cannot answer alone: which agent used which person's authority for this request? The exact claim format in a real system depends on its identity provider and delegation protocol.
Bind credentials to the intended service
A credential valid for one API should not automatically authorize another. MCP security guidance discusses audience validation and rejects token passthrough as a safe shortcut. Our original gateway uses a fixed expected audience and issuer in fixtures to make that boundary testable. It does not implement MCP or claim compliance with an authorization specification.
The production authentication layer must verify signatures, issuer trust, expiry and protocol requirements using maintained components before constructing trusted claims. The downstream adapter should obtain credentials intended for its own resource rather than forwarding an arbitrary incoming token. Avoid putting a broad token into a model-visible tool argument. If the model can choose which credential to use, it can accidentally cross the very boundary the gateway was meant to enforce.
Capacity and failure assumptions
Assume a read-only incident trial with fifty concurrent investigations, each making four health queries. That creates two hundred potential provider calls before retries. The gateway should impose concurrency and rate limits independently of model token limits. A cheap authorization check does not make the downstream API unlimited, and a provider outage should not encourage the agent to switch to a more privileged tool as a workaround.
The reference runs synchronously in one process with an in-memory audit list. It is designed for policy tests, not traffic handling or durable auditing. A hosted design needs authenticated ingress, a policy service or library, a resource resolver, a credential broker and governed audit storage. Keep denial behavior predictable when dependencies fail. If identity verification or policy data is unavailable, do not reinterpret that outage as permission to continue.
Test the boundary before adding autonomy
The original example allows one synthetic health read and denies a restart request, reporting one provider call and one denial. Its tests cover wrong issuer, wrong audience, expired claims, cross-tenant access, missing scope, wrong actor, arbitrary target and write-tool attempts. Every denial test verifies that the provider call count remains zero.
These assertions show a meaningful local authorization boundary while leaving authentication, revocation and transport security explicitly outside scope. Use evaluation foundations to test whether the assistant selects appropriate tools, but keep those quality checks separate from gateway enforcement. The system should remain safe when the assistant chooses incorrectly. That is the practical reason to place identity and authority in application infrastructure rather than relying on the model's interpretation of a prompt.