Skip to content

Conversation

@keithwillcode
Copy link
Contributor

@keithwillcode keithwillcode commented Jan 12, 2026

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:

  • Creates .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)
  • Updates cubic-devin-review.yml to use the reusable action
  • Updates devin-conflict-resolver.yml to use the reusable action
  • Updates stale-pr-devin-completion.yml to use the reusable action (previously didn't check for existing sessions)
  • Fixes 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

Reference: #25844 (comment)

Link to Devin run: https://app.devin.ai/sessions/936ea61cd543482b97255c4f43ada36e
Requested by: @keithwillcode

Updates since last revision

  • Fixed max_session_age_days handling: Changed from parseInt(...) || 7 to Number.isFinite(parsed) ? parsed : 7 so that setting max_session_age_days: "0" works correctly instead of falling back to 7
  • Fixed pr_body for workflow_dispatch events: Both devin-conflict-resolver.yml and stale-pr-devin-completion.yml now pass the PR body via step outputs (steps.get-pr.outputs.pr-body / steps.pr.outputs.pr_body) instead of github.event.pull_request.body, which is undefined for manual workflow dispatch runs

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - internal workflow changes only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works. N/A - GitHub workflow changes cannot be unit tested.

How should this be tested?

These workflow changes can only be tested in production when the workflows are triggered:

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

  2. Conflict resolver workflow: Add the devin-conflict-resolution label to a PR with conflicts that has an existing Devin session older than 7 days - should create a new session.

  3. Stale PR workflow: Add the stale label 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".

  4. Merge commit message: For fork PRs with conflicts, verify the merge commit message is Merge branch 'main' into {branch} (not Merge upstream/main into {branch}).

  5. Manual dispatch: Run devin-conflict-resolver or stale-pr-devin-completion via workflow_dispatch with a PR number - should correctly detect sessions from the PR body.

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have checked if my changes generate no new warnings

Human Review Checklist

  • Verify the max_session_age_days fix properly allows 0 value (line 62-63 in action.yml)
  • Verify pr_body output is correctly passed for workflow_dispatch events in both workflows
  • Note: isSessionTooOld() may crash if session.created_at is an invalid date string (identified by Cubic, confidence 8/10 - not fixed)
  • Note: findSessionFromComments() only checks first page of comments (identified by Cubic, confidence 8/10 - not fixed)
  • Confirm the merge commit message format matches what GitHub UI produces
  • Check that session patterns are consistent across all three workflows

…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-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@keithwillcode keithwillcode added this to the v6.1 milestone Jan 12, 2026
@keithwillcode keithwillcode marked this pull request as ready for review January 12, 2026 18:38
@keithwillcode keithwillcode requested a review from a team as a code owner January 12, 2026 18:38
@graphite-app graphite-app bot added foundation core area: core, team members only labels Jan 12, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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.

Comment on lines +86 to +87
const createdAt = new Date(session.created_at);
const now = new Date();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

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

Suggested change
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();
Fix with Cubic

Comment on lines +117 to +119
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

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

Suggested change
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()) {
Fix with Cubic

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session

keithwillcode and others added 3 commits January 12, 2026 18:54
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>
…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>
@keithwillcode keithwillcode changed the title feat(workflows): add reusable Devin session checking action with age limit ci: add reusable Devin session checking action with age limit Jan 12, 2026
@vercel vercel bot temporarily deployed to Preview – cal-companion January 13, 2026 09:34 Inactive
@vercel vercel bot temporarily deployed to Preview – dev January 13, 2026 09:34 Inactive
@CarinaWolli CarinaWolli modified the milestones: v6.1, v6.2 Jan 16, 2026
@github-actions
Copy link
Contributor

Devin AI is resolving merge conflicts

This PR has merge conflicts with the main branch. A Devin session has been created to automatically resolve them.

View Devin Session

Devin will:

  1. Merge the latest main into this branch
  2. Resolve any conflicts intelligently
  3. Run lint/type checks to ensure validity
  4. Push the resolved changes

If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants