Skip to content

Add post-run automation callbacks#211

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

Add post-run automation callbacks#211
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

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
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

2 participants