import asyncio
from swerex.deployment.local import LocalDeployment
from swerex.runtime.abstract import CreateBashSessionRequest, BashAction
async def interactive_python(deployment):
await deployment.start()
runtime = deployment.runtime
await runtime.create_session(CreateBashSessionRequest())
result = await runtime.run_in_session(
BashAction(
command="python",
is_interactive_command=True,
expect=[">"], timeout=5)
)
print(1, result.output)
result = await runtime.run_in_session(
BashAction(
command="print('hello world')",
is_interactive_command=True,
expect=[">>> "], timeout=5)
)
print(2, result.output)
result = await runtime.run_in_session(
BashAction(
command="print('hello world')",
is_interactive_command=True,
expect=[">>> "], timeout=5)
)
print(3, result.output)
await runtime.run_in_session(
BashAction(command="quit()\n", is_interactive_quit=True, timeout=5)
)
await deployment.stop()
print(4, "end.")
deployment = LocalDeployment()
asyncio.run(interactive_python(deployment))
# python test_swe_rex.py
1
2 Python 3.14.3 (main, Mar 25 2026, 03:28:18) [Clang 22.1.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
3
4 end.
Ensuring deployment is stopped because object is deleted
Env:
Resolved 59 packages in 3ms
├── swe-rex v1.4.0
Code:
Output:
Problem:
The output order is wrong, and 'hello world' is missing. Is this a mistake on my part, or is it a bug?