Skip to content

Add post-run automation callbacks - #211

Closed
malhotra5 wants to merge 1 commit into
mainfrom
app-2489-post-run-callbacks
Closed

malhotra5 wants to merge 1 commit into
mainfrom
app-2489-post-run-callbacks

Conversation

@malhotra5

@malhotra5 malhotra5 commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements post-run automation callbacks for APP-2489 / #208 using the callback-chain design.

  • Adds durable automation_run_callbacks records with persisted callback lifecycle state.
  • Adds automation-level callbacks config with exactly-one-of validation for entrypoint vs inline_python.
  • Defaults automations with callbacks to keep_alive=True when keep_alive is omitted, so normal sandbox cleanup can be left to runtime TTL/reaper.
  • Materializes preset inline_python callbacks into generated tarballs under callbacks/<name>.py and normalizes them to callback entrypoints.
  • Schedules callbacks when runs reach COMPLETED or FAILED via either SDK completion callback or watchdog verification.
  • Starts one in-sandbox Python wrapper command that runs matching callbacks sequentially in the existing workdir, captures per-callback results, and POSTs a final completion payload back to the automation service.
  • Adds POST /runs/{run_id}/callbacks/complete for the wrapper completion payload and GET /runs/{run_id}/callbacks for inspecting callback records.
  • Keeps explicit cleanup blocked until callbacks have been dispatched; if keep_alive=False is explicitly used, callback completion can clean up after terminal callback records.

Testing

  • uv run pre-commit run --files openhands/automation/models.py openhands/automation/schemas.py openhands/automation/preset_router.py openhands/automation/router.py openhands/automation/watchdog.py openhands/automation/app.py openhands/automation/backends/base.py openhands/automation/backends/cloud.py openhands/automation/backends/local.py openhands/automation/callbacks.py migrations/versions/010_post_run_callbacks.py tests/test_callbacks.py tests/test_schemas.py tests/test_preset_router.py --show-diff-on-failure
  • uv run pytest tests/test_callbacks.py tests/test_schemas.py tests/test_preset_router.py::TestGenerateTarball -q

Note: tests/test_watchdog.py could not be run in this environment because the Docker daemon is unavailable and the test fixture starts a Postgres testcontainer before executing tests.

Closes #208
Linear: APP-2489

This PR description was updated by an AI agent (OpenHands) on behalf of the user.

@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Co-authored-by: openhands <openhands@all-hands.dev>
@malhotra5
malhotra5 force-pushed the app-2489-post-run-callbacks branch from e64ac90 to 666ade6 Compare June 24, 2026 21:42
@all-hands-bot

Copy link
Copy Markdown
Contributor

👋 This PR needs a couple of things fixed before OpenHands can review it:

  • the PR description's HUMAN: section needs at least 20 characters describing what you tested, not just the template placeholder

Push an update once this is addressed and this check re-runs automatically.

This is an automated check - no AI was used to generate this comment.

@all-hands-bot

Copy link
Copy Markdown
Contributor

Required CI has remained failing for seven days. Please repair it or comment with an update. If the author does not push or comment and required CI remains failing for another seven days, this pull request will be closed automatically.

@all-hands-bot

Copy link
Copy Markdown
Contributor

Closing because required CI is still failing seven days after the automated warning and the author has not pushed or commented. The pull request can be reopened when work resumes.

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.

Support post-run callbacks inside automation sandboxes

3 participants