← Back to PRs

#14488: Fix Telegram default account listing and CLI cache-write usage mapping

by abdulbb open 2026-02-12 06:42 View on GitHub →
channel: telegram agents stale size: S
## Summary - include the `default` Telegram account in `listTelegramAccountIds()` whenever top-level `channels.telegram.botToken` or `tokenFile` is configured, even when named accounts exist - map Anthropic `cache_creation_input_tokens` to CLI `cacheWrite` usage in `parseCliJson()` / `parseCliJsonl()` so usage + cost reporting is accurate - add focused regression tests for both fixes in `src/telegram/accounts.test.ts` and new `src/agents/cli-runner.helpers.test.ts` ## Test plan - [x] `pnpm lint` - [x] `pnpm exec vitest run src/telegram/accounts.test.ts src/agents/cli-runner.helpers.test.ts` ## Linked issues - fixes #14366 - fixes #14454 ## Notes - AI-assisted: yes Made with [Cursor](https://cursor.com) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts two areas: - **CLI runner usage parsing**: `toUsage()` now maps Anthropic’s `cache_creation_input_tokens` field into the internal `usage.cacheWrite` field so usage/cost reporting counts cache writes correctly. - **Telegram account enumeration**: `listTelegramAccountIds()` now includes the implicit `default` Telegram account when a top-level `channels.telegram.botToken` or `tokenFile` is configured, even if named accounts exist. This is used by onboarding/inline-buttons flows and other account selection logic. It also adds targeted Vitest coverage for both behaviors (`src/agents/cli-runner.helpers.test.ts`, `src/telegram/accounts.test.ts`). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Changes are small, targeted, and consistent with existing normalization logic (e.g., usage.ts already maps cache_creation_input_tokens). Telegram default-account inclusion is gated on an actual configured top-level token source, preventing spurious IDs while fixing missing-default listings. Added focused tests cover the regressions. - No files require special attention <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs