llm 0.37.3
- Source
- github.com
- Author
- simonw
- Date

Context
Version 0.37.3 of , Simon Willison's command-line tool and Python library for working with language models, is a bug-fix release whose most useful fixes are in , where a model asks the program to run a function and send back the result (release notes). Three of them fix cases where a tool call did the wrong thing or crashed.
The first concerns Python tools written as `async def` functions and used with an ordinary synchronous model. LLM runs such a tool with asyncio.run(), which cannot start inside an event loop that is already running, as one is in a Jupyter notebook. So in a notebook the tool never ran, and the model received the error message as the tool's result. LLM now runs the tool in a separate thread with its own event loop. The updated documentation adds a limit: such a tool should not rely on objects that belong to the notebook's own loop, such as locks, queues or async HTTP clients created outside it, and waiting on something that loop has to finish will hang, because the loop is blocked until the tool returns. Its advice for running tools on the current loop is to use an async model.
The other two fixes are in LLM's support for OpenAI's Chat Completions format, which OpenAI's own models and compatible services share. When such a service streams a response, each tool call arrives in fragments, and OpenAI labels every fragment with an `index` saying which call it belongs to. Some compatible services, including the one Google DeepMind offers for Gemini, leave that label out, so LLM merged several tool calls in one response into a single call. The fix treats a fragment with a new call ID, or a function name without an ID, as the start of a new call, and because Gemini repeats the ID and name on every fragment, a repeated ID continues the call it names. Separately, when any Chat Completions model returns tool arguments that are not valid JSON, for instance because they were cut off part way through, LLM no longer crashes. It skips the tool and sends the error back to the model as the tool result, so the model can try again.
One fix is worth knowing about because the old behavior gave no sign of failure. When content moved between existing IDs in the same batch, for example two IDs swapping their text, `llm embed-multi` and `collection.embed_multi()` skipped those items and left the old embeddings and stored content in place. They now update them.
- An async def tool given to a synchronous model inside a running event loop, such as a Jupyter notebook, previously never ran and returned an asyncio.run() error as its result. llm 0.37.3 runs it in a separate thread with its own event loop.
- If an OpenAI Chat Completions model returns tool-call arguments that are not valid JSON, for example cut off midway, llm no longer raises JSONDecodeError: the tool is not run and the error goes back to the model as the tool result.
- Streamed tool calls from OpenAI-compatible endpoints that omit the index field, including Gemini's, were merged into a single call when one response held several. This release keeps them separate.
- embed_multi() and llm embed-multi now update items when content moves between existing IDs in one batch, such as two IDs swapping content. Before, those items were skipped and kept stale embeddings and stored content.
- LLM — A large language model — the neural network behind tools like Claude and ChatGPT, trained on huge amounts of text to predict what comes next.
- tool use — A model's ability to call external functions — run code, search the web, edit files — instead of only generating text.
- embedding — A list of numbers representing a piece of text's meaning, so that similar meanings end up numerically close and can be searched.
Checking sign-in…
Loading comments…

