-
Notifications
You must be signed in to change notification settings - Fork 11.6k
ci: add reusable Devin session checking action with age limit #26763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ci: add reusable Devin session checking action with age limit #26763
Conversation
…limit
- Create .github/actions/check-devin-session composite action that:
- Finds existing Devin sessions from PR body or comments
- Checks session status via Devin API
- Validates session age (default 7 days max)
- Returns whether session is valid for reuse or too old
- Update cubic-devin-review.yml to use the reusable action
- Update devin-conflict-resolver.yml to use the reusable action
- Update stale-pr-devin-completion.yml to use the reusable action
- Fix merge commit message for fork PRs to use 'Merge branch 'main' into {branch}'
instead of 'Merge upstream/main into {branch}' to match GitHub UI behavior
This addresses the case where an existing session is found but Devin
says it's too old and a new session should be started.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 issues found across 4 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name=".github/actions/check-devin-session/action.yml">
<violation number="1" location=".github/actions/check-devin-session/action.yml:62">
P2: `max_session_age_days` cannot be configured to `0` because the code falls back to `7` for any falsy value, so workflows cannot opt out of session reuse. Preserve an explicit `0` and only fall back when the input is missing or invalid.</violation>
<violation number="2" location=".github/actions/check-devin-session/action.yml:86">
P2: `isSessionTooOld` crashes when `session.created_at` exists but is not a valid date, because `createdAt.toISOString()` throws instead of treating the session as unusable. Guard against invalid dates so the action can continue and create a new session.</violation>
<violation number="3" location=".github/actions/check-devin-session/action.yml:117">
P2: `findSessionFromComments` only inspects the first page (30 items) of PR comments, so Devin sessions mentioned in older comments are ignored and valid sessions go undetected on busy PRs. Paginate through all comments before searching.</violation>
</file>
<file name=".github/workflows/devin-conflict-resolver.yml">
<violation number="1" location=".github/workflows/devin-conflict-resolver.yml:231">
P2: Manual workflow_dispatch runs always pass an empty PR body into the session-check action, so sessions referenced only in the PR description are never detected, regressing the previous behavior.</violation>
</file>
<file name=".github/workflows/stale-pr-devin-completion.yml">
<violation number="1" location=".github/workflows/stale-pr-devin-completion.yml:157">
P2: `github.event.pull_request` is undefined for `workflow_dispatch` events, so the reusable action never receives a PR body when the workflow is run manually. This breaks session detection for dispatch runs because any session link in the PR description is ignored.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const createdAt = new Date(session.created_at); | ||
| const now = new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: isSessionTooOld crashes when session.created_at exists but is not a valid date, because createdAt.toISOString() throws instead of treating the session as unusable. Guard against invalid dates so the action can continue and create a new session.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/actions/check-devin-session/action.yml, line 86:
<comment>`isSessionTooOld` crashes when `session.created_at` exists but is not a valid date, because `createdAt.toISOString()` throws instead of treating the session as unusable. Guard against invalid dates so the action can continue and create a new session.</comment>
<file context>
@@ -0,0 +1,191 @@
+ return true;
+ }
+
+ const createdAt = new Date(session.created_at);
+ const now = new Date();
+ const ageInDays = (now - createdAt) / (1000 * 60 * 60 * 24);
</file context>
Fix confidence (alpha): 8/10
| const createdAt = new Date(session.created_at); | |
| const now = new Date(); | |
| const createdAt = new Date(session.created_at); | |
| if (Number.isNaN(createdAt.getTime())) { | |
| console.log('Session created_at is invalid, treating it as expired'); | |
| return true; | |
| } | |
| const now = new Date(); |
| const comments = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: findSessionFromComments only inspects the first page (30 items) of PR comments, so Devin sessions mentioned in older comments are ignored and valid sessions go undetected on busy PRs. Paginate through all comments before searching.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/actions/check-devin-session/action.yml, line 117:
<comment>`findSessionFromComments` only inspects the first page (30 items) of PR comments, so Devin sessions mentioned in older comments are ignored and valid sessions go undetected on busy PRs. Paginate through all comments before searching.</comment>
<file context>
@@ -0,0 +1,191 @@
+ return null;
+ }
+
+ const comments = await github.rest.issues.listComments({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
</file context>
Fix confidence (alpha): 8/10
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| const comments = await github.paginate( | |
| github.rest.issues.listComments, | |
| { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| per_page: 100 | |
| } | |
| ); | |
| for (const comment of [...comments].reverse()) { |
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. |
Fixes issue identified by Cubic where setting max_session_age_days to 0 would fall back to 7 due to falsy value check. Now uses Number.isFinite() to properly handle explicit 0 values. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…s://git-manager.devin.ai/proxy/github.com/calcom/cal.com into devin/reusable-devin-session-action-1768242200
…t.body For workflow_dispatch events, github.event.pull_request is undefined, so the PR body was not being passed to the check-devin-session action. Now both workflows fetch the PR body in the 'Get PR details' step and pass it as an output to the check-session step. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Devin AI is resolving merge conflictsThis PR has merge conflicts with the Devin will:
If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself. |
Co-Authored-By: unknown <>
What does this PR do?
This PR addresses the case where an existing Devin session is found but is too old to reuse (Devin responds with "Cannot revive Devin session - the session is too old"). It creates a reusable GitHub composite action for session checking and updates all three Devin-related workflows to use it.
Changes:
.github/actions/check-devin-session/action.yml- a reusable composite action that finds and validates existing Devin sessions, checking both session status and age (default 7 days max)cubic-devin-review.ymlto use the reusable actiondevin-conflict-resolver.ymlto use the reusable actionstale-pr-devin-completion.ymlto use the reusable action (previously didn't check for existing sessions)Merge branch 'main' into {branch}instead ofMerge upstream/main into {branch}to match GitHub UI behaviorReference: #25844 (comment)
Link to Devin run: https://app.devin.ai/sessions/936ea61cd543482b97255c4f43ada36e
Requested by: @keithwillcode
Updates since last revision
max_session_age_dayshandling: Changed fromparseInt(...) || 7toNumber.isFinite(parsed) ? parsed : 7so that settingmax_session_age_days: "0"works correctly instead of falling back to 7pr_bodyforworkflow_dispatchevents: Bothdevin-conflict-resolver.ymlandstale-pr-devin-completion.ymlnow pass the PR body via step outputs (steps.get-pr.outputs.pr-body/steps.pr.outputs.pr_body) instead ofgithub.event.pull_request.body, which is undefined for manual workflow dispatch runsMandatory Tasks (DO NOT REMOVE)
How should this be tested?
These workflow changes can only be tested in production when the workflows are triggered:
Cubic review workflow: Have Cubic AI post a review with an AI prompt on a PR that has an existing Devin session older than 7 days - should create a new session instead of reusing the old one.
Conflict resolver workflow: Add the
devin-conflict-resolutionlabel to a PR with conflicts that has an existing Devin session older than 7 days - should create a new session.Stale PR workflow: Add the
stalelabel to a PR that has an existing valid Devin session - should reuse the existing session and post a comment indicating "The existing Devin session has been notified".Merge commit message: For fork PRs with conflicts, verify the merge commit message is
Merge branch 'main' into {branch}(notMerge upstream/main into {branch}).Manual dispatch: Run
devin-conflict-resolverorstale-pr-devin-completionvia workflow_dispatch with a PR number - should correctly detect sessions from the PR body.Checklist
Human Review Checklist
max_session_age_daysfix properly allows 0 value (line 62-63 in action.yml)pr_bodyoutput is correctly passed for workflow_dispatch events in both workflowsisSessionTooOld()may crash ifsession.created_atis an invalid date string (identified by Cubic, confidence 8/10 - not fixed)findSessionFromComments()only checks first page of comments (identified by Cubic, confidence 8/10 - not fixed)