Skip to content
Pyrula
Pre-release: the packages are not on PyPI yet, so pip install does not resolve. Build from source to try it today.

LangChain tools

from_langchain_tool wraps a LangChain BaseTool as a Pyrula @tool. Needs pip install "pyrula[agents,langchain]".

from pyrula.agents.integrations import from_langchain_tool
from pyrula.agents.decorators.agent import agent
search = from_langchain_tool(my_langchain_tool, timeout=30.0, retry=0) # also read_only=, writes=
@agent
async def assistant(ctx, message: str) -> None:
async for _ in ctx.llm.stream(messages=[{"role": "user", "content": message}], tools=[search]):
...

The input schema comes from args_schema, else a single input: str. read_only=True lets branches run it live; writes=True marks side effects. Defaults are False, so in a branch a plain LangChain tool replays its recorded result or is refused. For a chat model, see durable_chat_model.

A sync LangChain tool runs in a thread a timeout cannot stop, and the async wrapper is retried on timeout. With retry>=1, use an async tool, keep retry=0, or make the tool idempotent by its own key (it never sees a Pyrula ToolContext). For graphs, see LangGraph.

View this page as Markdown