LangChain: Multimodal Token Counting Gets Smarter

Today we're diving into a game-changing improvement to LangChain's token counting system that finally handles images properly! The star of the show is jiaming2li's multimodal support enhancement that fixes a major overestimation issue, plus we've got some helpful middleware exports and quality-of-life improvements from Mason Daugherty.

Duration: PT3M55S

Episode overview

This episode is a short developer briefing from LangChain.

It explains recent repository work in plain language.

  • Show: LangChain
  • Published: 2026-01-27T11:04:10Z
  • Audio duration: PT3M55S

Transcript excerpt

This excerpt keeps the crawler page concise. Listen to the episode or use the RSS feed for the full update.

Hey there, brilliant builders! Welcome back to another episode of the LangChain podcast. I'm your host, and I am genuinely excited to dig into what's been happening in the codebase. Grab your favorite beverage because we've got some really thoughtful improvements to talk about today.

So let's jump right into the main event - and this one's a real problem-solver. Our contributor jiaming2li just merged a fantastic PR that tackles something I bet many of you have run into: wildly inaccurate token counting when working with images.

Here's the story - you know how LangChain has this `count_tokens_approximately` function that helps you estimate token usage? Well, it had a pretty significant blind spot when it came to multimodal content. When you fed it base64-encoded images, it was treating them like regular text and counting them as roughly…

The real pain point was that this overestimation was breaking context management tools like `trim_messages`. Imagine you're building a chatbot that handles images, and every single image is being counted as if it's a short novel. Your context trimming logic would go haywire, thinking you're way over your token…

jiaming2li's solution is beautifully…

What…

Nearby episodes from LangChain

  1. Token Counting Gets Smarter (With Some Growing Pains)
  2. Bug Squashing Season and Thread Safety Wins
  3. Multimodal Magic and Documentation Love
  4. Small Touches, Big Impact
  5. XAI Streaming Fix and Spring Cleaning Day
  6. Dynamic Tools and Spring Cleaning Day
  7. Clean Code Standards & Better Documentation
  8. The Polish Pass - When Small Fixes Make Big Differences