google-deepmind/onetwo v0.6.0
google-deepmind/onetwo
Captured source
source ↗v0.6.0
Repository: google-deepmind/onetwo
Tag: v0.6.0
Published: 2026-11-20T18:01:52Z
Prerelease: no
Release notes:
v0.6.0
- ⚠️ Breaking changes
- OneTwo is now statically typed. The core decorators were rewritten
so that type checkers (like Pyrefly) see the real signatures and return types of decorated functions instead of Any. Code that type-checked against v0.5.0 may now report errors, and some decorators changed their calling convention:
- `ot.make_executable`: Note that runtime behaviour is unchanged.
What breaks is type checking:
- Decorated functions are now typed as returning
FunctionExecWrapper[T] instead of Any, where T is the result type of the function, unwrapped from coroutines, async generators and returned Executables. E.g. async def f(...) -> str is typed as returning FunctionExecWrapper[str], so using f(...) where a str is expected (instead of await f(...) or ot.run(f(...))) now fails type checking.
- Without arguments (
@ot.make_executable), the decorated
function keeps its parameters (via ParamSpec), so calls with wrong argument types or counts are now flagged.
- `tracing.trace`: Must now always be called with parentheses:
@tracing.trace() (or @tracing.trace(name=...)). A bare @tracing.trace no longer works.
- `caching.cache_method`: Now only supports
async defmethods,
and preserves the signature of the decorated method.
- `utils.with_retry` / `utils.rate_limit_method`: Preserve the
signature of the decorated method instead of collapsing it to Callable[..., Any].
- `Composable.execute` is now an executable.
- Legacy built-ins:
llm.generate_textandllm.generate_texts
are deprecated and moved to builtins/legacy_llm_builtins.py.
- Python >= 3.13 is now required.
- OneTwo Agent with MCP support
- `Agent`: Added a generic agent that runs model-native function
calling to completion. Tools can be plain Python callables (their declarations are inferred from signatures and docstrings), Tools, or MCP servers, mixed freely, e.g. Agent(tools=[get_weather, mcp_tools.server('http://localhost:8777/mcp')]). Supports multimodal questions, parallel tool calls, a final answer without tools when steps run out, and recovery from empty model turns. Added agent.format_tool_calls and agent.format_agent_steps to inspect runs.
- MCP tools: Added
mcp_tools.server(streamable HTTP) and
mcp_tools.stdio_server to use any MCP server as a source of agent tools, with sessions that stay alive across failing tool calls and support for image tool results.
- `llm.generate_with_tools`: New built-in for model-native function
calling, implemented in the GoogleGenAIAPI, ClaudeAPI and OpenAIAPI backends.
- `core.function_calling`: New core types
ToolSpec,
ConversationTurn, FunctionCall and FunctionResponse (with correlation ids). Function-calling runs, including thoughts and tool calls, are recorded in execution traces.
- Tool schemas: Added
tool_schema.tool_from_callableto infer a tool
declaration from a Python callable. llm_tool_use.Tool gained parameters and to_spec().
- RAG
- New top-level `rag` module (
from onetwo import rag) to build,
serve and evaluate retrieval pipelines in a few calls:
rag.build_index(corpus, index, *, output, ...):** Builds and
saves a document index from a registered DatasetLoader or a folder of files of any type, and returns the built index. index is either a ready-made rag.IndexType (EMBEDDING or GRAPHRAG) or any DocumentIndex object. Also available as a command-line tool (build_index).
rag.evaluate(examples, index, strategy, *, ...):** Evaluates a
QA strategy on a QA dataset. strategy is either a ready-made rag.StrategyType (CLOSED_BOOK, RAG, RETRIEVAL_ONLY, AGENTIC_RETRIEVAL) or any QAStrategy object; mcp_urls points agentic strategies at MCP servers. Results are saved in descriptive folders under output. Also available as a command-line tool (evaluate_rag).
- `rag.start_mcp` / `rag.start_mcp_in_background`: Serve a saved
index or an index object as an MCP server (stdio or streamable HTTP) with search and get_document tools.
- `rag.StorageFormat`: Chooses how an index is saved, at save
time.
- Indexing:
use_task_type, theprepare_*hooks,default_prepare_queryand
default_prepare_document were removed. Embedding indexes are configured with an EmbedBackendConfig and a searcher: Searcher.
EmbeddingBasedDocumentIndexis now coupled with its embedding
backend: it takes an embed_backend_config and instantiates its own embedder backend from it (with credentials passed separately and never saved), instead of relying on the globally registered llm.embed. The config is saved with the index, so a loaded index embeds queries with the same backend and model it was built with.
- Chunk
doc_ids now use a_chunksuffix format, and chunkers
record the source span of each chunk in its metadata (span_within_original_doc).
- Added ID-based document lookup (
get_doc,get_docs_by_ids,
get_doc_embedding) to indexes, and preservation of the original (unchunked) documents in rewriting indexes across save and load.
- Index configuration and persistence: Indexes are their own configs:
they are saved as index_config.json and rebuilt from it by index_building.load_index, whatever their type. Custom components (indexes, chunkers, formatters, searchers, ...) are registered by stable name with registry.register. Serializers are pluggable, support sharding, show progress bars and load faster.
- QA strategy results:
QAStrategyimplementations now return a
StrategyResult, holding the answer together with the retrieved Documents. Strategies always receive query_time_kwargs.
- Datasets:
onetwo.evaluation.datasetsis now a package. The
max_documents property of dataset loaders was renamed to max_number_of_documents.
- GraphRAG: Added
HippoRAGDocumentIndex, a knowledge-graph index
based on HippoRAG (with multimodal entity extraction), along with its own MCP server and serialization.
- Chunking:
- Added
RoutingChunker, which chunks each document according to its
content type, and is the default chunker of the ready-made indexes.
- Added
ChunkByMaxWords,ChunkByPdfPages,ChunkByAudioSeconds
and ChunkByVideoSeconds.
- The tokenizer of
ChunkByMaxTokensis configurable through a
TokenizeBackendConfig....
Excerpt shown — open the source for the full document.