Urgent.News

What's breaking now, across thousands of outlets.

AI

Python 3.15 for AI agent builders: 5 changes worth knowing

Before you start: LangGraph doesn't install on Python 3.15 yet. One of its dependencies (ormsgpack) has no build for 3.15. Keep production agents on 3.13 or 3.14 for now. Python 3.15 won't make your agent faster. An agent spends most of its time waiting for the model, and a faster Python doesn't change that. Five changes do make building agents easier, though: faster startup, faster answers,…

Python 3.15 introduces several enhancements that can simplify the process of building AI agents. Although it won't make agents faster, there are five key improvements worth noting.

Firstly, startup time has been reduced through lazy imports. Pythons 3.15 loads modules only when needed, which can significantly speed up cold starts in serverless environments and CLI tools.

Secondly, TaskGroup.cancel() allows for faster agent responses. When one source answers a query, the rest can be stopped, reducing wait times from several seconds to just 0.8 seconds in testing.

Thirdly, the Tachyon profiler simplifies debugging. When an agent "hangs" in production, this command displays the status of each task, saving time by avoiding the need to restart the process. It's recommended to assign names to tasks for clearer output.

Fourthly, TypedDict(closed=True) enhances state safety. This ensures that agent state, typically a TypedDict, doesn't contain unexpected additional fields, which could end up in checkpoints and logs. However, this only works within the type checker, not at runtime.

Lastly, sentinel and frozendict offer a simpler coding experience. sentinel helps distinguish between "no value given" and None, while frozendict prevents accidental modifications to dictionary keys. Keep in mind that these features are type-checked, not runtime-enforced.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Thursday 15 October →