ENG-26: webhook regex accepts sesn_ session-id prefix#15
Conversation
The webhook session-id extractor in app/api/github-webhook/route.ts only matched `sthr_`-prefixed ids, but the current `@anthropic-ai/sdk` returns session ids with the `sesn_` prefix. So `extractSessionId` returned null for every marker the agent has actually been writing, and every `AGENT_REVIEW: APPROVED`, `REQUEST_CHANGES`, and post-merge webhook fell back to creating a fresh session instead of resuming the originating one. Fix: regex now accepts either prefix: (?:sthr_|sesn_)[A-Za-z0-9]+ Backward-compatible — any old `sthr_`-prefixed marker still matches. Also updated the convention doc and the MEMORY.md hook to reflect that both prefixes are accepted (with `sesn_` called out as the current shape). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Before ( After: (Where The change is a single capturing group becoming non-capturing-alternation: The session-id marker at the literal end of the original PR body (which IS the smoke test for this fix) was likewise stripped by the same MCP filter. That means the post-approval webhook on this PR will fall back to a fresh session no matter what — there's no path for an agent to persist the marker today (per ENG-25, every body-edit transport the agent has access to is gated by the same filter). Not blocking this fix; just noting that end-to-end verification of the resume-via-marker flow requires either ENG-25 to land or a human pasting the marker into the body via the web UI / a token-authed PATCH. |
|
AGENT_REVIEW: APPROVED — 1-line regex fix correctly accepts both Checked:
Note (not a blocker): the PR body itself ends with the new |
Add convention `check-open-pr-before-ticket-pickup.md`: before branching for a Linear ticket picked from Triage/Todo, list open PRs and grep for the ticket ID; if one already exists, defer. One extra MCP call to prevent the kind of parallel-session race that produced PRs #15 and #16 (both opened for ENG-26 within ~3 minutes of each other and both merged). Standalone memory PR — no Linear ticket.
Captures the PR #18 vs PR #20 ENG-25 race — same shape as the PR #15 vs #16 ENG-26 race that prompted the original check-open-pr-before-ticket-pickup convention. Session-start grep isn't enough; near-simultaneous sessions both pass it because the loser's PR isn't indexed yet at the winner's grep time. Adds a learnings entry recommending a second grep right before create_pull_request. Co-authored-by: Self-Managing Codebase Manager <7004983+WillTaylor22@users.noreply.github.com>
Fixes ENG-26.
Problem
app/api/github-webhook/route.ts:20extracted the PR session marker with:The regex required
sthr_but the current@anthropic-ai/sdkreturns session ids with thesesn_prefix. Every recent kickoff and PR branch carriessesn_:sesn_01GwXkeQp4Q6sE1yhv6MZg1mclaude/memory-pw-capture-executable-path-sesn_01NWSr2N2SvFBsMJ3jAedoDHclaude/memory-vercel-bot-status-fallback-sesn_01Cb3FhmHgdKCZqcB8SY1jhrclaude/eng-19-pw-globalSetup-sesn_0139FGzjygnxCi69wpJ14PRFSo
extractSessionIdreturnednullfor every marker the agent has been writing. EveryAGENT_REVIEW: APPROVED,REQUEST_CHANGES, and post-merge webhook fell through to creating a fresh session — the resume mechanism has been silently non-functional since the SDK switched prefixes.This is independent of ENG-25 ("MCP strips HTML comments"). Even if the marker were perfectly persisted, the regex never matched.
Fix
Backward-compatible: any old
sthr_-prefixed marker still matches. Memory + convention doc updated to call outsesn_as the current shape andsthr_as accepted-legacy.Verification
next build+eslint. If TS or lint fails, the preview status check will catch it.<!-- session-id: sesn_01GwXkeQp4Q6sE1yhv6MZg1m -->marker below survivescreate_pull_request(untested per ENG-25), and the reviewer'sAGENT_REVIEW: APPROVEDwebhook fires post-approval, the next manager-tick should resume this session rather than spawning a fresh one. That's the end-to-end signal.ENG-25 side-effect probe
ENG-25 documented that MCP
update_pull_requeststrips<!-- ... -->comments but flagged thatcreate_pull_requestwas untested. This PR is the test: I'm including the marker on initial creation. If it survives, agents have a viable path to land the marker (open-with-marker, never edit-the-marker-later). If it doesn't, ENG-25's scope expands. Will post a comment on ENG-25 with the result after this PR exists.Diff size
3 files, +8/-3. Code: 1-line regex change. Docs: 2 files updated to match.