docs: add bedrock:CountTokens to IAM policy examples#1181
Merged
Conversation
Strands SDK uses bedrock:CountTokens to estimate token usage before model calls, enabling proactive context window management. Users running Strands-based agents need this permission in their IAM policies.
agentcore-cli-automation
suggested changes
May 8, 2026
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Thanks for adding bedrock:CountTokens — it's a real pain point for Strands-based agents. The JSON is valid and the boundary-policy change looks good. A few things to resolve before merging:
- The addition to
iam-policy-user.jsondoesn't match the stated rationale (see inline comment). Strands runs inside the agent at runtime under the execution role, not under the developer's user credentials. docs/PERMISSIONS.mddescribes what each policy grants in prose; it now drifts out of sync with the updated JSON.- The PR description says this is the companion to a CDK constructs PR that adds
bedrock:CountTokensto theAgentCoreRuntimeexecution role — that change isn't onmaininagentcore-l3-cdk-constructsyet (src/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.ts:74still lists onlyInvokeModel/InvokeModelWithResponseStream). Worth linking / coordinating so users following the docs aren't blocked by CDK-vended roles that still lack the permission.
Contributor
Coverage Report
|
Hweinstock
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bedrock:CountTokensto bothdocs/policies/iam-policy-boundary.jsonanddocs/policies/iam-policy-user.jsonWhy
The Strands SDK calls
bedrock:CountTokensto estimate token usage before model calls, enabling proactive context window management. Users running Strands-based agents need this permission included in their IAM policies. Without it, token estimation fails silently.Related
Companion L3 constructs PR: https://github.com/aws/agentcore-l3-cdk-constructs/pull/213
Test plan