Skip to content

docs: add bedrock:CountTokens to IAM policy examples#1181

Merged
jariy17 merged 1 commit intomainfrom
feat/add-count-tokens-iam-policy
May 8, 2026
Merged

docs: add bedrock:CountTokens to IAM policy examples#1181
jariy17 merged 1 commit intomainfrom
feat/add-count-tokens-iam-policy

Conversation

@jariy17
Copy link
Copy Markdown
Contributor

@jariy17 jariy17 commented May 8, 2026

Summary

  • Adds bedrock:CountTokens to both docs/policies/iam-policy-boundary.json and docs/policies/iam-policy-user.json

Why

The Strands SDK calls bedrock:CountTokens to 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

  • Verify policy JSON is valid
  • No automated tests needed (docs only)

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.
@jariy17 jariy17 requested a review from a team May 8, 2026 03:59
@github-actions github-actions Bot added size/xs PR size: XS agentcore-harness-reviewing AgentCore Harness review in progress labels May 8, 2026
Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. The addition to iam-policy-user.json doesn'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.
  2. docs/PERMISSIONS.md describes what each policy grants in prose; it now drifts out of sync with the updated JSON.
  3. The PR description says this is the companion to a CDK constructs PR that adds bedrock:CountTokens to the AgentCoreRuntime execution role — that change isn't on main in agentcore-l3-cdk-constructs yet (src/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.ts:74 still lists only InvokeModel / InvokeModelWithResponseStream). Worth linking / coordinating so users following the docs aren't blocked by CDK-vended roles that still lack the permission.

Comment thread docs/policies/iam-policy-user.json
Comment thread docs/policies/iam-policy-boundary.json
@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 43.19% 9034 / 20915
🔵 Statements 42.47% 9592 / 22585
🔵 Functions 40.02% 1558 / 3893
🔵 Branches 40% 5811 / 14527
Generated in workflow #2665 for commit 5041c0b by the Vitest Coverage Report Action

Comment thread docs/policies/iam-policy-boundary.json
Comment thread docs/policies/iam-policy-user.json
@jariy17 jariy17 merged commit 804e041 into main May 8, 2026
31 checks passed
@jariy17 jariy17 deleted the feat/add-count-tokens-iam-policy branch May 8, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants