Skip to content

hack/hero-demo: detect task completion inside the sandbox - #738

Merged
rakyll merged 2 commits into
mainfrom
issue722
Nov 24, 2026
Merged

rakyll merged 2 commits into
mainfrom
issue722

Conversation

@rakyll

@rakyll rakyll commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Fixes #722.

RUN_LIVE_STEPS=1 ./hack/hero-demo/run.sh hung in Steps 3, 4 and 5:
finish_task waited for ax describe task to report Completed or
Failed with Output:, but since #688 nothing sets either, and
COMPLETED is reserved until #690. Tasks stay Running with no
status.outcome after their command exits.

This change only touches hack/hero-demo/.

Manifests

  • task-starter.yaml sets spec.commands to a wrapper around the
    image's launcher (/usr/local/bin/ax-launcher, or ax-harness on
    images from before the rename). Commands still get the goal, config,
    MCP and session files of the launcher contract. The wrapper writes the
    launcher's exit status to /workspace/.ax/hero-demo-exit-code, and
    does not run the agent again once a status is recorded. This also
    avoids depending on the runner's launcher-done marker, which the
    runner cannot write (root without CAP_DAC_OVERRIDE in a UID
    1000-owned /workspace/.ax).
  • task-custom.yaml writes the unit test output to $AX_OUTPUT_FILE
    and its exit status to the same file.

run.sh

  • finish_task waits for the exit-code file over ax ssh (both tasks
    set spec.debug), fails on a non-zero status and shows the end of the
    output, and fails when /workspace/.ax/output is empty.
  • ax ssh calls take the global ax flags, so Step 5 reads the sandbox
    on --context <remote>.
  • Steps 3 and 5 fail fast when kubectl reports the hero-demo-gemini
    Secret as NotFound, or the Secret lacks the ax.io/credential=true
    label, instead of the agent getting 403 egress denied while the task
    reads Running.
  • Comments and the README no longer say a finished task refuses
    suspend/resume.

Not in this PR

Testing

  • RUN_LIVE_STEPS=1 AX_TIMEOUT=300 ./hack/hero-demo/run.sh on an
    ax local cluster built from 33b93cf: Step 2 and Step 4 PASS, Step 3
    runs the agent to completion (it added subtract and its test, exit
    status 0, output written); Steps 1, 3 and 5 report their existing STUBs.
  • The dry run (no RUN_LIVE_STEPS) is unchanged.
  • With a fake ax CLI: agent failure, empty output, missing Secret,
    failing unit tests, and Step 5 with --context each give the expected
    scoreboard line.

Fixes #722.

`RUN_LIVE_STEPS=1 ./hack/hero-demo/run.sh` hung in Steps 3, 4 and 5:
`finish_task` waited for `ax describe task` to report `Completed` or
`Failed` with `Output:`, but since #688 nothing sets either, and
`COMPLETED` is reserved until #690. Tasks stay `Running` with no
`status.outcome` after their command exits.

This change only touches `hack/hero-demo/`.

## Manifests

- `task-starter.yaml` sets `spec.commands` to a wrapper around the
  image's launcher (`/usr/local/bin/ax-launcher`, or `ax-harness` on
  images from before the rename). Commands still get the goal, config,
  MCP and session files of the launcher contract. The wrapper writes the
  launcher's exit status to `/workspace/.ax/hero-demo-exit-code`, and
  does not run the agent again once a status is recorded. This also
  avoids depending on the runner's `launcher-done` marker, which the
  runner cannot write (root without `CAP_DAC_OVERRIDE` in a UID
  1000-owned `/workspace/.ax`).
- `task-custom.yaml` writes the unit test output to `$AX_OUTPUT_FILE`
  and its exit status to the same file.

## run.sh

- `finish_task` waits for the exit-code file over `ax ssh` (both tasks
  set `spec.debug`), fails on a non-zero status and shows the end of the
  output, and fails when `/workspace/.ax/output` is empty.
- `ax ssh` calls take the global ax flags, so Step 5 reads the sandbox
  on `--context <remote>`.
- Steps 3 and 5 fail fast when `kubectl` reports the `hero-demo-gemini`
  Secret as NotFound, instead of the agent getting `403 egress denied`
  while the task reads `Running`.
- Comments and the README no longer say a finished task refuses
  suspend/resume.

## Not in this PR

- The runner's `launcher-done` permission bug, which still makes a
  resumed task without `spec.commands` run its launcher again.
- Reporting completion from AX itself (#690).

## Testing

- `RUN_LIVE_STEPS=1 AX_TIMEOUT=300 ./hack/hero-demo/run.sh` on an
  `ax local` cluster built from `33b93cf`: Step 2 and Step 4 PASS, Step 3
  runs the agent to completion (it added `subtract` and its test, exit
  status 0, output written); Steps 1, 3 and 5 report their existing STUBs.
- The dry run (no `RUN_LIVE_STEPS`) is unchanged.
- With a fake `ax` CLI: agent failure, empty output, missing Secret,
  failing unit tests, and Step 5 with `--context` each give the expected
  scoreboard line.

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Split the launcher-done permission denied bug out of #722 into #740 so closing #722 here doesn't drop it.

Comment thread hack/hero-demo/run.sh Resolved
@rakyll

rakyll commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Thanks! Updated the description to point to #740 for the launcher-done permission bug.

@rakyll
rakyll merged commit 3779eeb into main Nov 24, 2026
11 checks passed
@rakyll
rakyll deleted the issue722 branch November 24, 2026 01:59
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.

hack/hero-demo: live steps hang because tasks never reach Completed since #688

2 participants