Skip to content

feat(session-flow): arm a fresh background session for step-away before the person leaves - #17435

Merged
kyle-sexton merged 7 commits into
mainfrom
feat/17386-armed-background-handoff
Nov 19, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
feat/17386-armed-background-handoff

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Closes #17386

Summary

A step-away request for a fresh session used to hand off to a background session with no away rules, refusals or report. step-away now launches the background session through continue-in-background with the plain /goal payload, then arms it from the attended session while the person is still there: away.py start --session <the background session's full id>. This is the owner's decision Q228 option (a) on #17386; the earlier leading /session-flow:step-away first-prompt design is reverted.

Fix

  • continue-in-background: the launch report now reads claude agents --json --all, takes the entry whose id is the short id claude --bg printed, and reports its full sessionId (--bg ignores --session-id, so this is the only source). When another skill invoked it through the Skill tool, it hands that id back instead of ending the task. The payload stays plain /goal; no new flag and no gate exception.
  • step-away step 6: settle the absence and write the task file first, invoke continue-in-background with done when every item in <task file> is done or marked parked (case 1 of its gate, no draft or confirmation), then run start and status for the returned id at once. No id back means not armed: say so and offer to arm this session.
  • away.py refresh: when no hook recorded the transcript path, find <config>/projects/*/<session id>.jsonl. In the probe the background session's Stop hook never recorded the path, so without this the report's External actions block stayed empty.
  • goal-probe.md records the probe (probe 4); README sentence updated; eval case 20 replaced to cover the id hand-back.

Verification

  • Live probe, Claude Code 2.1.328, Linux (WSL2), one background session: claude --bg --name <name> --permission-mode auto --setting-sources local --settings '{"worktree":{"bgIsolation":"none"}}' --plugin-dir <checkout>/plugins/session-flow "$(cat <payload>)", payload /goal every item in <task file> is ticked done or marked parked plus one instruction line. Then, as separate tool calls, claude agents --json --all for the full id and away.py start --session <full id> --data-root <plugin data>/session-flow-inline.
    • Timeline: launch returned at 0 s; Goal set: and first prompt at 1.5 s (no away state yet); start wrote the state at 7.8 s; the away Stop hook rewrote state.json at 13.7 s, so the first Stop read the state.
    • Race: the window is launch to start. The first prompt gets no away note, a permission prompt in the window is not refused, and actions before start are not in the report. A first turn ending in the window is not held, but the goal names the task file, so the session keeps going (reasoned, not observed). Documented in goal-probe.md.
    • refresh with the new fallback found the transcript (External actions None. instead of "not recorded yet").
    • Cleanup: claude stop, claude rm, away.py end, away.py deliver; probe folder and report deleted.
  • uvx --with pytest pytest plugins/session-flow/scripts/tests -q: 550 passed. New test test_refresh_finds_an_unrecorded_transcript_under_projects.
  • scripts/run-ruff.sh check <worktree>: all checks passed.
  • check-skill.sh plugins/session-flow/skills: 20 passed, 0 failed (it skipped its own script tests because the shell's cwd was another checkout; pytest above covers them). validate-cases.py plugins/session-flow/evals: no failures, pre-existing warnings only. Pre-push check-affected passed.
  • Left out: a launch with worktree isolation on, where the task file and report sit outside the background session's worktree (untested); a paid eval run of case 20.

Related

🤖 Generated with Claude Code

continue-in-background takes --step-away "<words>": the launch payload's
first line becomes /session-flow:step-away <words>, so the background
session arms its own absence under its own id and its Stop hook holds the
completion condition. step-away's fresh-session step now hands off armed
through it instead of unarmed. A live --bg probe is recorded in
goal-probe.md.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 14:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T14:26:45.376685Z a1e2cab Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1e2cab2bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none (read lane)
Run 44543526493

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

With --step-away and no goal region, the text after the leading command
is the resume region's Read @ line (full path) or its between-rails text
(prompt-only), and the completion condition gate's cases 2 and 3 do not
apply on that path.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed d54f4be48aac3340f8d19e05f5fc9a0fd29149e6: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #17435, incremental from 091e7bd5 to d54f4be4

No security issues found. I read every hunk of both files in the incremental scope: .changes/session-flow/feat-17386-armed-background-handoff-670b530a.md and plugins/session-flow/skills/step-away/SKILL.md. This lane already reviewed an earlier head (blocking only: yes), so this review looked for CRITICAL and IMPORTANT findings only.

What I checked

  • step-away step 6, the new task-file header line (SKILL.md#L94-L97)
    • The attended session writes the task file itself, under the ignored .work/ path, while the person is still there.
    • The rules path in the header comes from ${CLAUDE_PLUGIN_ROOT}/skills/step-away/reference/rules.md. That is the plugin's own install root, not text from a pull request, an issue or the user.
    • The header adds an instruction: the background session is told to read the away rules. No rule, gate or block list is removed or softened, so the instruction-surface deletion lens has nothing to match.
  • Report path appended after start (SKILL.md#L103-L104)
    • The value is what away.py start prints. The earlier review found that command's --session argument is checked against SESSION_RE.
    • Nothing outside the machine supplies the value, and the path stays local.
  • Changelog fragment: prose only, with no security surface.
  • No plugin manifest, trust control, merge hold, token request or kill-switch file is touched in this increment.

Spend. Unchanged: one background session per fresh-session step-away, as before.

critical-findings: 0

@github-actions github-actions 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.

claude-review: 2 inline finding(s) on a1e2cab2bd8b8dc18f95203c8dcc915af5b7b9a9; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed d54f4be48aac3340f8d19e05f5fc9a0fd29149e6: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental, blocking only): d54f4be4

I already reviewed earlier heads of this pull request, so this review reports blocking findings only. It covers the change since 091e7bd5: both files on the incremental list, .changes/session-flow/feat-17386-armed-background-handoff-670b530a.md and plugins/session-flow/skills/step-away/SKILL.md. I read every hunk of both.

No blocking findings.

Last round's finding is addressed. That finding was that the background session never got the away rules or the report path. This push changes step 6 in two places:

  • Sub-step 1 now writes a header line above the task file's checklist. The line says the session runs in away mode and names reference/rules.md by absolute path, to be read before the first item (SKILL.md L94-L97).
  • Sub-step 3 adds the report path that start prints to that header line (L102-L104).

The goal condition sends the background session to this file on its first turn.

Checks I ran by reading the code:

  • Task counting. The header line does not change check or the Stop hook's count. TASK_RE only matches checklist bullets (away.py L135).
  • First-turn race on the report path. The background session can read the task file before sub-step 3 adds the report path; probe 4 puts the first prompt at about 1.5 s and start at 7.8 s. This does not block. rules.md names away.py status as the source of the report path and the task file path (rules.md L9), and the header line sends the session to that file first.

Changelog fragment: the new sentence matches the skill change. bump: minor still fits a feature addition.

Closing issue #17386: the owner's recorded decision Q228 (a) replaced the issue's "Done looks like" items. My last review found all three parts of that decision met, and this push does not touch them. The owner explained on the settled thread why there is no eval case for the header line: an eval run cannot launch and clean up a real claude --bg session. Under blocking-only scope I do not raise it again.

Not verified: I ran none of the author's commands. The live probe, the pytest count, ruff and the check scripts are the author's claims.

Lane notes:

  • Loosened-check verdict: fail. The prompt had no loosened_check_verdict: or loosened_check_patterns: lines, so the default applied with no consumer entries. There was no loosened_check_decision_record: line, so I did not check the citation requirement. No changed file weakens a check.
  • No plugin manifest changed.
  • I found no embedded instructions in the PR context, settled threads or prior findings.
  • Spend: this push changes no run counts, models or limits.

Verifier dropped 0 of 0 candidates.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head 4bcdf96dd04eccd34e13e5b182dd660e603f85d4. What it wrote, as data:

What it wrote (41 lines)
Summary: Issue #17386: the PR builds a different design from the one the owner chose. The issue's
  trusted spec comments include a "Decision recorded" comment (2026-11-19 14:37) that picks option
  (a). In (a), continue-in-background launches with `claude --bg` and reads the session id it prints
  (or gets it from `claude agents --json`). The attended session then runs `away.py start --session
  <that id>` and writes the task file while the person is present, and a probe settles the
  first-turn race. This PR builds option (b) instead: an allowlisted `/session-flow:step-away`
  leading command, where the background session arms itself unattended. The PR body calls this "the
  leading-command design the owner chose" and treats probe p6 as ruling out A. P6 only rules out a
  pre-assigned `--session-id`, not the decided read-the-printed-id flow. The diff also misses the
  issue body's done-when item: on the `--step-away` path, no `/goal` runs after the leading command.
  The skill itself says it is unprobed whether payload lines after the first reach step-away, so the
  resume text on those lines may never reach the launched session. The required CI jobs passed (e.g.
  Check Skills
  https://github.com/melodic-software/claude-code-plugins/actions/runs/44546423158/job/135638406192),
  but they don't settle any of this. No capture was recorded. No binary files and no takeover-set
  files are in the diff.
- plugins/session-flow/skills/step-away/SKILL.md:89: step 6 should follow the recorded decision (a).
  Hand off through continue-in-background as before, take the launched session's id from the `--bg`
  output or `claude agents --json`, and run `away.py start --session <that id>` here, writing the
  task file while the person is present. Don't forward `--step-away` so the background session arms
  itself unattended.
- plugins/session-flow/skills/continue-in-background/SKILL.md:127: replace the 'Leading step-away
  command' payload (which drops `/goal` and relies on unprobed multi-line arguments) with the
  decided flow. Keep the `/goal` payload, then give the caller the launched session's full id (from
  the printed id or `claude agents --json --all`) so it can run `away.py start --session <id>`.
  Update the argument grammar, the gate exemption and the checklist items at lines 158-174 to match.
- plugins/session-flow/skills/continue-in-background/reference/goal-probe.md:36: record the probe
  the decision asks for, i.e. when the hooks first see away state written by `away.py start
  --session <id>` against an already-running `--bg` session (the first-turn race). Probe 4 only
  shows a one-line step-away first prompt arming, which the decision did not choose.
- plugins/session-flow/skills/continue-in-background/evals/evals.json:256: eval 20 asserts the
  payload starts with `/session-flow:step-away` and has no `/goal`. Rewrite it to cover the decided
  payload and hand-off shape: the `/goal` payload is kept, the session id is returned, and arming
  happens attended.
- PR body: it says the owner chose the leading-command design and that probe p6 rules out option A.
  The recorded decision on #17386 is (a), launch then arm attended with the printed id, which p6
  does not rule out. Correct the description to match the decision that is implemented.
- plugins/session-flow/README.md:448 and
  .changes/session-flow/feat-17386-armed-background-handoff-670b530a.md:15: after reworking to
  decision (a), update this wording. It currently says the background session starts armed by
  running step-away first.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 19, 2026
…g it

After a --step-away launch, continue-in-background reads the launched
session's full id and waits up to two minutes for away.py status to read
active, reporting the session armed or arming unconfirmed, so a failed
start in the unattended session is not reported as armed. Two lines still
describing the /goal-only contract now name the launch payload.

Co-authored-by: Claude Opus 5.5 <[email protected]>

@github-actions github-actions 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.

claude-review: 1 inline finding(s) on 4bcdf96dd04eccd34e13e5b182dd660e603f85d4; the summary is in this lane's pull request comment.

claude-lane: claude-review

kyle-sexton and others added 3 commits November 19, 2026 10:46
…re the person leaves

Replace the leading /session-flow:step-away first prompt with the owner's
choice (a) on #17386: continue-in-background keeps the plain /goal payload
and hands back the full sessionId it reads from claude agents --json, and
step-away runs away.py start for that id from the attended session.

A live probe (Claude Code 2.1.328) shows the first Stop read the state
about 6 s after start; the window and its handling are recorded in
goal-probe.md. away.py refresh now finds an unrecorded transcript by
session id, since the background session's Stop hook did not record it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the measured seconds from step-away's launch message, label the
goal-keeps-it-working sentence as reasoning, and give the missing
ignored .work/ path a fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton kyle-sexton changed the title feat(session-flow): hand off a fresh session already armed for step-away feat(session-flow): arm a fresh background session for step-away before the person leaves Nov 19, 2026
@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 19, 2026

@github-actions github-actions 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.

claude-review: 1 inline finding(s) on 091e7bd50728881be9080604638ef8f2f2a7cde8; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions github-actions Bot removed the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 19, 2026
… report path

No hook tells a background session armed after its launch where the away
rules or the report are: its only prompt runs before `start`, and the Stop
hook names the rules only when it blocks. The task file now opens with a
header line naming the rules file by absolute path and, once `start` has
printed it, the report path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgaikHToyUB6YgDyVGn
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 900ffe9 Nov 19, 2026
49 checks passed
@kyle-sexton
kyle-sexton deleted the feat/17386-armed-background-handoff branch November 19, 2026 17:16
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session-flow: let continue-in-background take a leading slash command so a background session starts armed

1 participant