Skip to content

cli: add an unattended execution contract - #815

Open
reinainblood wants to merge 1 commit into
OpenHands:mainfrom
reinainblood:feat/unattended-execution
Open

reinainblood wants to merge 1 commit into
OpenHands:mainfrom
reinainblood:feat/unattended-execution

Conversation

@reinainblood

@reinainblood reinainblood commented Aug 31, 2026 •

Copy link
Copy Markdown

Summary

This adds an opt-in openhands run command for callers that need a fully
unattended process contract, while leaving the existing TUI and
--headless behavior unchanged.

Concrete downstream consumer and end-to-end validation:
harbor-framework/harbor#3009
(ready for review; merge remains blocked on this PR, with Modal V2 validated downstream).

The command:

  • never opens onboarding, confirmation prompts, or an interactive fallback;
  • requires explicit LLM_API_KEY and LLM_MODEL process configuration and
    does not load a workspace .env file;
  • requires explicit workspace and output directories;
  • supports --offline / --no-public-skills so startup does not clone the
    public extensions repository;
  • streams flushed JSONL to stdout and events.jsonl while the SDK also
    persists individual conversation events continuously;
  • atomically maintains run.json, including while the run is active;
  • supervises SDK execution so SIGINT/SIGTERM produce conventional exit codes
    and terminal artifacts even when a provider request does not stop
    cooperatively; and
  • distinguishes usage (2), configuration (3), provider (4), agent (5),
    and internal CLI (6) failures.

Why

The existing headless mode is useful for humans invoking a one-off task, but
benchmark and CI harnesses need a stronger boundary: fresh-home execution with
no TTY, no surprise startup fetches, an explicit workspace, incremental
machine-readable output, partial crash evidence, and trustworthy exit status.

This is also a concrete follow-up to #147 and the unresolved offline startup
failure reported in #483. I kept the new behavior opt-in because existing users
may depend on the current Textual-backed headless output.

I noticed that this repository was recently marked as no longer actively
maintained. A downstream Harbor adapter is being built against this exact
public command, but I would appreciate maintainer guidance on whether this CLI
repository remains the right home for the execution surface or whether it
should move elsewhere in the current OpenHands architecture.

Reproduction evidence

Released openhands==1.16.0 was installed into a fresh Python 3.12 Linux image
and exercised with stdin from /dev/null, no TTY, a fresh HOME, and a
deterministic OpenAI-compatible endpoint:

Case Observed result
Missing configuration exit 1; no run artifact
Final-only model response exit 0; JSONL and SDK session events persisted (the endpoint intentionally made no tool call)
GitHub unavailable public-skills clone failed during startup; no supported flag could disable the fetch
Provider failure still retrying after 45 s; harness sent SIGKILL (137)
SIGTERM during provider request did not terminate within 25 s; harness sent SIGKILL (137)
Hard timeout / crash low-level SDK event files survived, but no terminal run record

The new command was then built from this branch and run in a disposable Linux
container with GitHub mapped to an unavailable address after installation:

Case Observed result
Nominal offline run exit 0; requested file created; 5 persisted SDK events; stdout exactly matched events.jsonl; zero public-skills paths
Missing configuration exit 3; configuration_error summary and run.failed record
Provider failure, retries disabled exit 4; provider_error, ConversationErrorEvent, and run.failed record
SIGTERM during hung provider request exit 143; atomic interrupted summary, 3 partial SDK events, and final interrupt record

The deterministic endpoint uses a real HTTP transport and the real OpenHands
SDK execution path; it is not used as a substitute for downstream live-model
benchmark validation.

Verification

  • make lint
  • make test (1,366 passed)
  • make test-binary (3 passed; existing pytest warnings only)
  • targeted pre-commit hooks on every changed file (Ruff format/lint,
    pycodestyle, Pyright)
  • disposable Linux source install and no-TTY/offline end-to-end run
  • provider-failure and SIGTERM lifecycle runs through the public command

Compatibility

Existing openhands, openhands --headless, ACP, web, cloud, and GUI command
paths are unchanged. The new command creates a fresh runtime agent from process
environment values, ignores persisted agent settings, disables the critic, and
uses the SDK's existing process workspace rather than introducing Docker or
another sandbox.

This PR was prepared by Codex on behalf of Kirsten Ruge.

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants