Skip to content

fix: apply the continue_conversation keep_alive rule to presets - #740

Merged
enyst merged 3 commits into
mainfrom
claude/project-thread-aesue3-preset-keep-alive
Nov 11, 2026
Merged

enyst merged 3 commits into
mainfrom
claude/project-thread-aesue3-preset-keep-alive

Conversation

@enyst

@enyst enyst commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Requested by Engel · project thread

I'm an AI agent based on Opus 5.5, helping Engel Nyst (@enyst) with project maintenance.

Summary

POST /v1 forces keep_alive: true for an event trigger with destination: continue_conversation and refuses keep_alive: false with 422, but POST /v1/preset/prompt and POST /v1/preset/plugin skipped that rule: an omitted keep_alive was stored null and false was accepted with 201. The run-complete handler and the watchdog delete a sandbox unless keep_alive is true, so a preset-created automation lost the conversation the next event should continue after every run. The rule now lives in one shared helper that every create and update path uses (including git sync), so the presets answer exactly like POST /v1.

Issue Number

Fixes #734

Changes

  • schemas.py: new continue_conversation_keep_alive(trigger, keep_alive) and CONTINUE_CONVERSATION_KEEP_ALIVE_ERROR, the one place the rule is defined. CreateAutomationRequest's validator now calls it.
  • preset_router.py: CreatePromptAutomationRequest and CreatePluginAutomationRequest gain the same after-validator, so omitted keep_alive becomes true and false is a 422 with the POST /v1 message.
  • router.py: the plugin-spec create (its trigger can come from the manifest, so the rule runs in the handler) and PATCH replace their copies of the rule with the helper. Their status codes stay as they were (400).
  • git_sync/loop.py: _validate_and_resolve_fields (import-create and update-from-git) applies the helper. A missing keep_alive becomes true; keep_alive: false with continue_conversation skips that directory with the usual Skipping invalid automation directory warning, and the rest of the cycle is unaffected.
  • Drafts and /v1/validate: they diverged only because they validate against the preset request models (FINAL_DRAFT_MODELS), so they now follow the rule with no code change of their own. Partial draft bodies (draft_schemas) still accept the field as typed; the refusal shows up in validation_errors, like other final-shape errors.
  • Tests: presets (tests/test_preset_router.py, including cron and other event presets storing keep_alive exactly as sent), /v1/validate (tests/test_capabilities_router.py), preset drafts (tests/test_draft_router.py), git sync import and update (tests/test_git_sync.py).
  • verify-automation map: removed the # bug: markers and "known bug" wording from F06.continue-keep-alive and F06.continue-keep-alive-false; the false recipe checks the 422 message for both presets and that nothing was created. F06 prose/gotcha and the F05 cross-reference updated; README counts via map check --fix-counts. F13.import-invalid-skipped also pushes a continue_conversation directory with keep_alive: false and checks it is skipped and logged.

Evidence

  • uv run pytest -q tests/test_preset_router.py -k ContinueConversationKeepAlive: 22 passed. tests/test_git_sync.py -k TestImportedAutomationDefaults: 11 passed. Drafts/validate/plugin-spec -k "keep_alive or continu": 16 passed. tests/test_verify_automation_skill.py: 59 passed.
  • Full suite uv run pytest -q -n 4: 2903 passed, 7 skipped, 0 failed (the last commit only adds tests, which pass).
  • uv run pre-commit run --files <changed files>: ruff format, ruff lint, pycodestyle, pyright pass.
  • Baseline (origin/main 1b571fd), map run --file F06 --only <id> --fresh --repeat 2 --checkout <baseline>: both bullets xfail ×2. Fix with markers present: both xpass ×2. Markers dropped, map run --file F06 --fresh: 16 pass, 0 fail.
  • map run --file F13 --fresh: 30 pass, 0 fail. map run --file F05 --fresh: F05.patch-validation and F05.keep-alive-continue pass; the only fail is F05.tarball-path-errors, map drift on main fixed in docs(verify-automation): correct map drift in F03, F05 and F11 #738.
  • Independent review: no blockers; its finding that git sync still skipped the rule is fixed in 6d7fc97.

Notes

  • PATCH and POST /v1/plugin-spec now call the shared helper with unchanged behavior and status codes (400). Cron and other non-continue_conversation triggers store keep_alive as given.
  • No backfill migration. Rows that presets or git sync created before this fix keep keep_alive null or false. Any PATCH corrects a null row; a false row refuses PATCH with 400 unless the client also sends keep_alive: true, as on main.
  • A saved preset draft with continue_conversation and keep_alive: false could be dispatched before and is now refused, consistent with POST /v1.

🤖 Generated with Claude Code

https://claude.ai/code/session_013ArwwM9ABBZYP9fcggw4R8

The prompt and plugin preset routes skipped the rule POST /v1 enforces for
an event trigger with destination continue_conversation: an omitted
keep_alive was stored null and keep_alive false was accepted, so the
run-complete handler and the watchdog deleted the sandbox holding the
conversation the next event continues.

The rule now lives in one helper, continue_conversation_keep_alive, used by
CreateAutomationRequest, both preset request models, the plugin-spec create
and PATCH. Because /v1/validate and drafts validate against the same preset
request models, they report the same refusal and materialize keep_alive
true.

Fixes #734

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwM9ABBZYP9fcggw4R8
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Warning

Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it.

Git sync stored keep_alive from automation.yaml as given, on both a new
import and an update from git. It now goes through
continue_conversation_keep_alive: an omitted value becomes true, and
keep_alive false with a continue_conversation trigger skips that directory
with the same logged warning as any other invalid field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwM9ABBZYP9fcggw4R8
…rsation

Cron and dispatch_run event presets store keep_alive exactly as given
(omitted, false or true), on both preset routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwM9ABBZYP9fcggw4R8
@enyst
enyst requested a review from all-hands-bot November 11, 2026 19:51

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This review was posted by an AI agent (OpenHands).

Fresh review of head aff7bba5 (re-confirmed: PR open, head matches, no prior reviews on this commit, all checks green including unit-tests and windows-tests; issue #734 still labeled bug, ready-for-dev, priority:medium).

Scope gate: automation definitions, presets, validation, and git sync are owned by this repository per AGENTS.md; the change belongs here.

Technical review — no material findings:

  • continue_conversation_keep_alive in schemas.py has identical semantics to the inline rule it replaces on POST /v1: parsed EventTrigger or stored dict both resolve destination; anything else passes keep_alive through unchanged; false raises ValueError with the shared message; omitted/true settles to true.
  • The preset after-validators run after field validation, so self.trigger is the parsed discriminated union — verified directly against CreatePromptAutomationRequest, CreatePluginAutomationRequest, and CreateAutomationRequest (omitted→true, false→ValidationError with CONTINUE_CONVERSATION_KEEP_ALIVE_ERROR, cron/non-continuing event triggers store the value as given).
  • create_automation_from_plugin_spec keeps the rule in the handler (the trigger can come from the manifest) and keeps its 400; PATCH's merged-view handling is behavior-preserving (400 on false, writes true when the merged value differs, no write when already true).
  • Git sync applies the helper inside _validate_and_resolve_fields for both import-create and update-from-git; the ValueError lands in the cycle's except (ValidationError, ValueError) so the directory is skipped with the standard warning and pending storage deletes roll back. The serializer/export round-trip stays stable (a forced true re-imports as true).
  • Drafts and /v1/validate inherit the rule through FINAL_DRAFT_MODELS; partial draft bodies (draft_schemas) still accept the field as typed, with the refusal surfacing in validation_errors at final shape — consistent and tested.
  • Watchdog and run-complete cleanup are unchanged and correctly rely on keep_alive alone, now guaranteed for every create path. No schema change, so no migration; pre-existing null/false rows are addressed in the PR notes.

Tests/evidence: ran the Docker-free portions in the workspace — tests/test_git_sync.py 80 passed (includes the three new continuing import/update tests over real git), tests/test_schemas.py 33 passed, and the preset/validate model-level assertions. The remaining endpoint tests in this workspace error at fixture setup because no Docker daemon is available for the PostgreSQL testcontainer — the same fixtures already error on main's tests here, and the unit-tests CI job passes on this exact head, so this is local-environment, not the change.

✅ APPROVED

@enyst
enyst merged commit c32dab1 into main Nov 11, 2026
14 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: 1.33.0 Shipped in 1.33.0 label Nov 17, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.33.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.33.0 Shipped in 1.33.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Presets skip the continue_conversation keep_alive rule, so the conversation's sandbox is deleted after each run

2 participants