Skip to content

Wrong output when interactive with python #287

Description

@popjxc

Env:

  • os: mac
  • python 3.14.3
  • uv tree|grep swe
    Resolved 59 packages in 3ms
    ├── swe-rex v1.4.0

Code:

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))

Output:

# 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

Problem:
The output order is wrong, and 'hello world' is missing. Is this a mistake on my part, or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions