fix(terminal): lower agent process priority - #4573
Draft
primorLee wants to merge 2 commits into
Draft
Conversation
Co-authored-by: openhands <openhands@all-hands.dev>
7 tasks
Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
AGENT:
Why
CPU-heavy agent commands currently inherit the agent-server's priority and can
starve the server. The original product report and benchmarks are documented at
OpenHands/OpenHands#16720. SDK issue #4575 contains a
minimal reproduction and testable acceptance criteria for this repository.
Summary
/usr/sbin/taskpolicy -c utilityand Linuxterminal shells with an absolute
nice -n 10path, covering standalone tmux,pooled tmux, and the PTY subprocess backend.
BELOW_NORMAL_PRIORITY_CLASSandverify that a real child command inherits it.
nice, and supportOH_TERMINAL_PROCESS_PRIORITY=nonefor priority-sensitive benchmarks ordevelopment servers.
tests.
Issue Number
Fixes #4575
Original product issue: OpenHands/OpenHands#16720
How to Test
I completed the repository build steps on Windows (GNU Make is unavailable in
this checkout, so I ran the exact
buildtarget commands):Windows end-to-end verification launches a real command through the persistent
PowerShell terminal; that child reads its own OS priority through
psutil:Platform policy, missing-
nice, and opt-out coverage on the same checkout:The two skips are the real Linux tmux/subprocess inheritance cases. They are
committed in this PR for the Ubuntu tools job; this machine has neither WSL nor
a Linux container runtime. The assertions use a unique output marker and compare
against the runner's actual niceness rather than assuming a zero baseline.
I also checked every changed POSIX file with Linux type stubs:
Pre-commit was run after each changed file. On this Windows host, its default
pyright invocation reports the existing POSIX-only
pty,fcntl, andos.setsidsymbols as missing in
subprocess_terminal.py; the explicit Linux-platformpyright command above is clean. Ruff, pycodestyle, import rules, and tool
registration checks pass for all changed files.
I do not have macOS hardware in this environment. The Darwin argv path is covered
by the policy test, while the end-to-end
taskpolicy -c utilitymeasurement isthe one documented by the OpenHands member in the original product issue.
Video/Screenshots
Not applicable for a process-scheduling backend change; reproducible process-level
test output is included above.
Design Doc
Not included; the change is limited to one internal policy helper and four
existing process-spawn call sites.
Type
Notes
servers, and browser processes are unchanged.
nicebefore applying the terminal's possibly restrictedPATH; if the utility is unavailable, terminal startup remains functional.utilityQoS class, not the much more restrictivebackgroundclass.