Did you check docs and existing issues?
Python version (python --version)
Python 3.12.9
Operating system/version
Windows 11
NeMo-Guardrails version (if you must use a specific version and not the latest
0.20.0
Describe the bug
When using RunnableRails in any chain that uses a RunnableSequence we see the following error:
TypeError: 'async for' requires an object with __aiter__ method, got coroutine
The issue seems to have been introduced with version 0.17.0. I've attached a reproduction involving just LC and NemoRails (full disclosure, it was generated by Claude Code, though I've edited it a bit for brevity and I am a person ;)).
Steps To Reproduce
import asyncio
import inspect
from langchain_core.runnables import RunnableLambda
from nemoguardrails import RailsConfig
from nemoguardrails.integrations.langchain.runnable_rails import RunnableRails
async def reproduce_bug():
print("=== Bug reproduction ===")
config = RailsConfig.from_content(yaml_content="models: []")
rails = RunnableRails(config, passthrough=True)
# Putting RunnableRails in a sequence triggers atransform via astream
pipeline = RunnableLambda(lambda x: x) | rails
try:
async for _ in pipeline.astream("hello"):
pass
print("No error — bug not reproduced (unexpected)")
except TypeError as e:
print(f"TypeError (expected): {e}")
print()
if __name__ == "__main__":
asyncio.run(reproduce_bug())
Expected Behavior
When run, the above code should output "No error -- bug not reproduced".
Actual Behavior
The current output is:
$ python nemo_atransform_repro.py
=== Bug reproduction ===
No main LLM specified in the config and no LLM provided via constructor.
TypeError (expected): 'async for' requires an object with __aiter__ method, got coroutine
<path elided>/nemo_atransform_repro.py:21: RuntimeWarning: coroutine 'RunnableRails.atransform' was never awaited
print(f"TypeError (expected): {e}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Did you check docs and existing issues?
Python version (python --version)
Python 3.12.9
Operating system/version
Windows 11
NeMo-Guardrails version (if you must use a specific version and not the latest
0.20.0
Describe the bug
When using
RunnableRailsin any chain that uses aRunnableSequencewe see the following error:The issue seems to have been introduced with version
0.17.0. I've attached a reproduction involving just LC and NemoRails (full disclosure, it was generated by Claude Code, though I've edited it a bit for brevity and I am a person ;)).Steps To Reproduce
Expected Behavior
When run, the above code should output "No error -- bug not reproduced".
Actual Behavior
The current output is: