Skip to content

[fix] Keep the flag-off watchdog and late-output defaults unchanged - #6577

Merged
mmabrouk merged 2 commits into
release/v0.115.0from
fix/session-control-flag-off
Sep 5, 2026
Merged

[fix] Keep the flag-off watchdog and late-output defaults unchanged#6577
mmabrouk merged 2 commits into
release/v0.115.0from
fix/session-control-flag-off

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member

Context

With durable Stop disabled, the milestone changed two production defaults: stale running sessions closed after 90 seconds instead of the release baseline of 300 seconds, and late runner output was hidden in quarantine. The milestone also made clients retry a successful legacy Stop after 30 seconds even though the unchanged heartbeat path can take almost 30 seconds to notice Redis displacement before the new harness-cancel work begins.

Changes

  • Keep the watchdog settlement active in both flag states, but default its stale-heartbeat threshold to 300 seconds when durable Stop is off and 90 seconds when it is on. An explicit watchdog threshold still overrides either default.
  • Leave late runner output visible when durable Stop is off. Keep quarantine and reject handling on the durable path.
  • Treat the legacy HTTP-200 cancellation response as locally settled on desktop and mobile. The clients abort their local stream after the API confirms displacement, while durable Stops continue waiting for terminal evidence.

Tests

  • pytest oss/tests/pytest/unit/sessions -q -o addopts='': 731 passed on the milestone-2 databases.
  • Ruff 0.15.12 format and check: passed for all changed API files.
  • Desktop Stop hook: 7 passed. Mobile Stop state: 5 passed.
  • Targeted desktop and mobile ESLint: passed.
  • Full web typechecks remain unavailable in this worktree because its shared dependency tree is incomplete and stale; the failures are missing modules and unrelated existing type errors.

https://claude.ai/code/session_0164kzT6ttwpBtzvcDC6YzYk

Keep the pre-milestone watchdog threshold and visible late output when durable Stop is disabled. Retain watchdog terminal settlement and the stricter durable Stop behavior.

Claude-Session: https://claude.ai/code/session_0164kzT6ttwpBtzvcDC6YzYk
Abort the local stream as soon as the flag-off legacy API confirms Redis displacement. Keep durable Stops waiting for terminal evidence and prevent the legacy path from entering the 30-second retry state.

Claude-Session: https://claude.ai/code/session_0164kzT6ttwpBtzvcDC6YzYk
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 5, 2026 2:23pm UTC

Request Review

@mmabrouk mmabrouk added the lgtm This PR has been approved by a maintainer label Sep 5, 2026
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 7e07085e-6ad9-4242-af61-4dfcdd8a2ad0

📥 Commits

Reviewing files that changed from the base of the PR and between 5c4c2ef and 7d383c2.

📒 Files selected for processing (11)
  • api/oss/src/core/sessions/records/service.py
  • api/oss/src/tasks/asyncio/sessions/orphan_sweep.py
  • api/oss/src/utils/env.py
  • api/oss/tests/pytest/unit/sessions/test_late_record_quarantine.py
  • api/oss/tests/pytest/unit/sessions/test_orphan_sweep_thresholds.py
  • api/oss/tests/pytest/unit/sessions/test_session_cancel_feature_flag.py
  • web/mobile/src/features/chat/LiveConversation.tsx
  • web/mobile/src/features/chat/stopHereState.ts
  • web/mobile/tests/unit/stopHereState.test.ts
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Improved Stop handling so sessions that have already become idle are recognized as settled instead of entering retry flows.
    • Updated mobile chat behavior to correctly finalize both settled and retry stop outcomes.
    • Preserved visibility of late session records when Durable Stop is disabled.
  • Behavior Updates

    • Session watchdog timing now uses a 90-second threshold with Durable Stop enabled and retains the 300-second threshold when disabled.
    • Orphan-session detection follows the corresponding watchdog timing for each configuration.

Walkthrough

The change preserves pre-milestone session behavior when Durable Stop is disabled. It adds flag-dependent watchdog thresholds, keeps late records visible, and treats idle executions as settled stops in mobile and web session flows.

Changes

Durable Stop settlement

Layer / File(s) Summary
Backend Durable Stop thresholds and late events
api/oss/src/utils/env.py, api/oss/src/core/sessions/records/service.py, api/oss/src/tasks/asyncio/sessions/orphan_sweep.py, api/oss/tests/pytest/unit/sessions/*
Watchdog defaults use 90 seconds when Durable Stop is enabled and 300 seconds otherwise. Late events remain visible when Durable Stop is disabled. Tests cover both flag states.
Mobile settled-stop action
web/mobile/src/features/chat/stopHereState.ts, web/mobile/src/features/chat/LiveConversation.tsx, web/mobile/tests/unit/stopHereState.test.ts
The stop state adds abort-settled for idle executions. The conversation flow handles this action as a completed stop.
Web legacy stop settlement
web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts, web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts
An acknowledged idle execution now stops the SDK session and dispatches the terminal phase without entering the retry deadline. Tests verify the behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 7d383

This change preserves legacy behavior when Durable Stop is disabled and settles acknowledged idle cancellations in web and mobile clients, avoiding unnecessary retry waits. The covered behavior is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes to preserve flag-off watchdog and late-output defaults. It is concise and specific, although it does not mention the related cancellation behavior.
Description check ✅ Passed The description accurately covers the watchdog thresholds, late-output behavior, legacy cancellation handling, and test results described by the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/session-control-flag-off

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agent-generated Codex review, low weight.

SHIP

No blocking findings.

Flag-off restores the c49c45e baseline where comparable: a 300-second orphan threshold and visible late records, while watchdog terminal settlement stays active. Flag-on still defaults to 90 seconds and retains the quarantine/reject policy.

Desktop and mobile abort immediately only for an accepted response whose normalized execution state is idle, which is the legacy HTTP 200 shape. Accepted durable responses remain HTTP 202/stopping and keep waiting for terminal evidence; the existing retry path is unchanged. The legacy response follows expected-turn Redis displacement, so local abort cannot undo or retarget the cancellation, and later terminal records remain independently ingested and available to watch/hydration.

Relevant GitHub API, web, mobile, lint, type, and image-build checks pass. A focused local desktop rerun was environment-blocked by the incomplete shared dependency tree; no dependency install or purge was performed.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-09-05T15:08:20.194Z

@mmabrouk
mmabrouk merged commit 480e020 into release/v0.115.0 Sep 5, 2026
70 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant