Hi, is `conversation.astream()` still supported? ...
# dev-help
c
Hi, is
conversation.astream()
still supported?
Copy code
async def run_agent():
    conversation = Conversation(agent=agent, workspace=cwd)
    conversation.send_message("Write 3 facts about Python to FACTS.txt")
    
    async for event in conversation.astream():
        print(f"Event: {event}")
This is from the online docs: here. When I try to run this code snippet locally, I get this error:
Copy code
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 await run_agent()

Cell In[1], line 40, in run_agent()
     37 conversation = Conversation(agent=agent, workspace=cwd)
     38 conversation.send_message("Please add 'hi there' to the top of the readme.md file")
---> 40 async for event in conversation.astream():
     41     print(f"Event: {event}")

AttributeError: 'LocalConversation' object has no attribute 'astream'
l
@nutritious-balloon-65098 Check OpenHands/software-agent-sdk and see if this functionality previously existed in previous commits and was removed, and if so what the justification for this was.
n
I'm on it! Graham Neubig can track my progress here.
Summary of Investigation I completed a thorough investigation of the
conversation.astream()
functionality in the OpenHands/software-agent-sdk repository. Here's what I found: Answer to Your Question: The
astream()
method NEVER existed in the codebase and was never removed.
This is a documentation error where a feature was documented before implementation. Key Findings: 1. No Historical Evidence: I searched the entire git history using multiple methods (
git log --grep
,
git log -S
, etc.) and found zero commits that ever added or removed an
astream()
method. 2. Not in Current Code: The method doesn't exist in any conversation class (BaseConversation, LocalConversation, or RemoteConversation). 3. Documentation Issue: The problematic documentation was added on October 22, 2025 (commit b419a23) in the docs repository as part of a large documentation standardization effort. It shows example code using
conversation.astream()
that has never been implemented. 4. Mismatch with Examples: The actual working example file (
examples/01_standalone_sdk/11_async.py
) that the documentation links to does NOT use
astream()
. Instead, it uses the callback-based approach with
AsyncCallbackWrapper
. Current Working Alternative: Users should use the callback-based approach instead:
Copy code
async def callback_coro(event: Event):
    # Process events here
    pass

async def main():
    loop = asyncio.get_running_loop()
    callback = AsyncCallbackWrapper(callback_coro, loop)
    await loop.run_in_executor(None, run_conversation, callback)
There was no justification for removal because the feature was never implemented in the first place. I've created a detailed investigation report at
/workspace/project/astream_investigation.md
documenting all evidence and findings. No code changes were made as this was purely an investigative task. <sub>View full conversation</sub>
c
ugh this is probably one hallucinated method sorry 😭 unclear how i could missed that. @nutritious-balloon-65098 please remove the usage of
astream
in OpenHands/docs repo (sdk/guides/convo-async#async-streaming). Also for concurrency agent, instead of using
run_task
, you should refer to the function that has been defined above in the example document. Send a PR when you are done
n
Xingyao Wang is not authorized to send messages to this conversation.
l
@nutritious-balloon-65098 please remove the usage of
astream
in OpenHands/docs repo (sdk/guides/convo-async#async-streaming). Also for concurrency agent, instead of using
run_task
, you should refer to the function that has been defined above in the example document. Send a PR when you are done This is in the OpenHands/docs directory
🙌 1
n
I'm on it! Graham Neubig can continue tracking my progress here.
Final Summary I've successfully completed all requested tasks: ✅ Request Checklist: 1. Remove
astream
usage from sdk/guides/convo-async.mdx
- Complete 2. Fix concurrent agents example to use actual functions from the example - Complete 3. Send a PR - Complete Changes Made to OpenHands/docs: File Modified:
sdk/guides/convo-async.mdx
1. Removed "Async Streaming" section (14 lines deleted) â—¦ Eliminated documentation for non-existent
conversation.astream()
method â—¦ This was causing AttributeError for users following the docs 2. Fixed "Concurrent Agents" example (8 lines added) â—¦ Changed from undefined
run_task()
to actual
run_conversation()
function defined in the example â—¦ Added proper async setup:
loop.run_in_executor()
with
AsyncCallbackWrapper(callback_coro, loop)
◦ Now demonstrates correct concurrent execution pattern Pull Request: 🔗 PR #103: https://github.com/OpenHands/docs/pull/103 • Branch:
fix-astream-documentation
• Status: Draft (ready for review) • Net change: -10 lines (removed incorrect documentation) The documentation now accurately reflects the SDK's actual implementation and provides working examples that users can follow without errors. <sub>View full conversation</sub>
c
Oh no worries, that's pretty funny. Do you have a recommended way to simply replicate the functionality of a would-be
astream()
- basically an async generator of the events? My understanding is that
conversation.run()
doesnt actually return anything, but creates the side effects in the repository. So I think it would have to somehow involve an async-callback?
l
Unfortunately I’m not immediately sure and haven’t had time to check yet… If you figure it out though would be happy to know the answer
c
maybe write some sort of queue, and create an
on_event
callback that adds stuff to the queue? And then you can listen to that queue as an async generator of events