Menu

Post image 1
Post image 2
1 / 2
0

5 production bugs I debugged in popular AI libraries this week (and the fix patterns you can steal)

DEV Community·karchichen·23 days ago
#osFKIsrF
Reading 0:00
15s threshold

If you're building anything with LangChain, OpenAI's Python SDK, or LangGraph in production, you've probably run into the same class of bugs that have been quietly breaking real apps for months. Over the last week I dug through ~70 open issues across these libraries while doing client debugging work, and there are five patterns that come up constantly — each with a non-obvious root cause and a 5-line fix. Here they are, ranked by how much pain they cause. 1. _create_usage_metadata crashes when service_tier is set and cached_tokens is missing Repo: langchain-ai/langchain ( #36657 ) The trap: prompt_details = response . get ( " prompt_details " , {}) prompt_details . get ( " cached_tokens " ) # <-- this line is the bug Enter fullscreen mode Exit fullscreen mode This stores None in the dict explicitly when cached_tokens is missing. The subsequent .get(key, 0) then sees the key as present and returns None instead of the default 0 — classic Python dict.get + explicit-None trap. The fix: prompt_details .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More