Repository navigation
Description
Company or project name
No response
Component
Python SDK
Use case
DSPy programs retrieve through a retriever module; Loom has adapters for several frameworks (docs/features/integrations/frameworks.md) but none for DSPy.
Describe the solution you'd like
Goal. loom.integrations.dspy: a retriever that calls Loom search (memory and knowledge) and returns passages with their source.
Files to change. #650 (the OpenAI Agents SDK tools) is a worked example of each:
sdk/python/loom/integrations/dspy.pyandsdk/python/loom/integrations/__init__.py;- a
dspyextra insdk/python/pyproject.toml, pinned to a minor range; dspyinSDK_ADAPTER_EXTRASin theMakefile, somake test-sdk-adaptersinstalls and tests it;- the DSPy modules in the mypy
ignore_missing_importslist for the framework adapters in the rootpyproject.toml; sdk/python/tests/test_dspy.py;- a row in the table and a section in docs/features/integrations/frameworks.md, the framework list in docs/features/integrations/index.md, a line in docs/reference/python-sdk.md, and the
[dspy]extra in the framework adapters sentence ofsdk/python/README.md.
Acceptance criteria
- Before writing it, say in this issue which DSPy retriever interface the adapter targets and why. DSPy offers more than one way in (a retrieval model set with
dspy.configure(rm=…)and read throughdspy.Retrieve, or a plain function ordspy.Modulethat a program calls or hands todspy.ReActas a tool), and which one it recommends has changed across releases. - Signatures checked against the installed DSPy release; the PR names the version.
make test-sdk-adapter-dspypasses (one venv with the extra installed, its tests andmypy --strict), and so doesmake test-sdk-adapter-dspy SDK_ADAPTERS_PYTHON=3.11 SDK_ADAPTERS_RESOLUTION=lowest-direct, the lowest-deps leg of CI'ssdk-python-adaptersjob, which installs every direct requirement at its lower bound.make test-sdk-adapters,make format-check lint typecheckand.venv/bin/python -m pytest tests/unit/test_sdk_extra_requirements.py -qpass; that test checks that every extra inSDK_ADAPTER_EXTRAShasloom/integrations/<extra>.pyandtests/test_<extra>.py.loom/integrations/dspy.pyimports the framework insidetry/except ImportErrorand re-raises anImportErrorthat namespip install 'clickhouse-loom[dspy]', assdk/python/loom/integrations/openai_agents.pydoes (lines 31-37). CI'ssdk-python-packagejob checks it withscripts/gates/sdk_wheel_smoke.py, which imports every submodule in a clean venv holding only the wheel and fails on an adapter whoseImportErrordoes not name its extra. Run it locally from an emptydist/:
uv build sdk/python --out-dir dist
uv venv /tmp/sdk-venv
uv pip install --python /tmp/sdk-venv/bin/python dist/*.whl
/tmp/sdk-venv/bin/python scripts/gates/sdk_wheel_smoke.py dist/*.whl- The docs checks pass:
.venv/bin/python -m pytest tests/unit/test_doc_links.py tests/unit/test_public_copy.py -q
.venv/bin/python -m scripts.codegen.docs_reference --checkDescribe alternatives you've considered
A DSPy program can call the SDK directly inside a custom module; an adapter gives it the retriever interface DSPy already composes.
Where the need comes from
The need is mine, an AI tool helped shape the proposal
Additional context
Start after #696 (the Google ADK memory service) merges, or rebase onto it: it edits frameworks.md, integrations/index.md, python-sdk.md, sdk/python/README.md, SDK_ADAPTER_EXTRAS in the Makefile and both pyproject.toml files.
Size: M (a day or two). Read CONTRIBUTING.md first (signed-off commits), and comment here to say you are working on it.
Activity
rahulsjha commentedon Nov 20, 2026
Hi @zlareb1, I'd like to take this one, following #650 as the pattern.
Plan:
sdk/python/loom/integrations/dspy.py: aLoomRMretriever (adspy.Retrievemodule) that calls Loom search over memory and knowledge withk, namespace and optional filters, and returnsdspy.Prediction(passages=[...]). Each passage carries its text, score and source (memory id or document and chunk citation), so a DSPy program can cite what it used.dspyextra pinned to a minor range,dspyinSDK_ADAPTER_EXTRAS, and the DSPy modules in the mypyignore_missing_importslist.sdk/python/tests/test_dspy.pyagainst a stubbed Loom client: passages and sources come through,kand filters are passed on, an empty result is an empty list, and a search error is raised rather than swallowed.frameworks.md, the framework list inintegrations/index.md, and a line inpython-sdk.md.rahulsjha commentedon Nov 20, 2026
@zlareb1, on the acceptance question of which DSPy retriever interface to target: I checked DSPy 3.5.0 (the current release).
dspy.configure(rm=...)read throughdspy.Retrieve: still there, butRetrieve.forwardkeeps only each passage'slong_textand returnsPrediction(passages=[...]). The sources would be lost, and citing them is the point of this adapter.dspy.retrievers.Embeddings, is a plain class whose__call__(query)returnsdspy.Prediction(passages=..., indices=...). A program calls it inforward, or wraps it indspy.Toolfordspy.ReAct.So the adapter is a plain callable in that shape:
LoomKnowledgeRetriever(agent, k=3)andLoomMemoryRetriever(agent, k=3, user_id=...), the same pair and fields as the LangChain retrievers.dspy.Prediction(passages, sources, scores, metadata).acalltakes an asyncAgent.as_tool()returns adspy.ToolforReAct, sync or async to match the agent, that returns[source] passagelines.The PR is up next, pinned to
dspy>=3.5,<3.6.