OpenHands / OpenHands/software-agent-sdk
[Bug]: Agent terminal commands inherit server process priority
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 539
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 137
Description
Is there an existing issue for the same bug?
- I searched
OpenHands/software-agent-sdk; there is no same-repository issue. The original cross-repository report is OpenHands/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.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-sdkand runuv 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
- Linux standalone tmux, pooled tmux, and subprocess terminal children inherit niceness +10 (capped at 19).
- macOS terminal children run with
taskpolicy -c utility. - Windows terminal child commands inherit
BELOW_NORMAL_PRIORITY_CLASS. -
OH_TERMINAL_PROCESS_PRIORITY=nonepreserves the parent priority. - A restricted terminal
PATH, or a Linux image withoutnice, does not make a previously valid terminal fail to start.
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
- I confirmed this bug exists on the latest OpenHands SDK main branch before implementing the fix.
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
- Original product issue and benchmark: OpenHands/OpenHands#16720
- SDK implementation PR: OpenHands/software-agent-sdk#4573
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with uv sync --dev and reproduce_priority.py, then trace create_terminal_session and the terminal backends imported by the sample. Verify child priority behavior on Linux, macOS, and Windows, including restricted PATH and missing nice cases. Done means the three platform defaults work, none preserves the parent priority, and terminal startup remains valid in constrained environments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, macos, python
- Domain
- cli, operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100