Docs menuAWS AgentCore Policy

Docs Integrations

AWS AgentCore Policy

Seal the tool-call decisions AWS AgentCore Policy makes in the same audit log as Runback's own, so your evidence pack and the offline verifier cover them. About twenty minutes in your AWS account.

If your agents call tools through an AWS AgentCore Gateway with a policy engine attached, AWS decides whether each call may run. This connector copies each of those decisions into Runback, where it is sealed in your audit log next to the decisions Runback makes itself.

Each one is marked as decided by AWS AgentCore, sealed on receipt by Runback. Runback never presents it as its own decision. It also does not check the decision with AWS: it seals what your forwarder sends.

One AWS decision, as Runback seals it
An example span, and the decision Runback seals from it
AWS sendsRunback seals
DecisionDENYdeny
WhyRefundLimit-a1b2c3d4e5agentcore:RefundLimit-a1b2c3d4e5
Whererefunds-gateway-a1b2c3d4e5agentcore:refunds-gateway-a1b2c3d4e5
Policy enginearn:aws:bedrock-agentcore:ap-southeast-2:111122223333:policy-engine/refunds-a1b2c3d4e5arn:aws:bedrock-agentcore:ap-southeast-2:111122223333:policy-engine/refunds-a1b2c3d4e5
Which span160fc209c3befef4857ab1007d041db0 / 81346de89c725310160fc209c3befef4857ab1007d041db0/81346de89c725310
When1794535140123000000 ns2026-11-13T01:59:00.123Z
Decided byAWS AgentCore Policyaws_agentcore: decided by AWS AgentCore, sealed on receipt by Runback

The span above is an example, not anyone's data. The right-hand column is what the connector's own code produces from it.

How the decisions get out of AWS

AgentCore writes each policy decision as a trace span in the CloudWatch log group aws/spans. Decisions are not in the gateway's application logs. A small Lambda function, subscribed to aws/spans, posts them to Runback.

  1. AgentCore Gateway decides a tool call and writes the decision span to aws/spans.
  2. A CloudWatch Logs subscription passes the span to your forwarder function.
  3. The function posts it to Runback with your API key.
  4. Runback records it, and seals it into your audit log within about two minutes.

Before you begin

  • A Runback API key. In the app, open Settings › Keys and access › API key, select CI gate & replay and generate it. It is the narrowest key that can record decisions; a Send only key cannot.
  • An AgentCore Gateway with a policy engine attached, in ENFORCE or LOG_ONLY mode.
  • CloudWatch Transaction Search turned on in that account and region. AWS requires it before gateway tracing can be turned on.

Steps

  1. Turn on tracing for the gateway

    In the AgentCore console, open Gateways, select your gateway, and in the Tracing pane choose Edit, turn it on, and save.

    Expected output
    New spans appear in the aws/spans log group after the gateway's next tool call.
  2. Create the forwarder function

    Create a Lambda function on Node.js 20 or later named runback-agentcore-forwarder, paste this as index.mjs, and set RUNBACK_API_KEY in its environment.

    index.mjsJavaScript
    // index.mjs: an AWS Lambda function (Node.js 20+) subscribed to the aws/spans
    // log group. It forwards AgentCore Policy decision spans to Runback.
    // Set RUNBACK_API_KEY in the function's environment (or read it from Secrets Manager).
    import { gunzipSync } from "node:zlib";
    
    // Self-hosted? Point this at your own Runback.
    const ENDPOINT = "https://runback.dev/api/integrations/agentcore/decisions";
    const PER_CALL = 500;
    
    /** @param {{ awslogs: { data: string } }} event  a CloudWatch Logs subscription event */
    export async function handler(event) {
      const payload = JSON.parse(gunzipSync(Buffer.from(event.awslogs.data, "base64")).toString("utf8"));
      // CloudWatch sends a CONTROL_MESSAGE when the subscription is created; it carries no spans.
      if (payload.messageType !== "DATA_MESSAGE") return { forwarded: 0 };
    
      /** @type {{ id: string, timestamp: number, message: string }[]} */
      const events = payload.logEvents;
      for (let i = 0; i < events.length; i += PER_CALL) {
        const res = await fetch(ENDPOINT, {
          method: "POST",
          headers: { "content-type": "application/json", authorization: `Bearer ${process.env.RUNBACK_API_KEY}` },
          body: JSON.stringify({ records: events.slice(i, i + PER_CALL) }),
        });
        // Throwing makes Lambda retry the whole batch (twice by default; give the
        // function an on-failure destination so a batch is not lost after that).
        // Re-sending is safe: Runback counts a decision it already has as a duplicate.
        if (!res.ok) throw new Error(`Runback answered ${res.status}: ${await res.text()}`);
        const out = await res.json();
        if (out.rejected?.length) console.warn("Runback refused some records:", JSON.stringify(out.rejected));
      }
      return { forwarded: events.length };
    }
    Expected output
    The function saves without errors. It does nothing until the next step connects it.
  3. Subscribe it to aws/spans

    Run this with your own region and account ID. The filter passes on only the spans that carry a policy decision.

    terminalShell
    #!/usr/bin/env bash
    # Send AgentCore Policy decision spans from aws/spans to the forwarder function.
    # Run in the account and region of your AgentCore Gateway.
    set -euo pipefail
    
    REGION="ap-southeast-2"
    ACCOUNT_ID="111122223333"
    FUNCTION_NAME="runback-agentcore-forwarder"
    
    # Let CloudWatch Logs invoke the function.
    aws lambda add-permission \
      --region "$REGION" \
      --function-name "$FUNCTION_NAME" \
      --statement-id cloudwatch-logs-aws-spans \
      --principal logs.amazonaws.com \
      --action lambda:InvokeFunction \
      --source-arn "arn:aws:logs:${REGION}:${ACCOUNT_ID}:log-group:aws/spans:*"
    
    # Only spans that carry a policy decision reach the function.
    aws logs put-subscription-filter \
      --region "$REGION" \
      --log-group-name aws/spans \
      --filter-name runback-agentcore-decisions \
      --filter-pattern '"aws.agentcore.policy.authorization_decision"' \
      --destination-arn "arn:aws:lambda:${REGION}:${ACCOUNT_ID}:function:${FUNCTION_NAME}"
    Expected output
    Both commands print JSON and no error.
  4. Check decisions arrive

    Make one tool call through the gateway. In Runback, open Settings › Keys and access › AWS AgentCore decisions. It shows how many decisions have arrived and when the latest came in.

What Runback records

One row per decision. AgentCore's span names no agent and no tool arguments, so the row records what AWS does send:

  • Decision: allow or deny. If the gateway's policy engine is in LOG_ONLY mode, AWS did not enforce it, so it is recorded as shadow:allow or shadow:deny and never counted as a stopped call.
  • Rule: the AgentCore policies that decided it. If none did, AWS's stated reason.
  • Agent: the gateway, as agentcore:<gateway id>. To record your agent's name instead, have your forwarder add runback_agent to each record.
  • Policy: the policy engine's ARN.
  • Span: the trace and span IDs, so you can find the same decision in CloudWatch.
  • Time: when AWS made the decision, not when it reached Runback.

Spans for tool-list filtering (PartiallyAuthorizeActions) are counted and skipped. They decide which tools an agent sees, not whether a call may run.

Sending the same span twice records it once: the second copy is counted as a duplicate. That makes Lambda's retries, and re-sending a failed batch, safe.

Checking a decision offline

AgentCore decisions are sealed the same way as Runback's own, so the evidence pack and runback-verify check them too. Proofs for these decisions need @runback/verify 3.2 or later. Earlier versions do not recognise the aws_agentcore value and report the proof as invalid.

Limits

  • Runback can only seal what reaches it. A span AWS never wrote to aws/spans, or one the forwarder failed to send, is not in your audit log.
  • Up to 500 records per request, and decisions up to 7 days old. Older ones are refused with a reason.
  • The answer lists any refused record with its position and why. The forwarder above writes them to its log.
  • If Runback cannot record a batch (for example 503 with migration_not_applied), the forwarder throws and Lambda tries again, twice by default. After that Lambda discards the batch unless the function has an on-failure destination or dead-letter queue. Add one, so a failed batch can be re-sent instead of lost.
  • A record Runback refuses (listed in rejected) is not retried. The forwarder writes it to its log; check that log when the count in Settings looks low.

For your developer

POST /api/integrations/agentcore/decisions takes { "records": [...] }. Each record can be a span from aws/spans as JSON or as its text, or a CloudWatch log event ({ id, timestamp, message }). A decoded subscription payload ({ "logEvents": [...] }) is also accepted. The fields read, and the assumptions about the span's exact JSON shape, are listed in web/lib/agentcore.ts.

AWS references: policy spans and attributes, gateway logs (no policy decisions), LOG_ONLY mode, turning on gateway tracing, subscriptions on aws/spans.

Last updated 19 Nov 2026.