Is there an existing issue for the same bug?
Bug Description
Agent commands launched through the SDK terminal backends inherit the agent-server process priority. CPU-heavy commands such as parallel Rust compilation can therefore starve the server event loop and make local OpenHands sessions appear locked up.
The upstream reproduction in OpenHands/OpenHands#16720 measured the same priority for the server and terminal commands. A follow-up by an OpenHands member confirmed that the required policy is platform-specific: macOS utility QoS, Linux niceness +10, and Windows Below Normal priority.
Expected Behavior
Terminal-tool child processes should run below the agent server's CPU priority by default, while an explicit terminal environment setting should allow priority-sensitive benchmarks or development servers to retain the parent priority.
Actual Behavior
Run uv run python reproduce_priority.py using the minimal SDK program below. On current main, the child reports normal Windows priority (32) or the same Unix niceness as the parent (0 in a default shell). CPU-heavy child processes consequently compete with the agent server at equal scheduling priority.
Steps to Reproduce
- Check out
OpenHands/software-agent-sdk and run uv sync --dev.
- Save the minimal code below as
reproduce_priority.py.
- Run
uv run python reproduce_priority.py.
- Start several CPU-heavy commands through the same terminal session and observe that the agent server becomes slow or unresponsive.
Acceptance Criteria
Installation Method
uv sync --dev from a source checkout.
If you selected "Other", please specify
Source checkout.
SDK Version
main, reproduced at dc0c8428438dde13efa422fb456adfb542fd532d.
Version Confirmation
Python Version
3.13.15 locally; the scheduling behavior is not Python-version-specific.
Model Name (if applicable)
Not applicable.
Operating System
macOS, Linux, and Windows.
Logs and Error Messages
There is no exception. The failure mode is server starvation under CPU load. The full macOS/Linux throughput and latency measurements are in OpenHands/OpenHands#16720.
Minimal Code Sample
import platform
import tempfile
from openhands.tools.terminal import TerminalAction
from openhands.tools.terminal.terminal import create_terminal_session
command = (
'python -c "import psutil; print(psutil.Process().nice())"'
if platform.system() == "Windows"
else "python -c 'import os; print(os.getpriority(os.PRIO_PROCESS, 0))'"
)
with tempfile.TemporaryDirectory() as work_dir:
session = create_terminal_session(work_dir=work_dir)
try:
session.initialize()
print(session.execute(TerminalAction(command=command)).text)
finally:
session.close()
Screenshots and Additional Context
Is there an existing issue for the same bug?
OpenHands/software-agent-sdk; there is no same-repository issue. The original cross-repository report is [Bug]: Agent commands should run with lower priority (higher number) OpenHands#16720.Bug Description
Agent commands launched through the SDK terminal backends inherit the agent-server process priority. CPU-heavy commands such as parallel Rust compilation can therefore starve the server event loop and make local OpenHands sessions appear locked up.
The upstream reproduction in OpenHands/OpenHands#16720 measured the same priority for the server and terminal commands. A follow-up by an OpenHands member confirmed that the required policy is platform-specific: macOS utility QoS, Linux niceness +10, and Windows Below Normal priority.
Expected Behavior
Terminal-tool child processes should run below the agent server's CPU priority by default, while an explicit terminal environment setting should allow priority-sensitive benchmarks or development servers to retain the parent priority.
Actual Behavior
Run
uv run python reproduce_priority.pyusing the minimal SDK program below. On currentmain, the child reports normal Windows priority (32) or the same Unix niceness as the parent (0in a default shell). CPU-heavy child processes consequently compete with the agent server at equal scheduling priority.Steps to Reproduce
OpenHands/software-agent-sdkand runuv sync --dev.reproduce_priority.py.uv run python reproduce_priority.py.Acceptance Criteria
taskpolicy -c utility.BELOW_NORMAL_PRIORITY_CLASS.OH_TERMINAL_PROCESS_PRIORITY=nonepreserves the parent priority.PATH, or a Linux image withoutnice, does not make a previously valid terminal fail to start.Installation Method
uv sync --devfrom a source checkout.If you selected "Other", please specify
Source checkout.
SDK Version
main, reproduced atdc0c8428438dde13efa422fb456adfb542fd532d.Version Confirmation
Python Version
3.13.15 locally; the scheduling behavior is not Python-version-specific.
Model Name (if applicable)
Not applicable.
Operating System
macOS, Linux, and Windows.
Logs and Error Messages
There is no exception. The failure mode is server starvation under CPU load. The full macOS/Linux throughput and latency measurements are in OpenHands/OpenHands#16720.
Minimal Code Sample
Screenshots and Additional Context