AWS AgentCore Gets Lambda Hooks and Uses 34% Fewer Tokens Than Alternatives
AWS has updated the AgentCore harness, its ready-made environment for AI agents, and added hooks. Before a customer refund goes out, your Lambda function can block any amount above $500. AWS claims the agent uses roughly 34% fewer tokens than on other popular harnesses because old conversation history is compressed. Safety rules are more reliable when written in code than when requested in a prompt.
AI-processed from AWS Machine Learning Blog; edited by Hamidun News
Picture a support agent that sorts out an order on its own and can refund the customer's money. Telling the model in a prompt "don't refund more than $500" is unreliable, because its behavior is unpredictable. AWS proposes a different solution in the updated Amazon Bedrock AgentCore harness, a managed "harness" for AI agents: a ready-made bundle of model, prompt, tools and context management that AWS itself runs and scales.
It is now built on the Strands harness (an open harness under the Apache 2.0 license, released by AWS earlier this year) and gains lifecycle hooks, which are points in the agent's work where your ordinary code runs. For example, a Lambda function (a small function in the AWS cloud) can check the amount before a refund and block the action.
In addition, according to AWS, the harness uses roughly 34% fewer tokens than other popular harnesses thanks to context compression. You don't need to connect any new resources: the update arrives in the harness you already use.
What agents get by default
If you don't specify a model, system prompt and history truncation policy in the configuration, the harness fills in a recommended set. The default model will change as new ones are released, and explicitly set options always take priority. The system prompt teaches the agent to gather context, choose suitable tools, not abandon a task halfway, react to failures, and verify the result before reporting.
Some features directly affect the token bill. Automatic prompt caching (for now only for Anthropic models in Amazon Bedrock) stores the system instruction, tool descriptions and conversation history, and repeated calls read them at a reduced price. When the context window reaches a configurable threshold, older messages are collapsed into a short summary while recent ones stay as they are. According to AWS, this is what produces the roughly 34% savings. That figure comes from the vendor, and the article offers no independent confirmation.
The set of built-in tools has expanded:
- todo_write stores a task plan and restores it in later calls within the same session, even after history compression;
- subagent hands a self-contained task to a fresh "worker" and returns the result to the main agent;
- web_fetch pulls in the content of a web page;
- separate read, write and edit tools let you grant the agent only the file permissions it needs;
- large tool results are moved out of the context: the agent sees a preview and fetches the full version if needed.
Hooks: verification by code, not by hoping the prompt works
There are four events. before_invocation fires before the request is processed, and a denial stops the invocation. before_tool_call runs after the model has proposed an action but before it executes: a denial skips the call, and the agent keeps working. after_tool_call fires once the result already exists: the result is kept, but further reasoning stops. after_invocation reports the decision after the invocation finishes, and output already sent to the user cannot be recalled.
In the AWS example, a Lambda check sits in front of the issue_refund tool. If the amount exceeds $500, the function returns deny with the reason "Refund exceeds the $500 auto-approval limit". The refund is skipped, and the agent can tell the customer that the request has been passed on for approval. Each decision appears in the InvokeHarness response stream as a hookEvent, so auditing comes almost for free.
Important details. Only Lambda hooks can change the course of the agent's work: they are synchronous and respond with allow or deny. Hooks on Amazon SNS and Amazon EventBridge are notifications only and do not block the loop. Hooks also apply to subagents, so delegation does not bypass the refund policy. If the Lambda crashes or times out, failureMode applies, and it defaults to deny, meaning the action is blocked. Hooks are configured through CreateHarness or UpdateHarness.
How to try it and what to pin in the config
A harness is created with a single command through the AgentCore CLI, which is installed via npm. In the AWS example, the team built a research coordinator: in a single call it launches subagents (a researcher, a synthesizer and a reviewer) and returns one unified report. For hooks, there is a Refund Desk demo in the AgentCore samples repository on GitHub: a six-step walkthrough of all four events and the Lambda, SNS and EventBridge targets.
If your application has strict security requirements, pin them explicitly. The model is fixed by its ID, the system prompt is replaced via systemPrompt, and the context policy is set via truncation. allowedTools matters especially: if you omit it or set it to ["*"], the set of built-in tools may grow over time. List only what you need, for example ["read", "web_fetch"], which allows reading files and loading pages without shell access or the ability to modify files.
The practical takeaway is simple: if an agent touches money, customer data or external systems, it is more reliable to write restrictions in code, through hooks and an explicit tool list, than to ask for them in a prompt.
- Nov 19, 2026Skyflow in AgentCore Gateway hides personal data from AI agents' tools
- Nov 19, 2026Accenture Cuts Clients' Bedrock Token Costs by 40–85%
- Nov 19, 2026Two pods share one A10G GPU on Amazon EKS: NVIDIA Run:ai gave each 8 GiB
- Nov 19, 2026Anthropic goes public and raises $81.3 billion, beating SpaceX's $75 billion record
Key Questions Answered
What agents get by default?
If you don't specify a model, system prompt and history truncation policy in the configuration, the harness fills in a recommended set. The default model will change as new ones are released, and explicitly set options always take priority. The system prompt teaches the agent to gather context, choose suitable tools, not abandon a task halfway, react to failures, and verify the result before reporting. Some features directly affect the token bill.
What are the key details on Hooks: verification by code, not by hoping the prompt works?
There are four events. before_invocation fires before the request is processed, and a denial stops the invocation. before_tool_call runs after the model has proposed an action but before it executes: a denial skips the call, and the agent keeps working. after_tool_call fires once the result already exists: the result is kept, but further reasoning stops. after_invocation reports the decision after the invocation finishes, and output already sent to the user cannot be recalled.
How to try it and what to pin in the config?
A harness is created with a single command through the AgentCore CLI, which is installed via npm. In the AWS example, the team built a research coordinator: in a single call it launches subagents (a researcher, a synthesizer and a reviewer) and returns one unified report. For hooks, there is a Refund Desk demo in the AgentCore samples repository on GitHub: a six-step walkthrough of all four events and the Lambda, SNS and EventBridge targets.
Ship AI Faster with Founders, Engineers & Weekly Architecture Reviews
Inside Vibe Club (hamidun.com/club) — weekly live masterminds with Zhemal Khamidun, Tech Radar, full LMS access, and 370+ production Claude Code skills.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.