<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prabhakaran Jayaraman Masani</title>
    <description>The latest articles on DEV Community by Prabhakaran Jayaraman Masani (@prabhakaranjm).</description>
    <link>https://dev.to/prabhakaranjm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1035960%2Fcb2c3885-e309-461b-8e99-774510d7e754.png</url>
      <title>DEV Community: Prabhakaran Jayaraman Masani</title>
      <link>https://dev.to/prabhakaranjm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prabhakaranjm"/>
    <language>en</language>
    <item>
      <title>Building Coroner with Kiro: Why Docker Exit Code 137 Is Not a Root Cause</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Thu, 26 Nov 2026 20:51:14 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/building-coroner-with-kiro-why-docker-exit-code-137-is-not-a-root-cause-4h9d</link>
      <guid>https://dev.to/prabhakaranjm/building-coroner-with-kiro-why-docker-exit-code-137-is-not-a-root-cause-4h9d</guid>
      <description>&lt;p&gt;&lt;em&gt;How I built an open-source container crash-forensics tool using Kiro specifications, external telemetry, Docker termination records and property-based testing.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Two Python containers terminate with the same exit code: &lt;code&gt;137&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;One was deliberately killed with SIGKILL.&lt;/p&gt;

&lt;p&gt;The other was killed after Docker recorded an out-of-memory event.&lt;/p&gt;

&lt;p&gt;If I examined only the exit codes, I would see the same result. Yet the recorded termination mechanisms are different.&lt;/p&gt;

&lt;p&gt;That observation became the central problem behind &lt;strong&gt;Coroner&lt;/strong&gt;, an open-source crash-forensics tool I built using Kiro for the &lt;strong&gt;Kiroween 2026 hackathon&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The goal was not to create another dashboard that confidently guesses why a container failed.&lt;/p&gt;

&lt;p&gt;I wanted to preserve the evidence that existed before the container died, compare independent sources and show where the available information stops supporting a conclusion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fusiw8jft72529r680prh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fusiw8jft72529r680prh.png" alt=" " width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: What survives a container crash?
&lt;/h2&gt;

&lt;p&gt;When a container terminates unexpectedly, developers often start with a few familiar questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What was its exit code?&lt;/li&gt;
&lt;li&gt;Did it run out of memory?&lt;/li&gt;
&lt;li&gt;What happened immediately before termination?&lt;/li&gt;
&lt;li&gt;Can the last recorded measurements be trusted?&lt;/li&gt;
&lt;li&gt;Are we inferring something that the evidence does not establish?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Docker's &lt;code&gt;State.ExitCode&lt;/code&gt; is useful, but it is not a complete diagnosis.&lt;/p&gt;

&lt;p&gt;Exit code 137 commonly indicates termination by SIGKILL. It does not, by itself, establish an out-of-memory kill.&lt;/p&gt;

&lt;p&gt;Another problem is evidence survival.&lt;/p&gt;

&lt;p&gt;If telemetry is stored only inside a container that terminates, the information needed for investigation may be lost with the container.&lt;/p&gt;

&lt;p&gt;Coroner addresses these issues by preserving acknowledged samples outside the application container and examining them alongside Docker's termination records.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the architecture
&lt;/h2&gt;

&lt;p&gt;Coroner has four components.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Probe&lt;/td&gt;
&lt;td&gt;Runs inside the Python application container and captures process samples, including RSS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Collector&lt;/td&gt;
&lt;td&gt;Receives samples and stores acknowledged evidence outside the failing container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runner&lt;/td&gt;
&lt;td&gt;Executes controlled termination experiments and records Docker state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Viewer&lt;/td&gt;
&lt;td&gt;Reads preserved evidence and presents timelines, recorded values and comparisons&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;Probe&lt;/strong&gt; samples process information every 500 milliseconds by default.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Collector&lt;/strong&gt; stores acknowledged samples as JSON Lines evidence on a separate Docker volume. The design distinguishes delivered samples from samples that could not be delivered.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Runner&lt;/strong&gt; controls the experiments and collects Docker termination details, including &lt;code&gt;ExitCode&lt;/code&gt;, &lt;code&gt;OOMKilled&lt;/code&gt; and the run manifest.&lt;/p&gt;

&lt;p&gt;Finally, the &lt;strong&gt;Viewer&lt;/strong&gt; displays the preserved evidence through a local, read-only web interface.&lt;/p&gt;

&lt;p&gt;The Viewer starts no containers and does not modify saved runs.&lt;/p&gt;

&lt;p&gt;That distinction matters. Reviewing evidence should not itself reproduce a destructive experiment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three experiments, one important difference
&lt;/h2&gt;

&lt;p&gt;I created three controlled experiments using Docker Desktop with Linux containers on a Windows development machine.&lt;/p&gt;

&lt;p&gt;The recorded results were:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Experiment&lt;/th&gt;
&lt;th&gt;ExitCode&lt;/th&gt;
&lt;th&gt;OOMKilled&lt;/th&gt;
&lt;th&gt;Preserved samples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A — Controlled fatal exit&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B — Runner sends SIGKILL&lt;/td&gt;
&lt;td&gt;137&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C — Docker OOM kill&lt;/td&gt;
&lt;td&gt;137&lt;/td&gt;
&lt;td&gt;true&lt;/td&gt;
&lt;td&gt;45&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Experiment A&lt;/strong&gt; establishes a controlled fatal process exit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experiment B&lt;/strong&gt; terminates after the Runner issues &lt;code&gt;docker kill --signal=KILL&lt;/code&gt;. Docker records exit code 137 and &lt;code&gt;OOMKilled: false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experiment C&lt;/strong&gt; also returns exit code 137, but Docker records &lt;code&gt;OOMKilled: true&lt;/code&gt; under a 128 MiB memory limit.&lt;/p&gt;

&lt;p&gt;The highest preserved RSS sample in C was 141,090,816 bytes, approximately 134.55 MiB.&lt;/p&gt;

&lt;p&gt;The sampled RSS and the cgroup memory accounting that triggers an OOM kill are different measurements. Coroner does not treat a high RSS sample alone as proof of why the kernel terminated the container.&lt;/p&gt;

&lt;p&gt;The important evidence is the Docker termination record, considered alongside the Runner's actions and preserved samples.&lt;/p&gt;

&lt;p&gt;The Viewer's comparison page states the result:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The same exit code does not always mean the same failure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the central demonstration in the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdjjt0zu6t57oatoyr6sh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdjjt0zu6t57oatoyr6sh.png" alt=" " width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A second problem: Clocks do not automatically agree
&lt;/h2&gt;

&lt;p&gt;Building the timeline exposed another issue.&lt;/p&gt;

&lt;p&gt;The Probe, Collector, Runner and Docker records have different timestamp sources.&lt;/p&gt;

&lt;p&gt;A timestamp without its clock provenance can make an investigation appear more certain than it actually is.&lt;/p&gt;

&lt;p&gt;For Experiment B, the Runner recorded one timestamp immediately before issuing the kill command and another after the command returned.&lt;/p&gt;

&lt;p&gt;Those recorded timestamps were 425 milliseconds apart.&lt;/p&gt;

&lt;p&gt;That interval does not establish when the SIGKILL signal reached the container.&lt;/p&gt;

&lt;p&gt;Coroner's Viewer uses a derived host-equivalent axis for B's memory samples. The derivation is labelled and is not independently verified as clock synchronisation.&lt;/p&gt;

&lt;p&gt;Experiments A and C retain raw Probe capture time.&lt;/p&gt;

&lt;p&gt;The design decision was straightforward: show the clock source, label derived timing information and avoid inventing an ordering that the evidence cannot prove.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Kiro shaped the development process
&lt;/h2&gt;

&lt;p&gt;I used &lt;strong&gt;Kiro's spec-driven development workflow&lt;/strong&gt; to organise Coroner rather than treating the project as one large coding task.&lt;/p&gt;

&lt;p&gt;The repository contains three specifications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M0 — Evidence pipeline&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This milestone established the requirements and design for the Probe, Collector, Runner and controlled experiments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M1 — Forensic Viewer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This milestone organised the read-only interface, evidence presentation, timing information and comparison behaviour.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M2 — Demonstration and verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This milestone documented judge instructions, reproducibility checks, safety constraints and recording tasks.&lt;/p&gt;

&lt;p&gt;For M0 and M1, the Kiro specifications contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;requirements.md&lt;/code&gt; — What the system must do.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;design.md&lt;/code&gt; — Architecture and technical decisions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tasks.md&lt;/code&gt; — Development tasks, verification steps and checkpoints.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tasks.meta.json&lt;/code&gt; — Recorded task execution history.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3wzc2dtotum9jyurlwe1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3wzc2dtotum9jyurlwe1.png" alt=" " width="800" height="606"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The development tasks reference requirements and include verification commands, expected behaviour and safety constraints.&lt;/p&gt;

&lt;p&gt;Checkpoints require actual test results before work is accepted.&lt;/p&gt;

&lt;p&gt;Kiro's task execution history is preserved in &lt;code&gt;tasks.meta.json&lt;/code&gt;. I treat those records as evidence of development activity, not proof of correctness.&lt;/p&gt;

&lt;p&gt;The tests and acceptance reports provide the separate verification.&lt;/p&gt;

&lt;p&gt;You can inspect the actual Kiro files:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prabhakaran-jm/coroner/tree/master/.kiro/specs" rel="noopener noreferrer"&gt;https://github.com/prabhakaran-jm/coroner/tree/master/.kiro/specs&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Property-based testing uncovered real defects
&lt;/h2&gt;

&lt;p&gt;One of the most useful parts of the development process involved &lt;strong&gt;Hypothesis&lt;/strong&gt;, the Python property-based testing library.&lt;/p&gt;

&lt;p&gt;Instead of testing only selected examples, property-based tests generate many inputs and explore behaviours that are easy to overlook.&lt;/p&gt;

&lt;p&gt;Coroner includes 28 &lt;code&gt;test_prop_*&lt;/code&gt; files containing 83 Hypothesis &lt;code&gt;@given&lt;/code&gt; tests.&lt;/p&gt;

&lt;p&gt;The properties cover areas such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sample sequencing and missing-data accounting.&lt;/li&gt;
&lt;li&gt;Evidence durability and recovery.&lt;/li&gt;
&lt;li&gt;Dropped-sample handling.&lt;/li&gt;
&lt;li&gt;Collector acknowledgement behaviour.&lt;/li&gt;
&lt;li&gt;Runner verdict and manifest consistency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Collector's storage-status probe produced two particularly useful findings.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defect 1: A later error could hide an earlier failure
&lt;/h3&gt;

&lt;p&gt;If &lt;code&gt;fsync&lt;/code&gt; failed and closing the file also failed, the close error could replace the more important earlier failure.&lt;/p&gt;

&lt;p&gt;A property-test counterexample exposed this behaviour.&lt;/p&gt;

&lt;p&gt;The fix explicitly retained the earlier failure rather than allowing a later close error to mask it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defect 2: Exception messages could contain control characters
&lt;/h3&gt;

&lt;p&gt;Generated exception messages demonstrated that non-printable characters could reach the storage-status error text.&lt;/p&gt;

&lt;p&gt;The fix replaced those characters with safe printable placeholders.&lt;/p&gt;

&lt;p&gt;These findings matter because Coroner's purpose depends on evidence being recorded and reported accurately.&lt;/p&gt;

&lt;p&gt;A forensic tool should not quietly misrepresent a storage failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verification results
&lt;/h2&gt;

&lt;p&gt;The recorded full unit-test run used a clean Windows checkout with Python 3.12.10.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Count&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Collected&lt;/td&gt;
&lt;td&gt;5,995&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Passed&lt;/td&gt;
&lt;td&gt;5,982&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failed&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skipped&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Process exit code&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The skipped tests include platform-specific checks, a Node-dependent test and tests requiring the unpublished real run files.&lt;/p&gt;

&lt;p&gt;The Viewer has also been exercised through automated headless-Chrome checks.&lt;/p&gt;

&lt;p&gt;This does not establish that every platform, browser or accessibility scenario has been tested.&lt;/p&gt;

&lt;p&gt;The real Docker experiments were verified on one Windows host using Docker Desktop. Native Linux and macOS have not been verified.&lt;/p&gt;

&lt;h2&gt;
  
  
  A reproducible demonstration without Docker
&lt;/h2&gt;

&lt;p&gt;I wanted other developers and hackathon judges to inspect the Viewer without having to run destructive container experiments.&lt;/p&gt;

&lt;p&gt;The public repository includes &lt;code&gt;scripts/make-sample-runs.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It generates three clearly labelled synthetic runs carrying the same key ExitCode and OOMKilled values as the recorded demonstration.&lt;/p&gt;

&lt;p&gt;These synthetic files are not real container measurements and do not reproduce the Docker experiments.&lt;/p&gt;

&lt;p&gt;They provide a safe way to exercise the Viewer and its comparison behaviour.&lt;/p&gt;

&lt;p&gt;The complete setup instructions are available in &lt;a href="https://github.com/prabhakaran-jm/coroner/blob/master/JUDGING.md" rel="noopener noreferrer"&gt;JUDGING.md&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Building Coroner reinforced three engineering lessons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, preserving information is not the same as understanding its cause.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An exit code is a recorded fact. A root-cause explanation requires further evidence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second, an accurate interface must distinguish recorded facts from derived values and missing observations.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A graph becomes more useful when the viewer knows which timestamps are measured, which are derived and what remains unknown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third, tests and development records serve different purposes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A completed task shows development progress. A verified test provides evidence about a particular behaviour under particular conditions.&lt;/p&gt;

&lt;p&gt;Kiro's specification workflow helped keep those distinctions visible throughout the project.&lt;/p&gt;

&lt;p&gt;The most useful outcome was not a larger codebase. It was a tool with clearer boundaries around what its evidence can establish.&lt;/p&gt;

&lt;h2&gt;
  
  
  What comes next?
&lt;/h2&gt;

&lt;p&gt;Coroner is an open-source foundation for further container failure investigation.&lt;/p&gt;

&lt;p&gt;Possible next steps include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Testing on native Linux hosts and macOS.&lt;/li&gt;
&lt;li&gt;Supporting more container termination scenarios.&lt;/li&gt;
&lt;li&gt;Improving the presentation of timing uncertainty.&lt;/li&gt;
&lt;li&gt;Expanding human usability and accessibility testing.&lt;/li&gt;
&lt;li&gt;Making saved evidence easier to share and examine across environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also want to explore how developer tools can communicate uncertainty without making the user work harder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explore Coroner
&lt;/h2&gt;

&lt;p&gt;Coroner is open source under the MIT licence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub repository:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prabhakaran-jm/coroner" rel="noopener noreferrer"&gt;https://github.com/prabhakaran-jm/coroner&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo video — Kiroween 2026:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/V1TVWcnrygg" rel="noopener noreferrer"&gt;https://youtu.be/V1TVWcnrygg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run Coroner locally:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prabhakaran-jm/coroner/blob/master/JUDGING.md" rel="noopener noreferrer"&gt;https://github.com/prabhakaran-jm/coroner/blob/master/JUDGING.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kiro specifications:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prabhakaran-jm/coroner/tree/master/.kiro/specs" rel="noopener noreferrer"&gt;https://github.com/prabhakaran-jm/coroner/tree/master/.kiro/specs&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was written as part of the Kiroween 2026 hackathon, where I built Coroner using Kiro's spec-driven development workflow.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you were investigating a production container crash, which evidence would you trust first, and what would you refuse to conclude without further measurements?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>kiro</category>
      <category>python</category>
      <category>devops</category>
      <category>docker</category>
    </item>
    <item>
      <title>One Role, Many Agents: Least-Privilege AI Agents on AWS with STS GetScopedCredentials</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Thu, 26 Nov 2026 14:49:18 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/one-role-many-agents-least-privilege-ai-agents-on-aws-with-sts-getscopedcredentials-2lgp</link>
      <guid>https://dev.to/prabhakaranjm/one-role-many-agents-least-privilege-ai-agents-on-aws-with-sts-getscopedcredentials-2lgp</guid>
      <description>&lt;p&gt;&lt;em&gt;How to hand each agent and sub-agent its own narrowed, short-lived credentials without creating a new IAM role for every task&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: agents inherit everything
&lt;/h2&gt;

&lt;p&gt;Most agent stacks on AWS share one awkward habit. The orchestrator runs under an IAM role (a Lambda execution role, an ECS task role, an EC2 instance profile or a developer's &lt;code&gt;aws login&lt;/code&gt; session), and every tool call, sub-agent and code-execution step quietly reuses those same credentials. The model decides at runtime which API to call, often based on prompts or tool output it does not fully control. If the role can delete a table, so can the agent, whether or not that was ever part of the task.&lt;/p&gt;

&lt;p&gt;The usual fixes are heavy. You can create a dedicated role per agent and per task and chain &lt;code&gt;AssumeRole&lt;/code&gt; calls, but that means more trust policies, more roles to govern and a role-sprawl problem that grows with every new tool. Session policies on &lt;code&gt;AssumeRole&lt;/code&gt; help, but you need a role to assume in the first place, and the session takes on a new role identity.&lt;/p&gt;

&lt;p&gt;On 19 November 2026 AWS announced a simpler building block: &lt;strong&gt;AWS STS GetScopedCredentials&lt;/strong&gt;. It takes the temporary credentials you already have and returns a narrower copy: fewer permissions, a shorter lifetime, or both, while keeping the caller's identity. For agent builders, that maps neatly onto the "orchestrator delegates to sub-agent" pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  How GetScopedCredentials works
&lt;/h2&gt;

&lt;p&gt;Based on the API reference and the AWS Security Blog launch post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You call it &lt;strong&gt;with temporary credentials only&lt;/strong&gt; (assumed role, federated session, Lambda or EC2 role credentials). IAM user and root credentials are not accepted; for an IAM user you first call &lt;code&gt;GetSessionToken&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;You pass a &lt;strong&gt;scope down policy&lt;/strong&gt; (one inline IAM policy, up to 2,048 characters), a &lt;strong&gt;DurationSeconds&lt;/strong&gt; value, or both. At least one is required.&lt;/li&gt;
&lt;li&gt;The resulting permissions are the &lt;strong&gt;intersection&lt;/strong&gt; of the calling session's effective permissions and the scope down policy. It can never add permissions.&lt;/li&gt;
&lt;li&gt;The duration cannot exceed the caller's remaining session lifetime. If you omit it, the new credentials inherit the caller's expiry.&lt;/li&gt;
&lt;li&gt;The new credentials &lt;strong&gt;keep the same identity&lt;/strong&gt;: same role ARN, role session name, session tags and source identity.&lt;/li&gt;
&lt;li&gt;You can call it &lt;strong&gt;recursively&lt;/strong&gt; with already-scoped credentials. Up to three scope down policy layers are allowed per session, and every earlier layer must still allow &lt;code&gt;sts:GetScopedCredentials&lt;/code&gt; for the next call to work.&lt;/li&gt;
&lt;li&gt;An optional &lt;code&gt;ScopedSessionDescription&lt;/code&gt; (up to 256 characters) is written to AWS CloudTrail, so you can record why a scoped session exists.&lt;/li&gt;
&lt;li&gt;It is &lt;strong&gt;not available on the STS global endpoint&lt;/strong&gt;, so use a Regional STS endpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last identity point is the key difference from &lt;code&gt;AssumeRole&lt;/code&gt;. You are not switching roles; you are shrinking the session you are already in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture: an orchestrator that mints credentials per sub-agent
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx41mupo3ccpq787mulsf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx41mupo3ccpq787mulsf.png" alt=" " width="800" height="993"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pattern looks like this in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The orchestrator runs under one role that covers the union of what all its tools might need.&lt;/li&gt;
&lt;li&gt;Before starting a sub-agent or invoking a tool, a small, trusted &lt;strong&gt;credential broker&lt;/strong&gt; in your code (not the model) chooses a scope down policy for that task and calls &lt;code&gt;GetScopedCredentials&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The sub-agent only ever receives the scoped credentials. If it starts its own helper, it can narrow them again but never widen them.&lt;/li&gt;
&lt;li&gt;CloudTrail records each call with its description, and later API calls made with scoped credentials carry the scoped session's access key ID, which you can trace back to the parent session.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same pattern works for multi-tenant SaaS: after authenticating a request, the broker scopes the shared role down to that tenant's S3 prefix before handing credentials to the worker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hands-on
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Allow the caller to scope down
&lt;/h3&gt;

&lt;p&gt;The calling role needs permission to call the API. From the AWS launch post:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"sts:GetScopedCredentials"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"*"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can tighten this further with the &lt;code&gt;sts:DurationSeconds&lt;/code&gt; condition key, and with global keys such as &lt;code&gt;aws:PrincipalArn&lt;/code&gt;, &lt;code&gt;aws:PrincipalTag&lt;/code&gt; or &lt;code&gt;aws:SourceVpce&lt;/code&gt; to control who can call it and from where.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Write a task-level scope down policy
&lt;/h3&gt;

&lt;p&gt;For a research sub-agent that should only read from one bucket:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"s3:ListBucket"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"arn:aws:s3:::amzn-s3-demo-reports"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"arn:aws:s3:::amzn-s3-demo-reports/*"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you would rather keep most permissions and just put guardrails in place, AWS documents an &lt;code&gt;Allow&lt;/code&gt; plus &lt;code&gt;NotAction&lt;/code&gt; pattern. Because a scope down policy can only reduce access, this keeps everything the session already had except the listed actions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"NotAction"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"iam:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"organizations:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"account:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"sts:AssumeRole*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"s3:DeleteBucket"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ec2:TerminateInstances"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"rds:DeleteDBInstance"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dynamodb:DeleteTable"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"*"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember dependent actions. If a tool uses Athena over S3 data, the scoped credentials also need &lt;code&gt;s3:GetObject&lt;/code&gt; on that data. AWS's open source &lt;strong&gt;IAM Policy Autopilot&lt;/strong&gt; can generate a starting policy from the SDK calls in your code, which you then tighten by hand.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Call it from the CLI
&lt;/h3&gt;

&lt;p&gt;With the latest AWS CLI, using a Regional endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws sts get-scoped-credentials \
  --policy file://research-agent-policy.json \
  --duration-seconds 900 \
  --scoped-session-description &lt;span class="s2"&gt;"research-subagent ticket-1234"&lt;/span&gt; \
  --region eu-west-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response contains new &lt;code&gt;Credentials&lt;/code&gt;, a &lt;code&gt;SessionInfo&lt;/code&gt; block whose ARN matches your calling session, &lt;code&gt;ScopedPoliciesCount&lt;/code&gt;, and two size fields, &lt;code&gt;SessionTokenSize&lt;/code&gt; and &lt;code&gt;SessionTokenUtilization&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. A credential broker in Python (illustrative)
&lt;/h3&gt;

&lt;p&gt;The snippet below is &lt;strong&gt;illustrative and untested&lt;/strong&gt;. It assumes a boto3 version that includes the new operation, with parameter names taken from the API reference (&lt;code&gt;Policy&lt;/code&gt;, &lt;code&gt;DurationSeconds&lt;/code&gt;, &lt;code&gt;ScopedSessionDescription&lt;/code&gt;). Check your SDK version before relying on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;

&lt;span class="no"&gt;REGION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"eu-west-2"&lt;/span&gt;
&lt;span class="n"&gt;sts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"sts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;endpoint_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"https://sts.{REGION}.amazonaws.com"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;scoped_session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;policy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;purpose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Return a boto3 Session whose credentials are a narrowed copy of ours."""&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_scoped_credentials&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nc"&gt;Policy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;policy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;separators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;DurationSeconds&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;ScopedSessionDescription&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;purpose&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Credentials"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;aws_access_key_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"AccessKeyId"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;aws_secret_access_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"SecretAccessKey"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;aws_session_token&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"SessionToken"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="no"&gt;READ_REPORTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::amzn-s3-demo-reports/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# The broker, not the model, picks the policy for each tool or sub-agent.&lt;/span&gt;
&lt;span class="n"&gt;research_session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;scoped_session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;READ_REPORTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"research-subagent"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;research_session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"s3"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# pass this client to the sub-agent's tools&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important design choice is where the policy comes from. Keep a fixed catalogue of task policies in code or configuration, reviewed like any other IAM change. Do not let the model write its own scope down policy; at best that recreates the over-permissioning problem, at worst it hands policy authorship to prompt injection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs, security and cost notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It narrows, it does not isolate.&lt;/strong&gt; If the parent credentials are reachable from the sub-agent's process (environment variables, the instance metadata service, a shared credentials file), the sub-agent can simply use those instead. AWS recommends running agents in isolated or sandbox environments so they only see the scoped credentials. On AWS that might be a separate container, MicroVM or sandbox per sub-agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The ceiling is still the parent role.&lt;/strong&gt; Scoping cannot fix an over-broad base role. Keep the orchestrator role reasonable and use permission boundaries and SCPs as the outer fence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy size limits are real.&lt;/strong&gt; The inline policy is capped at 2,048 characters, and the packed session token has its own limit (&lt;code&gt;PackedPolicyTooLarge&lt;/code&gt;). Session tags count too, so watch &lt;code&gt;SessionTokenUtilization&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three layers maximum.&lt;/strong&gt; Plan your delegation depth. Duration-only calls do not count towards the limit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit by description.&lt;/strong&gt; Make &lt;code&gt;ScopedSessionDescription&lt;/code&gt; meaningful (agent name, task or ticket ID) so CloudTrail actually explains who did what.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Throughput.&lt;/strong&gt; At launch AWS states a dedicated quota of 200 requests per second per account per Region. Cache scoped sessions per task rather than per tool call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service coverage.&lt;/strong&gt; Scoped credentials work with most AWS services, but AWS publishes a list of unsupported ones; check it for your tool set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost.&lt;/strong&gt; The main cost is engineering effort: designing and reviewing task policies. Check current AWS STS pricing and request quotas for your account rather than assuming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compared with Google Cloud:&lt;/strong&gt; GCP tends to approach the same goal through separate identities (service accounts and newer per-agent identities) plus token downscoping for specific services such as Cloud Storage's Credential Access Boundaries. GetScopedCredentials is notable for being a general, identity-preserving scope down across most AWS services from a single API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;GetScopedCredentials closes a gap that has quietly existed in many AWS agent designs: the "one role, many tools" problem. Instead of multiplying roles, you keep one well-governed role and have a trusted broker mint a narrower, short-lived copy for every sub-agent and tool, with each hand-off recorded in CloudTrail. Pair it with real process isolation and a reviewed catalogue of task policies, and least privilege for agents becomes a few lines of code rather than a role-management project.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AWS What's New: AWS STS announces GetScopedCredentials (19 Nov 2026) - &lt;a href="https://aws.amazon.com/about-aws/whats-new/2026/11/sts-getscopedcredentials/" rel="noopener noreferrer"&gt;https://aws.amazon.com/about-aws/whats-new/2026/11/sts-getscopedcredentials/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS Security Blog: Scope down permissions of existing sessions using AWS STS GetScopedCredentials - &lt;a href="https://aws.amazon.com/blogs/security/scope-down-permissions-of-existing-sessions-using-aws-sts-getscopedcredentials/" rel="noopener noreferrer"&gt;https://aws.amazon.com/blogs/security/scope-down-permissions-of-existing-sessions-using-aws-sts-getscopedcredentials/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS STS API Reference: GetScopedCredentials - &lt;a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_GetScopedCredentials.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/STS/latest/APIReference/API_GetScopedCredentials.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;IAM Policy Autopilot (AWS open source) - &lt;a href="https://github.com/awslabs/iam-policy-autopilot" rel="noopener noreferrer"&gt;https://github.com/awslabs/iam-policy-autopilot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud: Credential Access Boundaries - &lt;a href="https://cloud.google.com/iam/docs/downscoping-short-lived-credentials" rel="noopener noreferrer"&gt;https://cloud.google.com/iam/docs/downscoping-short-lived-credentials&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>security</category>
      <category>ai</category>
      <category>iam</category>
    </item>
    <item>
      <title>Keyless AI Agents on Google Cloud: A Practical Guide to Agent Identity, Auth Manager and Identity-Based VPC Service Controls</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Tue, 24 Nov 2026 09:57:12 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/keyless-ai-agents-on-google-cloud-a-practical-guide-to-agent-identity-auth-manager-and-1ebj</link>
      <guid>https://dev.to/prabhakaranjm/keyless-ai-agents-on-google-cloud-a-practical-guide-to-agent-identity-auth-manager-and-1ebj</guid>
      <description>&lt;p&gt;&lt;em&gt;How to stop pasting API keys and service account JSON into agents, and give each agent its own verifiable identity, brokered OAuth tokens and a perimeter that knows who it is&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: agents inherit the worst habits of backend services
&lt;/h2&gt;

&lt;p&gt;Most agent prototypes I see follow the same pattern. The agent runs on Cloud Run or Agent Runtime under a shared service account, a Jira or Salesforce client secret sits in an environment variable or Secret Manager, and calls to another cloud use a long-lived access key. It works, but it is a flat-trust design:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Several agents share one service account, so audit logs cannot tell you which agent did what.&lt;/li&gt;
&lt;li&gt;Static secrets live inside the agent's reach, which matters when the agent is driven by untrusted prompts and tool output.&lt;/li&gt;
&lt;li&gt;Perimeter rules are written per service and method, so security teams end up adding broad exceptions just to make agents work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the Google Cloud Security Summit in November 2026, Google announced a set of controls aimed squarely at this: Auth Manager (part of Agent Identity) is now generally available, Agent Identity JWT (OIDC ID token) support is in preview, and VPC Service Controls ingress and egress rules that use IAM roles are generally available. This article walks through how the pieces fit together and how to wire them up with the documented CLI and client libraries.&lt;/p&gt;

&lt;h2&gt;
  
  
  The architecture in one picture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb8u7obfj901gqwdd6p7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb8u7obfj901gqwdd6p7y.png" alt="Architecture diagram: end user, agent, Auth Manager, Google Cloud APIs inside VPC-SC, SaaS tool and external cloud via OIDC ID token" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are three building blocks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent Identity&lt;/strong&gt; gives each agent a strongly attested identity based on the SPIFFE standard. Per the docs, agent identities are not shared by multiple workloads by default, cannot be impersonated, and do not allow long-lived keys. Access tokens for Google Cloud are bound to the agent's unique X.509 certificate to reduce token theft. Supported runtimes are Agent Runtime, Gemini Enterprise, Cloud Run and GKE.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auth Manager&lt;/strong&gt; stores OAuth client credentials and user-delegated tokens in a Google-managed vault governed by IAM. It handles 2-legged OAuth (client credentials, agent's own authority) and 3-legged OAuth (on behalf of a user), so you do not write token-refresh code. ADK can retrieve and inject the token into tool calls for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identity-based VPC Service Controls&lt;/strong&gt; let ingress and egress rules be scoped by IAM roles rather than only by lists of services and methods, which makes least-privilege perimeters for agent traffic far easier to express.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The useful mental model is: the agent proves &lt;em&gt;who it is&lt;/em&gt; with its own identity, Auth Manager decides &lt;em&gt;which external credentials it may use&lt;/em&gt;, and the perimeter decides &lt;em&gt;what data it may touch and from where&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hands-on
&lt;/h2&gt;

&lt;p&gt;The snippets below follow the official documentation as of November 2026. Several features are in preview, so treat the code as illustrative and check the current docs before running it. Replace the upper-case placeholders.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Deploy an agent with its own identity
&lt;/h3&gt;

&lt;p&gt;For a containerised agent on Cloud Run, Agent Identity is a deploy-time flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud run deploy support-agent \
  --image=REGION-docker.pkg.dev/PROJECT_ID/agents/support-agent:latest \
  --identity-type=agent-identity \
  --no-allow-unauthenticated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Agent Runtime, set the identity type when you create the engine with the Vertex AI SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;remote_app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agent_engines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"identity_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IdentityType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;AGENT_IDENTITY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"requirements"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"google-cloud-aiplatform[agent_engines,adk]"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From here, grant IAM roles to the agent's principal, not to a shared service account. That one change gives you per-agent audit trails.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Move SaaS secrets into Auth Manager (2-legged OAuth)
&lt;/h3&gt;

&lt;p&gt;Say the agent calls a Jira MCP server using client credentials. Instead of storing the secret with the agent, create a 2-legged auth provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud agent-identity auth-providers create jira-mcp-2lo \
  --location=&lt;span class="s2"&gt;"us-central1"&lt;/span&gt; \
  --two-legged-oauth-client-id=&lt;span class="s2"&gt;"CLIENT_ID"&lt;/span&gt; \
  --two-legged-oauth-client-secret=&lt;span class="s2"&gt;"CLIENT_SECRET"&lt;/span&gt; \
  --two-legged-oauth-token-url=&lt;span class="s2"&gt;"TOKEN_URL"&lt;/span&gt;

gcloud agent-identity auth-providers list \
  --project=&lt;span class="s2"&gt;"PROJECT_ID"&lt;/span&gt; --location=&lt;span class="s2"&gt;"us-central1"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then allow only this agent to retrieve credentials from that provider by granting &lt;code&gt;roles/agentidentity.user&lt;/code&gt; on the provider resource to the agent's SPIFFE principal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud agent-identity auth-providers add-iam-policy-binding jira-mcp-2lo \
  --project=&lt;span class="s2"&gt;"PROJECT_ID"&lt;/span&gt; \
  --location=&lt;span class="s2"&gt;"us-central1"&lt;/span&gt; \
  --role=&lt;span class="s2"&gt;"roles/agentidentity.user"&lt;/span&gt; \
  --member=&lt;span class="s2"&gt;"principal://agents.global.org-ORGANIZATION_ID.system.id.goog/resources/aiplatform/projects/PROJECT_NUMBER/locations/us-central1/reasoningEngines/ENGINE_ID"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The member string above is the documented format for an Agent Runtime agent. For local testing with &lt;code&gt;adk web&lt;/code&gt;, the docs also show binding the same role to &lt;code&gt;user:YOUR_EMAIL&lt;/code&gt;. When the tool needs to act as a specific person (their Jira tasks, their GitHub repos), use a 3-legged provider instead, and Auth Manager handles the consent flow and token refresh.&lt;/p&gt;

&lt;p&gt;Note the IAM API name: the docs recommend the Agent Identity API and say the earlier IAM Connectors API (preview) will not become generally available, so migrate if you started there.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Call another cloud with an OIDC ID token, no access keys
&lt;/h3&gt;

&lt;p&gt;This is the part I find most interesting for multi-cloud architects. With Agent Identity JWT support (preview), the agent requests an OIDC ID token for a target audience. The token asserts the agent's SPIFFE identity and is signed by keys for the agent's trust domain. Receivers verify it through public, unauthenticated endpoints on &lt;code&gt;sts.googleapis.com&lt;/code&gt; (&lt;code&gt;/.well-known/openid-configuration&lt;/code&gt; and &lt;code&gt;/openid/jwks&lt;/code&gt;), so they need no Google Cloud credentials at all.&lt;/p&gt;

&lt;p&gt;In the agent, the &lt;code&gt;google-auth&lt;/code&gt; library does the work, including caching and renewal from the metadata server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;AuthorizedSession&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;oauth2&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;id_token&lt;/span&gt;

&lt;span class="n"&gt;target_audience&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.example.com"&lt;/span&gt;
&lt;span class="n"&gt;credentials&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;id_token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetch_id_token_credentials&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;audience&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target_audience&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AuthorizedSession&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.example.com/v1/tickets"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"summary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Created by agent"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issuer your receiver must trust is the workload identity pool for the agent's trust domain, for example &lt;code&gt;https://sts.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/workloadIdentityPools/TRUST_DOMAIN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On the AWS side, a standard pattern is to register that issuer as an IAM OIDC identity provider and let the agent exchange its token with &lt;code&gt;AssumeRoleWithWebIdentity&lt;/code&gt;. The following is an illustrative sketch built from the generic AWS OIDC federation flow, not from a Google worked example, so validate the claim names against a real token first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Illustrative only&lt;/span&gt;
aws iam create-open-id-connect-provider \
  --url &lt;span class="s2"&gt;"https://sts.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/workloadIdentityPools/TRUST_DOMAIN"&lt;/span&gt; \
  --client-id-list &lt;span class="s2"&gt;"sts.amazonaws.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then write the role trust policy to match &lt;code&gt;aud&lt;/code&gt; and the agent's &lt;code&gt;sub&lt;/code&gt; (its SPIFFE ID) exactly, so that only this one agent can assume the role.&lt;/p&gt;

&lt;p&gt;Two details from the docs worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client libraries bind ID tokens to the agent's X.509 certificate by default via the &lt;code&gt;cnf&lt;/code&gt; (&lt;code&gt;x5t#S256&lt;/code&gt;) claim. Receivers may validate it over mTLS or ignore it.&lt;/li&gt;
&lt;li&gt;Cloud Run enforces that binding when the claim is present. If your agent calls another Cloud Run service with a bound token, call its &lt;code&gt;*.mtls.run.app&lt;/code&gt; endpoint over mTLS, or opt out per request (&lt;code&gt;bind_id_token=False&lt;/code&gt; in Python) or with &lt;code&gt;GOOGLE_API_ENABLE_RUNTIME_BOUND_TOKEN=false&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Scope the perimeter by role, not by an ever-growing method list
&lt;/h3&gt;

&lt;p&gt;If the agent's data lives in BigQuery or Cloud Storage inside a VPC-SC perimeter, an ingress rule can now name IAM roles rather than enumerating every method. The documented YAML shape is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;ingressFrom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;identities&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;PRINCIPAL_IDENTIFIER&lt;/span&gt;
    &lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;accessLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ACCESS_LEVEL&lt;/span&gt;
  &lt;span class="na"&gt;ingressTo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;roles/bigquery.dataViewer&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;projects/PROJECT_NUMBER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule then only allows actions covered by that role's permissions. Before relying on a role, check it is supported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud access-context-manager supported-permissions describe roles/bigquery.dataViewer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Custom roles in the &lt;code&gt;projects/PROJECT_ID/roles/...&lt;/code&gt; format are not accepted in these rules, so plan to use predefined or organisation-level custom roles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs, cost and security notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Preview versus GA.&lt;/strong&gt; Auth Manager and IAM roles in VPC-SC rules are GA. OIDC ID tokens for external services are preview under Pre-GA terms, so I would not make a cross-cloud production path depend on them without a fallback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blast radius.&lt;/strong&gt; Per-agent identities make least privilege practical, but only if you resist granting broad project roles to every agent principal. Bind roles on the narrowest resource: the auth provider, the dataset, the bucket.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token binding surprises.&lt;/strong&gt; Certificate-bound tokens are a strong defence against replay, but they change how service-to-service calls work on Cloud Run. Test the mTLS path early rather than disabling binding globally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operational ownership.&lt;/strong&gt; Moving secrets into Auth Manager shifts rotation to whoever owns the auth provider. Decide who that is and alert on provider state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost.&lt;/strong&gt; I have not found separate pricing for these identity features in the sources below. Check the current pricing pages for Agent Identity, the runtimes and VPC-SC before you estimate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Defence in depth.&lt;/strong&gt; Identity does not stop a prompt-injected agent from misusing access it legitimately has. Pair it with Agent Gateway policies and content controls such as Model Armor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The shift here is small in syntax and large in effect: a &lt;code&gt;--identity-type=agent-identity&lt;/code&gt; flag, a handful of &lt;code&gt;gcloud agent-identity&lt;/code&gt; commands and a role-scoped perimeter rule replace shared service accounts, pasted secrets and long-lived cross-cloud keys. If you are building agents on Google Cloud today, I would start by giving one agent its own identity, moving one SaaS secret into Auth Manager, and seeing how much cleaner the audit log becomes.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Helping you build and defend at machine-speed in the agentic era (Google Cloud Blog, 4 November 2026): &lt;a href="https://cloud.google.com/blog/products/identity-security/helping-you-build-and-defend-at-machine-speed-in-the-agentic-era" rel="noopener noreferrer"&gt;https://cloud.google.com/blog/products/identity-security/helping-you-build-and-defend-at-machine-speed-in-the-agentic-era&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Agent Identity overview: &lt;a href="https://docs.cloud.google.com/iam/docs/agent-identity-overview" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/agent-identity-overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Authenticate to external services using an agent's own identity: &lt;a href="https://docs.cloud.google.com/iam/docs/auth-agent-own-identity-external" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/auth-agent-own-identity-external&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Authenticate using 2-legged OAuth with auth manager: &lt;a href="https://docs.cloud.google.com/iam/docs/auth-with-2lo-v2" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/auth-with-2lo-v2&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Authenticate using 3-legged OAuth with auth manager: &lt;a href="https://docs.cloud.google.com/iam/docs/auth-with-3lo" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/iam/docs/auth-with-3lo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;gcloud agent-identity auth-providers add-iam-policy-binding: &lt;a href="https://docs.cloud.google.com/sdk/gcloud/reference/agent-identity/auth-providers/add-iam-policy-binding" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/sdk/gcloud/reference/agent-identity/auth-providers/add-iam-policy-binding&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Codelab, build an agent that acts on behalf of the user with Agent Identity and Auth Manager: &lt;a href="https://codelabs.developers.google.com/agent-identity-auth-manager" rel="noopener noreferrer"&gt;https://codelabs.developers.google.com/agent-identity-auth-manager&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Configure IAM roles in VPC Service Controls ingress and egress rules: &lt;a href="https://docs.cloud.google.com/vpc-service-controls/docs/configure-iam-roles" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/vpc-service-controls/docs/configure-iam-roles&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Introducing Agent Compute Engine and expanded agent governance (Google Cloud Blog, 22 October 2026): &lt;a href="https://cloud.google.com/blog/topics/ai-infrastructure/introducing-agent-compute-engine-and-expanded-agent-governance/" rel="noopener noreferrer"&gt;https://cloud.google.com/blog/topics/ai-infrastructure/introducing-agent-compute-engine-and-expanded-agent-governance/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gcp</category>
      <category>ai</category>
      <category>security</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Giving AI Agents a Memory That Lasts: A Practical Look at Amazon OpenSearch Memory</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Thu, 19 Nov 2026 08:22:49 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/giving-ai-agents-a-memory-that-lasts-a-practical-look-at-amazon-opensearch-memory-4602</link>
      <guid>https://dev.to/prabhakaranjm/giving-ai-agents-a-memory-that-lasts-a-practical-look-at-amazon-opensearch-memory-4602</guid>
      <description>&lt;p&gt;Most AI agents I see in demos have the memory of a goldfish. Each session starts from zero, so the user explains their account, their preferences and their open issue all over again. The usual workaround is to stuff the whole conversation history back into the prompt. That works until it doesn't: prompts get longer, latency and token costs climb, and the one fact that matters gets buried under thousands of tokens of chit-chat.&lt;/p&gt;

&lt;p&gt;The alternative is to build your own memory layer: capture every turn, extract facts and summaries with an LLM, embed them, store them in a vector database, reconcile new facts with old ones, scope everything per user and enforce retention. That's a lot of plumbing to own before your agent does anything useful.&lt;/p&gt;

&lt;p&gt;On 18 November 2026, AWS announced the general availability of &lt;strong&gt;Amazon OpenSearch Memory&lt;/strong&gt;, a serverless capability in Amazon OpenSearch Service built on OpenSearch Serverless. It's designed to give agents persistent, searchable memory without you running that pipeline yourself. In this article I'll walk through how it works, show how to plug it into an agent loop with Boto3, and share the architectural trade-offs I'd look at before adopting it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The core model: spaces, events, memories and strategies
&lt;/h2&gt;

&lt;p&gt;OpenSearch Memory has a small set of concepts, and once they click the rest is straightforward.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Space&lt;/strong&gt; - the AWS resource that acts as a memory store. It defines which memory strategies run, how long data is kept and how it's encrypted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Events&lt;/strong&gt; - the original interactions your application writes, stored verbatim. They're readable straight away and searchable within seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memories&lt;/strong&gt; - facts, preferences and summaries derived from events in the background.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory strategies&lt;/strong&gt; - each defines one kind of memory to extract. There are &lt;code&gt;SEMANTIC&lt;/code&gt; strategies (facts), &lt;code&gt;SUMMARY&lt;/code&gt; strategies (per-session summaries) and &lt;code&gt;CUSTOM&lt;/code&gt; strategies driven by your own prompt. A space can run up to 10 strategies over the same events.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Actor and session&lt;/strong&gt; - every request names an actor (the end user the data belongs to). An optional session ID groups the events from one conversation. Searches are always scoped to a single actor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two design choices stand out to me. First, the write path is "write now, remember later": &lt;code&gt;CreateEvent&lt;/code&gt; returns as soon as the event is stored, and extraction happens asynchronously, so your agent's response time doesn't depend on the extraction model. Second, memories are &lt;strong&gt;consolidated&lt;/strong&gt; by default. If a user says "I live in Seattle" and later "I moved to Austin", the stored fact is updated instead of keeping two contradictory facts side by side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;Here's how the pieces fit together in a typical agent loop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuc710ecrca398zced8f4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuc710ecrca398zced8f4.png" alt="Architecture: agent application searches the OpenSearch Memory space, calls a Bedrock model, then writes events; memory strategies extract and consolidate asynchronously" width="798" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each turn adds two calls to the loop: one search before the model responds, and one write after. Extraction and embedding happen inside the service using an Amazon Bedrock model (Claude Haiku 5.5 by default, configurable per space). According to the docs, you don't request model access or grant model permissions yourself; the service calls the extraction model on your behalf, and AWS states that extraction and embedding costs are included in OpenSearch Memory pricing.&lt;/p&gt;

&lt;p&gt;Your agent can connect through the AWS SDKs, the AWS CLI (&lt;code&gt;aws opensearchmemory ...&lt;/code&gt;), an AWS MCP server, hooks or supported framework integrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hands-on: adding memory to a support agent
&lt;/h2&gt;

&lt;p&gt;The snippets below follow the official launch walkthrough and developer guide. They need Python 3.10+, Boto3 1.44.4 or later, and one of the launch Regions: US East (N. Virginia), US West (Oregon), Europe (Frankfurt) or Asia Pacific (Tokyo). I haven't run these end to end against a live account, so treat them as illustrative and check the current API reference before using them.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create a space
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;

&lt;span class="no"&gt;REGION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"eu-central-1"&lt;/span&gt;  &lt;span class="c1"&gt;# Frankfurt is the closest launch Region for UK/EU workloads&lt;/span&gt;
&lt;span class="n"&gt;osm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"opensearchmemory"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;REGION&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;space&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_space&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"customer-support-agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;memoryStrategies&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"SEMANTIC"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"facts-and-preferences"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"SUMMARY"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"session-summaries"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;eventExpiryDays&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;# raw events: 1-365 days&lt;/span&gt;
    &lt;span class="n"&gt;memoryExpiryDays&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;365&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# derived memories: 0 = never expire&lt;/span&gt;
    &lt;span class="c1"&gt;# encryptionConfiguration={"kmsKeyArn": "arn:aws:kms:..."},  # CMK can only be set at creation&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;space_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;space&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"spaceId"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_waiter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"space_active"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spaceId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;space_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the comment on encryption: a customer managed KMS key can only be set when the space is created. If your organisation requires CMKs, decide that up front.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Write an event after each turn
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;conversational&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;turns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Build a CreateEvent payload from [(role, text), ...]."""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"conversational"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"unified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;turns&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;spaceId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;space_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;actorId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"user-42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;sessionId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"session-007"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;conversational&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"USER"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"I'm calling again about Case #78234. It's still not resolved."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ASSISTANT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"I've escalated Case #78234 to billing. Your reference is ESC-5521."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"channel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"phone"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Retrieve context before the model responds
&lt;/h3&gt;

&lt;p&gt;Search uses a subset of the OpenSearch Query DSL (&lt;code&gt;match&lt;/code&gt;, &lt;code&gt;neural&lt;/code&gt;, &lt;code&gt;hybrid&lt;/code&gt;, &lt;code&gt;bool&lt;/code&gt;), which will feel familiar if you've used OpenSearch before. A hybrid query lets the keyword half find exact identifiers like case numbers, while the semantic half picks up related context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search_memories&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;spaceId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;space_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;actorId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"user-42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"hybrid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"queries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"match"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"memory_text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Case #78234 open cases and account status"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"neural"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"memory_vector"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"query_text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"open cases and account status"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"k"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;maxResults&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"memories"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Inject `context` into the system prompt for the Bedrock model call&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each memory also returns &lt;code&gt;sourceEventIds&lt;/code&gt;, so you can trace a fact back to the conversation that produced it. That's useful for debugging and for audit.&lt;/p&gt;

&lt;p&gt;For a brand-new user, memory search may return nothing at first because extraction is asynchronous. If the agent restarts mid-conversation, read recent turns straight from events with &lt;code&gt;ListEvents&lt;/code&gt; and &lt;code&gt;BatchGetEvent&lt;/code&gt; instead of waiting for memories.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Write known facts directly
&lt;/h3&gt;

&lt;p&gt;When you already know something, for example a preference from your CRM, you can skip extraction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_memory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;spaceId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;space_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"facts-and-preferences"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;actorId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"user-42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"The user prefers to be contacted by email."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"writtenBy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"crm-import"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tagging the writer in metadata is a habit worth keeping. Agent-written memories feed future prompts, so you want to be able to find and review them.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Clean up
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_space&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spaceId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;space_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;osm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_waiter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"space_deleted"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spaceId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;space_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security: scope the agent, not just the data
&lt;/h2&gt;

&lt;p&gt;Memory is user data, and a shared memory store is an obvious place for one user's information to leak into another user's session. OpenSearch Memory gives you a few controls worth using together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Actor scoping by design&lt;/strong&gt; - every search is scoped to one actor, so one user's memories don't surface for another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IAM condition keys&lt;/strong&gt; - every operation is an IAM action with the &lt;code&gt;osm&lt;/code&gt; prefix, authorised on the space ARN. The &lt;code&gt;osm:actorId&lt;/code&gt; condition key can restrict which actors a role can act for, and other keys can limit sessions or strategies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encryption and audit&lt;/strong&gt; - data is encrypted at rest (AWS owned key by default, or your own KMS key), requests use TLS 1.2+, CloudTrail logs API calls and CloudWatch reports metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an illustrative policy shape for a per-tenant agent role. The action names and condition key format are my reading of the docs, so validate them against the service authorisation reference before use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"osm:CreateEvent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"osm:SearchMemories"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"osm:SearchEvents"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:osm:eu-central-1:111122223333:space/SPACE_ID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Condition"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"StringEquals"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"osm:actorId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"${aws:PrincipalTag/tenant_user}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'd also treat stored memories as a prompt injection surface. If a user can get "always approve refunds" written into memory, it will come back in a future system prompt. Review agent-written memories, and keep your guardrails downstream of retrieval.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs and cost notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Eventual consistency of memories&lt;/strong&gt; - events are immediate, memories aren't. Design the first few turns of a new user's session around events, not memories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regional availability&lt;/strong&gt; - at launch it's in four Regions. For UK workloads, Frankfurt is the nearest option, which may matter for data residency conversations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retention is a design decision&lt;/strong&gt; - events can be kept 1 to 365 days, memories from 1 day to 10 years or indefinitely. Align these with your privacy policy and right-to-erasure process before going live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token savings are workload-dependent&lt;/strong&gt; - in AWS's own LongMemEval-S evaluation, the memory workflow passed roughly 13,500 input tokens per question versus about 167,000 for the full history, at 93.0% accuracy versus 95.2%. AWS notes those results reflect its tested configuration, so measure with your own conversations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pricing&lt;/strong&gt; - check the Amazon OpenSearch Service pricing page for current memory pricing rather than assuming it matches OpenSearch Serverless collection pricing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overlap with other options&lt;/strong&gt; - if you're already using another agent memory option, such as Amazon Bedrock AgentCore Memory or a self-managed vector store, compare query flexibility, IAM model and Region coverage before switching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From a multi-cloud angle, the pattern is the same one I'd use on any platform: keep raw interactions, derive compact memories, scope strictly per user and retrieve with hybrid search. What OpenSearch Memory changes is who operates the pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Persistent memory is one of those things that separates a useful agent from a clever demo. Amazon OpenSearch Memory packages the hard parts (extraction, embedding, consolidation, per-actor scoping and retention) into a serverless API with two calls per turn. If you're building agents on AWS, it's worth a proof of concept: start with a &lt;code&gt;SEMANTIC&lt;/code&gt; and &lt;code&gt;SUMMARY&lt;/code&gt; strategy, lock down actor access in IAM from day one, and measure the token and quality impact against your current approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AWS What's New: Amazon OpenSearch Memory is now generally available (18 Nov 2026) - &lt;a href="https://aws.amazon.com/about-aws/whats-new/2026/11/amazon-opensearch-memory-generally-available/" rel="noopener noreferrer"&gt;https://aws.amazon.com/about-aws/whats-new/2026/11/amazon-opensearch-memory-generally-available/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS Big Data Blog: Introducing Amazon OpenSearch Memory: Persistent memory for AI agents - &lt;a href="https://aws.amazon.com/blogs/big-data/introducing-amazon-opensearch-memory-persistent-memory-for-ai-agents/" rel="noopener noreferrer"&gt;https://aws.amazon.com/blogs/big-data/introducing-amazon-opensearch-memory-persistent-memory-for-ai-agents/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon OpenSearch Service Developer Guide: What is Amazon OpenSearch Memory? - &lt;a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/memory.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/opensearch-service/latest/developerguide/memory.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon OpenSearch Service pricing - &lt;a href="https://aws.amazon.com/opensearch-service/pricing/" rel="noopener noreferrer"&gt;https://aws.amazon.com/opensearch-service/pricing/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>ai</category>
      <category>serverless</category>
      <category>opensearch</category>
    </item>
    <item>
      <title>Letting AI Agents Run Code Safely: A Hands-On Look at Cloud Run Sandboxes and Sandbox Templates</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Tue, 17 Nov 2026 13:13:44 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/letting-ai-agents-run-code-safely-a-hands-on-look-at-cloud-run-sandboxes-and-sandbox-templates-11ok</link>
      <guid>https://dev.to/prabhakaranjm/letting-ai-agents-run-code-safely-a-hands-on-look-at-cloud-run-sandboxes-and-sandbox-templates-11ok</guid>
      <description>&lt;h2&gt;
  
  
  The problem: agents want to execute code
&lt;/h2&gt;

&lt;p&gt;Sooner or later, every useful AI agent wants to run code. It might be a data-analysis agent that writes a pandas script, a coding agent that runs tests, or a research agent that spins up a headless browser. The model generates the code, so from an architecture point of view that code is &lt;strong&gt;untrusted input&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The usual options are uncomfortable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run it in the agent's own container, and the generated code can read your environment variables, call the metadata server and act as your service account.&lt;/li&gt;
&lt;li&gt;Spin up a new Cloud Run job or VM per task, and you pay in latency, plumbing and cost for every tool call.&lt;/li&gt;
&lt;li&gt;Run a separate sandbox service, and you now own another piece of infrastructure, plus the networking and auth between the two.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cloud Run sandboxes (currently in Preview) target exactly this gap. On 16 November 2026, Google added &lt;strong&gt;sandbox templates&lt;/strong&gt;, which let you launch sandboxes as separate containers with their own images and dynamically mount in-memory volumes into them. In this article I walk through how the feature fits together, how I would wire it into an agent, and the security and cost trade-offs to think about before you enable it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Cloud Run sandboxes work
&lt;/h2&gt;

&lt;p&gt;According to the documentation, sandboxes run inside the same Cloud Run instance as your main container (second-generation execution environment) and share its CPU and memory. You enable them per container with a &lt;code&gt;sandboxLauncher&lt;/code&gt; flag, and your code then calls a CLI shipped at &lt;code&gt;/usr/local/gcp/bin/sandbox&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The defaults are what make this interesting from a security point of view. By default, a sandbox:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;has &lt;strong&gt;no outbound network access&lt;/strong&gt; (you opt in with &lt;code&gt;--allow-egress&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;does &lt;strong&gt;not&lt;/strong&gt; inherit the parent's environment variables, secrets or access to the Google Cloud metadata server&lt;/li&gt;
&lt;li&gt;is isolated from every other sandbox&lt;/li&gt;
&lt;li&gt;runs processes as a non-root user with sudo, so it can still &lt;code&gt;pip install&lt;/code&gt; or &lt;code&gt;apt install&lt;/code&gt; inside its own ephemeral filesystem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are two modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local sandboxes&lt;/strong&gt; use the host container's root filesystem, mounted read-only, as their base. Simple, but your main image has to contain every tool the sandbox needs, and the sandbox can read whatever is on the host's disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Templated sandboxes&lt;/strong&gt; (new) start from a separate image you declare, such as &lt;code&gt;python:3.12-slim&lt;/code&gt; or a custom toolchain image. You can declare up to 10 templates. They still share the host instance's CPU and memory, and the docs note they launch without provisioning new VMs or billing for new instances.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Templates can mount an &lt;strong&gt;in-memory volume&lt;/strong&gt; shared with the main container, and a &lt;code&gt;subPath&lt;/code&gt; with a &lt;code&gt;$(VARIABLE)&lt;/code&gt; placeholder means each sandbox only sees its own subdirectory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhlxzja5q52oagwl6p7d0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhlxzja5q52oagwl6p7d0.png" alt="Agent container launching isolated Cloud Run sandboxes that share an in-memory volume" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The agent container keeps the identity, the secrets and the network access. The sandboxes get a scratch directory and nothing else unless you grant it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hands-on: a code-execution tool for an agent
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Cloud Run sandboxes are a Preview feature. The configuration below follows the official documentation as of 17 November 2026, but the Python tool wrapper is &lt;strong&gt;illustrative&lt;/strong&gt; and has not been tested in production. Check the docs for changes before you use it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1. Enable the sandbox launcher
&lt;/h3&gt;

&lt;p&gt;For a quick start on an existing service, the docs use the beta gcloud command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud beta run services update my-agent --sandbox-launcher
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Terraform &lt;code&gt;google_cloud_run_v2_service&lt;/code&gt; resource exposes the same setting as &lt;code&gt;sandbox_launcher = true&lt;/code&gt; on the container. Because sandboxes share the container's resources, size CPU and memory for your app plus the sandboxes you expect to run at the same time.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Declare a template and a shared in-memory volume
&lt;/h3&gt;

&lt;p&gt;Templates are configured through the service YAML (or the Admin API). Export the current config, edit it, and replace it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud run services describe my-agent --format &lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; service.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;serving.knative.dev/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-agent&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;run.googleapis.com/launch-stage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;BETA&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;europe-west2-docker.pkg.dev/PROJECT_ID/agents/my-agent:latest&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;
        &lt;span class="na"&gt;sandboxLauncher&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
        &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;work&lt;/span&gt;
          &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/mnt/work&lt;/span&gt;
      &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;work&lt;/span&gt;
        &lt;span class="na"&gt;emptyDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;medium&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Memory&lt;/span&gt;
      &lt;span class="na"&gt;sandboxes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;templates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python:3.12-slim&lt;/span&gt;
          &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;work&lt;/span&gt;
            &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/work&lt;/span&gt;
            &lt;span class="na"&gt;subPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;$(SANDBOX_DIR)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud run services replace service.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details from the docs that are easy to miss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Template variable names can only contain ASCII letters and underscores, so &lt;code&gt;SANDBOX_DIR&lt;/code&gt; works but &lt;code&gt;SANDBOX_DIR_2&lt;/code&gt; or &lt;code&gt;sandbox-dir&lt;/code&gt; does not.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subPath&lt;/code&gt; does not create directories for you. The main container has to &lt;code&gt;mkdir -p&lt;/code&gt; the subdirectory before launching the sandbox.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Wrap it as an agent tool
&lt;/h3&gt;

&lt;p&gt;Here is an illustrative Python function you could register as a tool in an agent framework such as ADK. It gives each call its own directory and sandbox name, runs the generated code in the &lt;code&gt;python&lt;/code&gt; template with no egress, and enforces a timeout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Illustrative only: verify flags against the current sandbox CLI reference.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;

&lt;span class="no"&gt;SANDBOX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/usr/local/gcp/bin/sandbox"&lt;/span&gt;
&lt;span class="no"&gt;WORK_ROOT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/mnt/work"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_python&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout_s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Execute model-generated Python in an isolated Cloud Run sandbox."""&lt;/span&gt;
    &lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"job{uuid.uuid4().hex[:12]}"&lt;/span&gt;   &lt;span class="c1"&gt;# matches ^[a-zA-Z0-9][a-zA-Z0-9-]*$&lt;/span&gt;
    &lt;span class="n"&gt;job_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;WORK_ROOT&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;job_id&lt;/span&gt;
    &lt;span class="n"&gt;job_dir&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exist_ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# subPath is not auto-created&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_dir&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"main.py"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="no"&gt;SANDBOX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"do"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"--template=python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"--template-var=SANDBOX_DIR={job_id}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"--sandbox-name={job_id}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"--stdin=false"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"--workdir=/work"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"--"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/usr/local/bin/python3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/work/main.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;timeout_s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"exit_code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;returncode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"stdout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10_000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"stderr"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10_000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TimeoutExpired&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Naming the sandbox lets us force-delete it on timeout.&lt;/span&gt;
        &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;SANDBOX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"delete"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"--force"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"exit_code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stdout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stderr"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"timed out"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the absolute interpreter path: the official images put Python in &lt;code&gt;/usr/local/bin&lt;/code&gt;, and the docs advise using absolute paths or setting &lt;code&gt;PATH&lt;/code&gt; with &lt;code&gt;--env&lt;/code&gt;. Also note what is &lt;em&gt;not&lt;/em&gt; in the command: no &lt;code&gt;--allow-egress&lt;/code&gt;, no &lt;code&gt;--env&lt;/code&gt; with credentials, no bind mounts of host directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Keep state between steps (optional)
&lt;/h3&gt;

&lt;p&gt;Multi-step agents often need the workspace to survive between tool calls. The CLI supports exporting the sandbox's writable overlay to a tar file and importing it on the next call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sandbox &lt;span class="k"&gt;do&lt;/span&gt; --write --sync-tar=/mnt/work/job123/state.tar \
  -- /usr/bin/bash -c &lt;span class="s2"&gt;"mkdir -p /workspace &amp;amp;&amp;amp; echo step-done &amp;gt;&amp;gt; /workspace/log.txt"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Files under &lt;code&gt;/tmp&lt;/code&gt; inside the sandbox are not included in archives, so persist to another path such as &lt;code&gt;/workspace&lt;/code&gt;. For long-lived sessions you can also &lt;code&gt;sandbox run NAME --detach&lt;/code&gt; once and then &lt;code&gt;sandbox exec NAME -- ...&lt;/code&gt; repeatedly, which the docs recommend for fast repeated commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs, cost and security notes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The defaults are good; the risk is relaxing them under deadline pressure. The documentation is explicit: don't relax isolation flags to work around permission or network errors when running untrusted code.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--allow-egress&lt;/code&gt; exposes everything the Cloud Run instance can reach, including internal VPC endpoints. If the agent truly needs the internet, consider a narrow egress path rather than turning it on globally.&lt;/li&gt;
&lt;li&gt;Never pass API keys or tokens via &lt;code&gt;--env&lt;/code&gt;, and append &lt;code&gt;,readonly&lt;/code&gt; to any mount you expose.&lt;/li&gt;
&lt;li&gt;Don't run &lt;code&gt;tar -xf&lt;/code&gt; on sandbox archives in the host container; archives can contain malicious symlinks. Inspect with &lt;code&gt;tar -tf&lt;/code&gt; or re-import into another sandbox.&lt;/li&gt;
&lt;li&gt;Do not share writable archives across users or tenants. In a multi-tenant agent, key directories, sandbox names and archives by tenant.&lt;/li&gt;
&lt;li&gt;Sandbox lifecycle events land in Cloud Logging; pipe sandbox stdout and stderr to your container's streams if you want the output there too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cost and capacity&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sandboxes don't create new billable instances, but they consume the host instance's CPU and memory, and the in-memory volume counts against memory too. A burst of heavy sandbox jobs can starve the agent itself, so limit concurrency inside the agent and keep request concurrency on the service conservative.&lt;/li&gt;
&lt;li&gt;You cannot set per-template CPU or memory limits, so a single runaway script can affect its neighbours on the same instance. Timeouts and output truncation (as in the example) matter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to use something else&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sandboxes are Preview, so weigh support expectations before relying on them for critical workloads.&lt;/li&gt;
&lt;li&gt;For heavy, long-running or GPU tasks, a dedicated Cloud Run job is still the cleaner unit of isolation and billing.&lt;/li&gt;
&lt;li&gt;Google has also announced Agent Compute Engine, a hardware-isolated microVM runtime for agents targeted for preview. That looks aimed at large-scale, high-churn agent fleets; Cloud Run sandboxes fit the much more common case of "my agent on Cloud Run needs a safe code interpreter today".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Cloud Run sandboxes turn "let the agent run code" from an infrastructure project into a configuration change plus a CLI call. Sandbox templates are the piece that makes it practical: your agent image stays lean, each tool runtime lives in its own image, and each execution gets its own private directory on a shared in-memory volume. Combined with secure defaults (no egress, no inherited secrets, no metadata server) this is a pattern I would reach for whenever an agent on Cloud Run needs a code interpreter, while keeping a close eye on resource sizing and never relaxing isolation just to make an error go away.&lt;/p&gt;

&lt;p&gt;If you try it, start with the defaults, add one capability at a time, and log every sandbox invocation.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Cloud Run release notes (16 Nov 2026, sandbox templates): &lt;a href="https://docs.cloud.google.com/run/docs/release-notes" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/run/docs/release-notes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Code execution in Cloud Run (sandboxes): &lt;a href="https://docs.cloud.google.com/run/docs/code-execution" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/run/docs/code-execution&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Configure sandboxes for services: &lt;a href="https://docs.cloud.google.com/run/docs/configuring/services/sandboxes" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/run/docs/configuring/services/sandboxes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloud Run sandbox CLI reference: &lt;a href="https://docs.cloud.google.com/run/docs/reference/sandbox-cli" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/run/docs/reference/sandbox-cli&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloud Run YAML reference: &lt;a href="https://docs.cloud.google.com/run/docs/reference/yaml/v1" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/run/docs/reference/yaml/v1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Host AI agents on Cloud Run: &lt;a href="https://docs.cloud.google.com/run/docs/ai-agents" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/run/docs/ai-agents&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Introducing Agent Compute Engine and expanded agent governance: &lt;a href="https://cloud.google.com/blog/topics/ai-infrastructure/introducing-agent-compute-engine-and-expanded-agent-governance/" rel="noopener noreferrer"&gt;https://cloud.google.com/blog/topics/ai-infrastructure/introducing-agent-compute-engine-and-expanded-agent-governance/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gcp</category>
      <category>ai</category>
      <category>serverless</category>
      <category>security</category>
    </item>
    <item>
      <title>Building FailureDNA: an agent memory that knows when not to trust itself</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Sat, 27 Jun 2026 20:07:30 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/building-failuredna-an-agent-memory-that-knows-when-not-to-trust-itself-fbn</link>
      <guid>https://dev.to/prabhakaranjm/building-failuredna-an-agent-memory-that-knows-when-not-to-trust-itself-fbn</guid>
      <description>&lt;p&gt;&lt;em&gt;Submitted for the &lt;a href="https://qwencloud-hackathon.devpost.com/" rel="noopener noreferrer"&gt;Global AI Hackathon Series with Qwen Cloud&lt;/a&gt; — Track 1: MemoryAgent.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug that started it
&lt;/h2&gt;

&lt;p&gt;Give an incident-response agent a vector database of past incidents and it will do something that looks smart and is quietly dangerous: when a new outage resembles an old one, it retrieves the most &lt;em&gt;similar&lt;/em&gt; past incident and reuses whatever action it finds there.&lt;/p&gt;

&lt;p&gt;The problem is that &lt;strong&gt;similarity is not applicability.&lt;/strong&gt; The most similar past incident might be the one where &lt;code&gt;restart_service&lt;/code&gt; &lt;em&gt;failed&lt;/em&gt;. Or where &lt;code&gt;increase_connection_pool&lt;/code&gt; worked — but only because the database driver was &lt;code&gt;psycopg2&lt;/code&gt; and the topology was single-region, both of which have since changed. A cosine score of 1.0 tells you the symptoms rhyme. It tells you nothing about whether the fix still holds.&lt;/p&gt;

&lt;p&gt;In incident response, that gap is expensive. Repeating a remediation that already failed burns the most costly minutes of an outage; reusing a fix whose preconditions have drifted can make the incident worse. So I built &lt;strong&gt;FailureDNA&lt;/strong&gt;: a persistent memory that accumulates real outcomes and reasons about whether past experience should be &lt;strong&gt;used&lt;/strong&gt;, &lt;strong&gt;inspected&lt;/strong&gt;, or &lt;strong&gt;avoided&lt;/strong&gt; — &lt;em&gt;before&lt;/em&gt; the model is allowed to act on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The core idea: an LLM over a deterministic gate
&lt;/h2&gt;

&lt;p&gt;The architecture has one opinionated rule: &lt;strong&gt;the model selects; it never decides what's valid.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Incident
  -&amp;gt; embed symptoms (Qwen text-embedding-v3)
  -&amp;gt; pgvector semantic search on Alibaba Cloud RDS
  -&amp;gt; fuse semantic + keyword scores
  -&amp;gt; DETERMINISTIC validity gate  &amp;lt;- the important part
  -&amp;gt; Qwen picks one allowlisted action (validated JSON)
  -&amp;gt; execute -&amp;gt; persist the real outcome back to memory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp2axylr7i765rspebfv9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp2axylr7i765rspebfv9.png" alt=" " width="800" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The validity gate is deliberately boring and deterministic:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prior outcome&lt;/th&gt;
&lt;th&gt;Environment match&lt;/th&gt;
&lt;th&gt;Disposition&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;failure&lt;/td&gt;
&lt;td&gt;any&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;avoid&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;success&lt;/td&gt;
&lt;td&gt;full match&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;use&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;success&lt;/td&gt;
&lt;td&gt;driver / topology / config hash changed&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;inspect&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;No model decides whether a memory is trustworthy. And critically, &lt;code&gt;avoid&lt;/code&gt; is &lt;strong&gt;enforced, not advised&lt;/strong&gt;: an action with a symptom-matching prior failure is &lt;em&gt;removed from the candidate list before the model sees it&lt;/em&gt;. The agent cannot repeat a known failure even if it wanted to — which matters, because a live LLM handed the same memories as a "hint" will sometimes ignore the hint. The creative part (which action, given the evidence) goes to Qwen; the part that must never hallucinate (is this memory valid? did this action succeed?) stays in deterministic code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Qwen Cloud fit
&lt;/h2&gt;

&lt;p&gt;I used Qwen Cloud through its OpenAI-compatible DashScope endpoint, which made two things nearly free:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings for recall.&lt;/strong&gt; &lt;code&gt;text-embedding-v3&lt;/code&gt; turns incident symptoms into 1024-d vectors for pgvector search. Hybrid retrieval fuses semantic similarity (weight 0.70) with keyword overlap (0.30), so it catches both paraphrased and exact-token symptoms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validated action selection.&lt;/strong&gt; A Qwen chat model receives the symptoms, the environment fingerprint, the (gated) candidate actions, and the memories, and returns a single JSON decision at &lt;code&gt;temperature=0&lt;/code&gt; with thinking disabled — fast, deterministic-ish output that I validate before anything executes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because it's OpenAI-compatible, the whole client is a thin, well-typed wrapper with explicit timeouts and one retry — no exotic SDK to fight.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving it helps (without fooling myself)
&lt;/h2&gt;

&lt;p&gt;A demo where the new thing wins is easy to fake, so FailureDNA ships a benchmark designed to be hard on itself: three modes (&lt;code&gt;no_memory&lt;/code&gt;, &lt;code&gt;naive&lt;/code&gt;, &lt;code&gt;failuredna&lt;/code&gt;) on identical seeded history, &lt;strong&gt;hidden&lt;/strong&gt; simulator outcomes, &lt;strong&gt;evaluator-only&lt;/strong&gt; safe/unsafe labels, isolated memory per mode, and static shortcut baselines (&lt;code&gt;always_inspect_downstream&lt;/code&gt;, …) to check it isn't just rediscovering that one action is usually right.&lt;/p&gt;

&lt;p&gt;FailureDNA lifts first-action resolution well above the naive agent, cuts unsafe first actions sharply, resolves in fewer actions, and repeats &lt;strong&gt;zero&lt;/strong&gt; historical failures and &lt;strong&gt;zero&lt;/strong&gt; stale successes. The honest caveat I left in the open: in this small scenario set, a static always-inspect policy also scores well — which is exactly why the shortcut audit exists. FailureDNA's value isn't a magic action; it's that it &lt;em&gt;never repeats a known failure and never blindly reuses a stale fix as environments change&lt;/em&gt; — the behavior that generalizes beyond a fixed benchmark.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it on Alibaba Cloud (and the sharp edges)
&lt;/h2&gt;

&lt;p&gt;The backend runs as a custom container on &lt;strong&gt;Alibaba Cloud Function Compute&lt;/strong&gt; (FastAPI, port 9000), memory persists in &lt;strong&gt;ApsaraDB RDS for PostgreSQL + pgvector&lt;/strong&gt; (HNSW), and the image lives in &lt;strong&gt;ACR Personal Edition&lt;/strong&gt;. A few things bit, and are worth writing down for the next person:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ACR tiers matter.&lt;/strong&gt; Enterprise &lt;em&gt;Economy&lt;/em&gt; can't back an FC custom-container function (no image processing). Personal Edition (free) works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The default &lt;code&gt;*.fcapp.run&lt;/code&gt; domain forces downloads.&lt;/strong&gt; It adds &lt;code&gt;Content-Disposition: attachment&lt;/code&gt; to HTML and JSON responses, so a browser downloads your dashboard or health JSON instead of rendering it. I serve the UI from GitHub Pages and added a small &lt;a href="https://prabhakaran-jm.github.io/failuredna/api.html" rel="noopener noreferrer"&gt;API status page&lt;/a&gt; that fetches and displays &lt;code&gt;/health/ready&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS is the gateway's job, not the app's.&lt;/strong&gt; The FC gateway already injects &lt;code&gt;Access-Control-*&lt;/code&gt; headers (it even reflects the request origin). The app's only CORS responsibility is to return &lt;strong&gt;200 on OPTIONS&lt;/strong&gt; — if it 405s the preflight, the browser blocks every POST. Adding app-level CORS headers on top just produces duplicates the browser also rejects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch for stale images.&lt;/strong&gt; Pushing a tag to ACR doesn't update a running function; you must repoint it, and FC can serve a cached image. I added a &lt;code&gt;/health/cors-debug&lt;/code&gt; endpoint and a &lt;code&gt;build&lt;/code&gt; marker so "is my new code actually live?" is a one-glance check.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do next
&lt;/h2&gt;

&lt;p&gt;The most interesting open problem is the &lt;code&gt;inspect&lt;/code&gt; disposition. Today the deterministic gate hard-removes &lt;code&gt;avoid&lt;/code&gt; actions but leaves &lt;code&gt;inspect&lt;/code&gt; ones available with a warning. The right next step is a real verification tool behind &lt;code&gt;inspect&lt;/code&gt; — so a stale success is &lt;em&gt;checked&lt;/em&gt; against the current environment, not just flagged. That keeps the thesis intact: let the model be creative where creativity helps, and let deterministic code (and real checks) hold the line where being wrong is expensive.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Try it:&lt;/strong&gt; &lt;a href="https://prabhakaran-jm.github.io/failuredna/" rel="noopener noreferrer"&gt;Live dashboard&lt;/a&gt; · &lt;a href="https://prabhakaran-jm.github.io/failuredna/api.html" rel="noopener noreferrer"&gt;API status&lt;/a&gt; · &lt;a href="https://github.com/prabhakaran-jm/failuredna" rel="noopener noreferrer"&gt;GitHub (MIT)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Built with &lt;strong&gt;Qwen Cloud&lt;/strong&gt; + &lt;strong&gt;Alibaba Cloud Function Compute&lt;/strong&gt; and &lt;strong&gt;RDS pgvector&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>qwen</category>
      <category>hackathon</category>
      <category>ai</category>
      <category>alibabacloud</category>
    </item>
    <item>
      <title>How I Built MCP Time-Traveler with Kiro: A Developer’s Journey Through Vibe Coding, Specs, Steering, Hooks, and MCP</title>
      <dc:creator>Prabhakaran Jayaraman Masani</dc:creator>
      <pubDate>Tue, 02 Dec 2025 23:44:14 +0000</pubDate>
      <link>https://dev.to/prabhakaranjm/how-i-built-mcp-time-traveler-with-kiro-a-developers-journey-through-vibe-coding-specs-m7g</link>
      <guid>https://dev.to/prabhakaranjm/how-i-built-mcp-time-traveler-with-kiro-a-developers-journey-through-vibe-coding-specs-m7g</guid>
      <description>&lt;p&gt;When the Kiroween Hackathon was announced, I wanted to try something different — something playful, something nostalgic, and something that would push the boundaries of what an AI-powered IDE like Kiro could help me build.&lt;/p&gt;

&lt;p&gt;Most hackathon projects either look forward into the future or try to solve an immediate problem.&lt;br&gt;
I wanted to look backward.&lt;/p&gt;

&lt;p&gt;That’s how I came up with MCP Time-Traveler — an app that reconstructs historical tech stacks from 2015 to 2025 across Node, Python, and Ruby, using real version data from npm, PyPI, and RubyGems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj92vprpqqszqangv264l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj92vprpqqszqangv264l.png" alt=" " width="627" height="926"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What surprised me most wasn’t the idea.&lt;br&gt;
It was how quickly Kiro turned it into a real, working project.&lt;/p&gt;

&lt;p&gt;This is the story of how it came to life.&lt;/p&gt;

&lt;p&gt;🌱 Where the Idea Started&lt;/p&gt;

&lt;p&gt;Developers often discuss “what stack should I use?”&lt;br&gt;
But rarely do we ask, “what did this stack look like five or ten years ago?”&lt;/p&gt;

&lt;p&gt;I imagined a simple interface:&lt;/p&gt;

&lt;p&gt;Choose a language → choose a framework → pick a year → get the entire runtime + dependency stack for that year.&lt;/p&gt;

&lt;p&gt;But the real twist was this:&lt;/p&gt;

&lt;p&gt;I didn’t want to fake the data.&lt;br&gt;
I wanted to fetch it from real package registries.&lt;/p&gt;

&lt;p&gt;To get there, I needed multiple moving pieces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A frontend&lt;/li&gt;
&lt;li&gt;An API&lt;/li&gt;
&lt;li&gt;A shared types layer&lt;/li&gt;
&lt;li&gt;A custom MCP server&lt;/li&gt;
&lt;li&gt;Real registry integrations&lt;/li&gt;
&lt;li&gt;Kiro support end-to-end&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a solo developer, that’s a lot.&lt;br&gt;
But Kiro made it feel surprisingly manageable.&lt;/p&gt;

&lt;p&gt;⚡ Vibe Coding: Turning Loose Thoughts into a Real Project&lt;/p&gt;

&lt;p&gt;I started with vibe coding — simply talking to Kiro about the concept.&lt;/p&gt;

&lt;p&gt;Within minutes, Kiro created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A full monorepo structure&lt;/li&gt;
&lt;li&gt;An Express API&lt;/li&gt;
&lt;li&gt;A React/Vite frontend&lt;/li&gt;
&lt;li&gt;Shared TypeScript types&lt;/li&gt;
&lt;li&gt;A starter MCP server&lt;/li&gt;
&lt;li&gt;Initial routes and validation logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What stood out most was that the project didn’t feel like a patchwork of generated snippets.&lt;br&gt;
Kiro aligned each part with the others, right from the beginning.&lt;/p&gt;

&lt;p&gt;It felt like I was pair-programming with an engineer who understood architecture.&lt;/p&gt;

&lt;p&gt;📘 Specs: Moving from Exploration to Structure&lt;/p&gt;

&lt;p&gt;Once the idea was clear, I moved into spec-driven development, which Kiro handles beautifully.&lt;/p&gt;

&lt;p&gt;I wrote two spec files:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;.kiro/specs/app-spec.md&lt;/li&gt;
&lt;li&gt;.kiro/specs/mcp-spec.md&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These specs defined:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input/output contracts&lt;/li&gt;
&lt;li&gt;Type structures&lt;/li&gt;
&lt;li&gt;Expected API behavior&lt;/li&gt;
&lt;li&gt;Input validation&lt;/li&gt;
&lt;li&gt;Error shapes&lt;/li&gt;
&lt;li&gt;Integration points&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After that, I could simply tell Kiro:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;“Update the API implementation based on the current spec.”&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And Kiro updated everything — API routes, types, helpers — consistently across the monorepo.&lt;/p&gt;

&lt;p&gt;Specs transformed the project from something exploratory into something internally coherent.&lt;/p&gt;

&lt;p&gt;🎛 Steering Docs: Teaching Kiro My Preferences&lt;/p&gt;

&lt;p&gt;AI systems generate excellent code, but consistency matters in large codebases.&lt;/p&gt;

&lt;p&gt;So I added .kiro/steering/coding-style.md to describe:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Naming conventions&lt;/li&gt;
&lt;li&gt;Error formats&lt;/li&gt;
&lt;li&gt;TypeScript patterns&lt;/li&gt;
&lt;li&gt;Folder structure rules&lt;/li&gt;
&lt;li&gt;Expected comments&lt;/li&gt;
&lt;li&gt;File layout preferences&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result?&lt;/p&gt;

&lt;p&gt;Every part of the project — whether generated on day one or day five — looked like it came from the same author.&lt;br&gt;
This eliminated cleanup time and made iteration much faster.&lt;/p&gt;

&lt;p&gt;🔌 The MCP Server: The Heart of the Project&lt;/p&gt;

&lt;p&gt;The custom MCP server is what makes MCP Time-Traveler more than a demo.&lt;/p&gt;

&lt;p&gt;I built three MCP tools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;npm historical version lookup&lt;/li&gt;
&lt;li&gt;PyPI historical version lookup&lt;/li&gt;
&lt;li&gt;RubyGems version lookup&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Kiro helped generate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The MCP tool schema&lt;/li&gt;
&lt;li&gt;Validation logic&lt;/li&gt;
&lt;li&gt;Error handling&lt;/li&gt;
&lt;li&gt;The tool handler implementation&lt;/li&gt;
&lt;li&gt;EOF-safe request/response types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The MCP layer allowed the app to fetch real, accurate ecosystem data — not hardcoded values.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node 4.9.1 + Express 4.13.4 for 2015&lt;/li&gt;
&lt;li&gt;Python 3.7.17 + Django 2.1.15 for 2018&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Seeing real historical stacks appear in the UI felt magical.&lt;/p&gt;

&lt;p&gt;🔁 Hooks: Automating the Workflows That Slow You Down&lt;/p&gt;

&lt;p&gt;To keep things consistent, I added two Kiro agent hooks:&lt;/p&gt;

&lt;p&gt;1️⃣ Scaffold regeneration hook&lt;/p&gt;

&lt;p&gt;Triggered whenever specs changed, ensuring project structure stayed aligned.&lt;/p&gt;

&lt;p&gt;2️⃣ Pre-commit hook&lt;/p&gt;

&lt;p&gt;Performed type checks + lightweight build steps.&lt;/p&gt;

&lt;p&gt;These hooks acted like guardrails.&lt;br&gt;
As a solo developer, they helped maintain discipline and consistency — without me having to remember every detail.&lt;/p&gt;

&lt;p&gt;☁️ Deploying the Full Project&lt;/p&gt;

&lt;p&gt;The final structure:&lt;br&gt;
&lt;strong&gt;API&lt;/strong&gt;→ deployed to Heroku&lt;br&gt;
&lt;strong&gt;Frontend&lt;/strong&gt; → deployed to Vercel&lt;br&gt;
&lt;strong&gt;MCP Server&lt;/strong&gt; → runs locally for Kiro during development&lt;br&gt;
&lt;strong&gt;GitHub Repo&lt;/strong&gt; → public, open source, MIT licensed&lt;/p&gt;

&lt;p&gt;You can try it here:&lt;/p&gt;

&lt;p&gt;🔗 Frontend:&lt;br&gt;
&lt;a href="https://mcp-time-traveler.vercel.app/" rel="noopener noreferrer"&gt;https://mcp-time-traveler.vercel.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 API health endpoint:&lt;br&gt;
&lt;a href="https://mcp-time-traveler-api-04b9f0b0b1ae.herokuapp.com/health" rel="noopener noreferrer"&gt;https://mcp-time-traveler-api-04b9f0b0b1ae.herokuapp.com/health&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Source code:&lt;br&gt;
&lt;a href="https://github.com/prabhakaran-jm/mcp-time-traveler" rel="noopener noreferrer"&gt;https://github.com/prabhakaran-jm/mcp-time-traveler&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💡 What This Project Taught Me&lt;/p&gt;

&lt;p&gt;Building MCP Time-Traveler showed me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How AI-powered IDEs elevate solo developers&lt;/li&gt;
&lt;li&gt;How vibe coding excels at early exploration&lt;/li&gt;
&lt;li&gt;How specs enforce structure and long-term consistency&lt;/li&gt;
&lt;li&gt;How steering docs unify the codebase&lt;/li&gt;
&lt;li&gt;How MCP bridges AI and real-world data&lt;/li&gt;
&lt;li&gt;How hooks automate away repetitive tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kiro didn’t just help me build faster.&lt;br&gt;
It helped me build more cleanly, more predictably, and more enjoyably.&lt;/p&gt;

&lt;p&gt;🎃 Final Thoughts&lt;/p&gt;

&lt;p&gt;When I started this project, I thought the MCP server would be the hardest part. Turns out, the hardest part was believing that an AI-assisted IDE could actually guide a full multi-service build.&lt;/p&gt;

&lt;p&gt;But Kiro did — consistently, reliably, and creatively.&lt;/p&gt;

&lt;p&gt;MCP Time-Traveler became more than just a hackathon project.&lt;br&gt;
It became a blueprint for how I want to build future tools.&lt;/p&gt;

&lt;h1&gt;
  
  
  kiro
&lt;/h1&gt;

</description>
      <category>programming</category>
      <category>ai</category>
      <category>tooling</category>
      <category>kiro</category>
    </item>
  </channel>
</rss>
