Agents That Write Their Own Tools at Runtime — Sandhya Subramani, AWS

Loading slides…

Read the talk

Agents That Write Their Own Tools at Runtime

Selected presentation frame from Agents That Write Their Own Tools at Runtime — Sandhya Subramani, AWS at 672 secondsOpen full source frame
Slide diagram of swarm, graph, and workflow patterns for multi-agent systems.

Sandhya Subramani demonstrates how Strands Agents can write and load new tools during a running conversation, extend the same mechanism to sub-agents, and expose the evaluations and permissions that self-modifying systems need.

From a talk by Sandhya Subramani

At a glance

Ideas worth remembering

  • Meta-tooling combines a prompted tool template with editor, shell, and dynamic loading tools so an agent can create and use a new capability without restarting.

  • The same mechanism can create sub-agents: the Hawaii planner writes flight, activities, and itinerary agents from an ordinary travel request.

  • Generated code does not supply missing external access. The travel demo cannot retrieve real-time information without a tool connected to a real-world API.

  • Evaluate goal completion, answer correctness, tool selection, parameters, and inter-agent messages; a convincing final response can conceal an incorrect execution path.

  • Self-modifying agents need sandboxed code execution, constrained tools and permissions, controlled user access, and telemetry because the ability to write also enables modification and deletion.

A running agent acquires a capability it did not start with

Generating code is already familiar. The harder question is what happens when a running application encounters a task its existing tools cannot handle. Sandhya Subramani, an AWS developer advocate, opens with the possibility of an agent recognizing that gap, writing the missing code, and using it without restarting. Her first Strands Agents demonstration makes that smaller, concrete capability visible before turning to the larger ambition of self-repair.

The agent begins with an empty directory of task-specific tools. It already has a system prompt and three tools for creating and loading code, so “zero tools” describes its starting application capabilities rather than its entire tool inventory. There is no calculator waiting to be called. A request for help with a complex mathematical expression prompts the agent to create one.

The observable change is a new calculator tool in the tools directory. The agent describes its supported operations, including minimum and maximum, and then receives a follow-up request to square a number. It calls the calculator it just wrote and returns an answer within the same running session. Code generation has changed the set of actions available to the agent.

Selected presentation frame from Agents That Write Their Own Tools at Runtime — Sandhya Subramani, AWS at 212 secondsOpen full source frame
The demo shows a newly created math calculator tool and its use in the same session.

A character-counting request tests whether that expansion can happen again. The agent checks its available tools, finds that the calculator does not supply the needed capability, and creates a character counter. It reports 28 letters for a random input. Subramani immediately notices the weakness of that test: she should have chosen something she could count herself. She follows with three letters, letting the conversation carry forward the counting task without restating it. The exchange illustrates tool creation, invocation, and conversational continuity; the random-input result alone does not establish counting accuracy.

0:120:42

Meta-tooling separates writing code from making it callable

This pattern is called meta-tooling. Strands Agents supplies the agent harness: the structure that connects a model to tools and runs the interaction. Subramani presents it as an open-source, AWS-maintained framework with multiple model providers and community-written tools. Keeping that structure separate from the model lets developers experiment with another model without rebuilding the surrounding architecture.

The starting toolkit divides the work into three mechanisms:

  • Editor: writes the new tool’s code.
  • Shell: gives the agent access to its directory and codebase so it can inspect what is already there.
  • Load tool: loads a tool from the directory dynamically, making generated code available during the running session.

The system prompt supplies the construction rules. It describes a tool template and specification, tells the agent where to write files, and includes the @tool decorator that identifies a function as a tool. It also tells the agent to check whether a suitable tool exists before creating another. That instruction keeps the character-counter example from becoming “write new code for every message”: reuse comes first, and generation fills a missing capability.

Dynamic loading is the crucial step between a file appearing and the agent being able to use it. Subramani describes an earlier directory-loading option, then explains that loading became a tool in its own right. The agent can therefore write code and explicitly load it as part of its work. The small agent constructor combines the system prompt with the three tools; the surrounding chat loop keeps the conversation running.

Selected presentation frame from Agents That Write Their Own Tools at Runtime — Sandhya Subramani, AWS at 495 secondsOpen full source frame
Code slide highlighting dynamic tool loading from a directory.

How does a request become a new callable capability? The diagram follows the character counter through the same session. Inspecting the existing inventory, writing a file, and loading that file are separate steps. The important relationship is the return from generated code to the live agent: the next invocation can use something that was unavailable at startup.

From a counting request to a callable character counter

Count charactersThe user introduces a task the existing tools do not cover.
Check existing toolsInspect the inventory and reuse a suitable tool if one exists.
Write the counterThe editor creates a tool file using the prompted template and storage rules.
Load into the running agentThe load tool makes the generated tool available dynamically.
Call the counterThe agent uses the new tool for the input and continues the counting conversation.
The editor creates the code; dynamic loading makes it usable without restarting the conversation.
Read the diagram as text
  • Count characters. The user introduces a task the existing tools do not cover.
  • Check existing tools. Inspect the inventory and reuse a suitable tool if one exists.
  • Write the counter. The editor creates a tool file using the prompted template and storage rules.
  • Load into the running agent. The load tool makes the generated tool available dynamically.
  • Call the counter. The agent uses the new tool for the input and continues the counting conversation.
  • Count characters → Check existing tools: Find a usable capability.
  • Check existing tools → Write the counter: No suitable tool exists.
  • Write the counter → Load into the running agent: Load the generated file.
  • Load into the running agent → Call the counter: Use it in the same session.
5:076:08

A missing capability can also call for a new sub-agent

The production motivation is a request that falls outside the original application design. Subramani imagines a domestic flight-booking app receiving a request to travel from India to Hong Kong. A fixed toolset may leave the agent unable to proceed, sending the problem back to engineering. Meta-tooling offers a way to create missing functionality during the interaction. This is a proposed use case, rather than a demonstrated international booking.

The same construction mechanism can write sub-agents. Before demonstrating that, the talk distinguishes several ways agents can cooperate:

  • Swarm: sub-agents work in parallel and take different parts of a shared task.
  • Graph: one sub-agent’s result feeds into another, making the dependency between stages explicit.
  • Handoff: another named coordination pattern, though its mechanics are not developed here.
  • Workflow: a combination of patterns, potentially mixing parallel work with dependent stages.

The second demo deliberately keeps the orchestration small. Its prompt asks for two to four sub-agents and supplies a template, specification, and rules for creating them. The agent again starts with the three code-writing and loading tools. The change is what the generated code represents: a focused agent rather than a standalone utility. There is no elaborate swarm in this example.

10:0710:37

The Hawaii planner creates specialists from an ordinary request

The user-facing request is simply to plan an itinerary for Hawaii. It does not ask the system to create agents. The planning agent chooses that implementation itself and announces three focused sub-agents: a flight agent, an activities agent, and an itinerary agent. It calls the editor three times, once for each, turning a general travel request into newly written specialists.

The running system then calls the activities agent and produces travel guidance, including airports and beaches. Creating specialists does not create access to current facts: this demo has no tool connected to a real-world API, so it cannot retrieve real-time information. A weather-aware extension would need that access before a generated weather tool could fetch current conditions and use them to recommend activities.

That distinction matters for the flight-booking ambition. An agent can reorganize its work and write new code using the facilities it has been given. It still needs the external access required by the task. The Hawaii example demonstrates self-assembly and a sub-agent invocation, while live weather retrieval remains a proposed extension.

The next ambition is self-healing: inspect errors and edit the tool or agent that caused them. Subramani describes longer sessions in which audience requests break the system, it recognizes the errors, and it tries to repair its code. She also notes excessive chatter and the possible need for a maximum-token setting. Those accounts motivate the repair loop; this recording’s travel demonstration does not establish how reliably it recovers from failures. Changing the destination is another suggested reason to update an agent already created.

12:3713:07

Evaluate the outcome, the tool call, and the path between agents

Once a system can change its own capabilities, a plausible answer becomes a weak test. A booking agent might discuss flights without booking one. A balance lookup might return a sensible-looking amount for the wrong account. Subramani says Strands has eight built-in evaluations and uses the following concerns to explain what needs inspection, without enumerating all eight by name.

  • Session goal: did the requested action happen? For a flight-booking request, success means achieving the booking goal.
  • Response usefulness and correctness: does a balance answer address the question, and does its amount match the actual balance rather than an invented value?
  • Tool selection and parameters: did the agent choose the right tool and pass the right account ID? A correct tool with the wrong parameter can still produce the wrong result.
  • Inter-agent flow: did tools and sub-agents run in the required sequence, and did the messages between them carry suitable information?

These checks connect the final response to the execution that produced it. In the travel planner, inspecting only the itinerary would miss whether a specialist actually ran or whether dependent work received the information it needed. The complete session trace gives developers a way to distinguish a good-looking response from a system that performed the intended work.

15:0715:37

Protect the environment where generated code executes

Evaluation reveals behavior; it does not prevent damage. The permission to create code can also enable modification and deletion. A meta-tooling agent that writes into the wrong place could destroy existing work, even if its intended task sounds harmless. The ability demonstrated by the editor tool therefore creates a second design problem: how much of the environment should generated code be able to affect?

Subramani emphasizes sandboxing the code-execution environment itself. The protection must apply where the generated program runs, rather than stopping at a container around the agent process. She describes a recently introduced Strands feature intended to keep that execution from affecting other environments or writing and deleting in unintended locations. The talk does not develop its isolation mechanism or configuration, so that protection depends on how the execution sandbox is implemented and used.

The remaining controls address different parts of the system:

  • Tools and permissions: constrain the actions the agent and its generated code can perform.
  • User access and requests: constrain who can ask the system to act and what kinds of requests it accepts.
  • Observability: retain evaluations, OpenTelemetry, and other telemetry so developers can inspect what happened.
Selected presentation frame from Agents That Write Their Own Tools at Runtime — Sandhya Subramani, AWS at 1062 secondsOpen full source frame
Slide listing guardrails for environment, tools, permissions, and observability.

Together, these controls make experimentation more accountable. The sandbox limits where execution can cause changes, permissions limit what actions are available, and telemetry supports the evaluations of outcomes and intermediate calls. Runtime adaptation needs all of those: repairing one tool is little comfort if the repair can damage unrelated code or cannot be inspected afterward.

9:0717:06

From generating tools to changing the framework itself

The ending expands the idea in three stages: agents create tools, then create other agents, then update their own source code. Subramani frames that progression as the beginning of self-improving and self-evolving systems. Here, improvement means changing the software the system can use or execute; the demonstrations center on generated capabilities and agent code.

The most ambitious closing example concerns Strands itself. Subramani says the framework began internally three years earlier, was later opened to the community, and that its Python version wrote the TypeScript version. This is a reported development outcome rather than a demonstrated porting process; the recording does not specify the human involvement or validation behind it. It nevertheless brings the central subject back to developer tooling: the same framework used to generate a calculator can participate in building another implementation of the framework.

The closing invitation is to explore the code and slides with Subramani. The useful starting point is the modest version shown at the beginning: supply a tool template, let the agent inspect and write within a constrained environment, and load the result into the running conversation. Expanding from that mechanism to sub-agents and repairs raises the importance of checking both what the system accomplished and what it changed along the way.

18:3619:06

Resources

Transcript download
Full transcript

Loading transcript…