[DOCS] Python SDK count_tokens endpoint missing ComputerUse and CodeExecution tool types

Resolved 💬 2 comments Opened Jan 25, 2026 by coygeek Closed Feb 12, 2026

Documentation Type

Incorrect/outdated documentation

Documentation Location

https://platform.claude.com/docs/en/api/python/messages/count_tokens

Section/Topic

Parameters section, tools parameter definition

Current Documentation

The non-beta messages.count_tokens endpoint defines tools as:

tools: Optional[Iterable[MessageCountTokensToolParam]]

This type only includes Tool, ToolBash..., ToolTextEditor..., and WebSearchTool....

Meanwhile, the beta endpoint (beta.messages.count_tokens) defines:

tools: Optional[Iterable[Tool]]

Which includes BetaToolComputerUse20241022, BetaCodeExecutionTool20250522, and other beta tool types.

What's Wrong or Missing?

The non-beta count_tokens endpoint's tools parameter type (MessageCountTokensToolParam) excludes:

  • ComputerUse tools
  • CodeExecution tools

If the non-beta endpoint is intended to support token counting for all available tools (even beta features), these definitions are missing. Users cannot accurately estimate tokens for payloads involving computer use or code execution.

Suggested Improvement

Option A: If non-beta should support all tools, update MessageCountTokensToolParam to include:

  • ToolComputerUse variants
  • CodeExecutionTool variants

Option B: If these tools require the beta endpoint, add a note:

"For token counting with ComputerUse or CodeExecution tools, use the beta endpoint beta.messages.count_tokens."

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

| Page | Section | Context |
|------|---------|---------|
| https://platform.claude.com/docs/en/api/python/messages/count_tokens | Parameters > tools | Type definition missing ComputerUse/CodeExecution |

Verification: Grep for ComputerUse|CodeExecution returns 0 matches in non-beta count_tokens.md, 20 matches in beta/messages/count_tokens.md.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗