helpers/tokens.py.dox.md
tokens.py helper module.tokens.py because this directory is intentionally flat.tokens.py owns the runtime implementation.tokens.py.dox.md owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.count_tokens(text: str, encoding_name=...) -> intapproximate_tokens(text: str) -> intsanitize_embedded_image_data_urls(text: str) -> strapproximate_prompt_tokens(text: str) -> inttrim_to_tokens(text: str, max_tokens: int, direction: Literal['start', 'end'], ellipsis: str=...) -> strAPPROX_BUFFER, TRIM_BUFFER, EMBEDDED_IMAGE_DATA_PLACEHOLDER, _EMBEDDED_IMAGE_DATA_URL_PATTERN.re, tiktoken, typing.re.compile, tiktoken.get_encoding, encoding.encode, _EMBEDDED_IMAGE_DATA_URL_PATTERN.sub, approximate_tokens, count_tokens, sanitize_embedded_image_data_urls.tests/test_chat_compaction.pytests/test_default_prompt_budget.pytests/test_history_compression_wait.pytests/test_mcp_handler_multimodal.pytests/test_oauth_codex.pytests/test_oauth_gemini_api.pytests/test_oauth_xai_grok.pytests/test_ws_security.pyNo child DOX files.