Skip to content

fix(run-tend): say that ending the turn, not backgrounding, loses unfinished work - #1676

Merged
max-sixty merged 5 commits into
mainfrom
fix/issue-1675
Nov 27, 2026
Merged

max-sixty merged 5 commits into
mainfrom
fix/issue-1675

Conversation

@tend-agent

@tend-agent tend-agent commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

run-tend's Complete the task before ending the turn described the risk as returning the final response while a background command runs, and its corollary said "don't background anything whose output gates the deliverable." That framing missed the failure in #1675. In max-sixty/leaf's weekly run, the parent's three Agent calls set no run_in_background, and the harness ran them asynchronously anyway. The parent said it would wait for them, ended its turn, and the headless session exited with the subagents' work undelivered. The rule forbade a choice the session never made, and its last turn didn't look like "returning the final response."

This PR rewords the existing rule so it names the act itself, and adds no harness mechanics:

  • The paragraph now says ending your turn can end the session, and that work the deliverable needs, if still running, finishes invisibly or is killed.
  • The corollary becomes "don't end your turn while anything the deliverable needs is still running."
  • review-runs' references/parallel-maintenance.md says the parent "does not end its turn until its subagents have returned," replacing "waits for its subagents," which the leaf parent satisfied as written.

This is an instruction-only change. Pre-commit hooks and the skill tests pass. No model replay compared the two wordings.

Closes #1675 — automated triage

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

One wording fix inline: the subagent paragraph gives a mechanism the cited evidence does not support.

169c20d dropped this clause as unobserved, but the third occurrence on #1675
(max-sixty/worktrunk run 45006859472) shows it: a task-notification enqueued
at 09:28:12Z after the parent's final turn was removed as absorbed_mid_turn at
09:31:45Z with no further assistant turn.
@tend-agent

Copy link
Copy Markdown
Collaborator Author

I restored the clause that 169c20d removed, as be8e661. The text is now the same as 65110df again.

The review that removed it said a dropped notification "isn't what #1675 observed". It read only the issue body, which covers the first two occurrences. The third occurrence, posted on #1675 two minutes before that review started, does show the mechanism. In max-sixty/worktrunk's session log for run 45006859472, the parent's last assistant turn is at 09:24:12Z. A <task-notification> was enqueued at 09:28:12Z and removed at 09:31:45Z with reason: "absorbed_mid_turn", and no assistant turn followed it. Earlier absorbed_mid_turn entries in the same log fell inside active turns, which carried on with the next user message, so this last one is the one that matters. So the paragraph's two reasons are both observed: a notification that never wakes the parent, and a subagent killed when the session exits.

@max-sixty

Copy link
Copy Markdown
Owner

@tend-agent the maintainer would rather not add harness mechanics to run-tend (run_in_background, concurrent calls, absorbed notifications), since they go stale as harnesses change. Please replace this PR's two additions with a rewording of the existing turn-end rule, so the rule stops being confusing rather than gaining a paragraph (… marks text that stays as it is):

--- a/plugins/tend-ci-runner/skills/run-tend/SKILL.md
+++ b/plugins/tend-ci-runner/skills/run-tend/SKILL.md
-Returning the final response ends the CI session — the runner is discarded, and the harness does not reliably resume it when a background task completes. If you return while a background command whose result was going to gate the deliverable is still running, the task either finishes invisibly or gets killed when the runner is torn down, and any staged work …
+Ending your turn can end the CI session — the runner is discarded, and the harness does not reliably resume it when background work completes. If you end it while work the deliverable needs is still running, that work either finishes invisibly or gets killed when the runner is torn down, and any staged work …
-Corollary: don't background anything whose output gates the deliverable. If a full test suite …
+Corollary: don't end your turn while anything the deliverable needs is still running. If a full test suite …
--- a/plugins/tend-ci-runner/skills/review-runs/references/parallel-maintenance.md
+++ b/plugins/tend-ci-runner/skills/review-runs/references/parallel-maintenance.md
-current ownership before outward actions, and waits for its subagents before
-reporting the sweep's outcome.
+current ownership before outward actions, and does not end its turn until its
+subagents have returned.

Why this wording: in leaf's weekly run 42779124311 the parent never asked for background work. Its three Agent calls set no run_in_background, and Claude Code ran them asynchronously anyway. So "don't background anything" forbade a choice it never made, and "returning the final response" and "a background command" didn't describe its last turn, "I'll wait for the tasks to finish before writing the summary." That turn also satisfied "waits for its subagents" as written. The reworded rule names the act itself: ending the turn while the deliverable's work is still running. Worktrunk's weekly run 45006859472 shows the same pattern.

Retitle the PR to match, and if you can, check the wording by replaying the leaf parent's last request under each version and counting turns that end with agents still running.

This was written by Claude Code on behalf of max-sixty

…ed work

Replace the subagent paragraph and the parallel-maintenance pointer with a
rewording of the existing turn-end rule, which now names ending the turn
while the deliverable's work is still running.
@tend-agent tend-agent changed the title fix(run-tend): run subagents that gate the deliverable in the foreground fix(run-tend): say that ending the turn, not backgrounding, loses unfinished work Nov 27, 2026
@tend-agent

Copy link
Copy Markdown
Collaborator Author

I applied the rewording as 9f07f4e. The subagent paragraph and the parallel-maintenance.md pointer are gone. The turn-end paragraph, its corollary, and the parallel-maintenance sentence now read exactly as in your diff. I also retitled the PR and rewrote its description to match.

I didn't run the replay. The eval suite here runs Codex from a local subscription login, which this sandbox doesn't have. Replaying the leaf parent's last request under Claude would mean resuming its transcript with the skill text swapped in, and nothing here supports that, so the two wordings haven't been compared on that turn.

@max-sixty
max-sixty merged commit 08a2162 into main Nov 27, 2026
12 checks passed
@max-sixty
max-sixty deleted the fix/issue-1675 branch November 27, 2026 07:04
max-sixty added a commit that referenced this pull request Nov 27, 2026
… harness meets them (#1751)

Follows #1676: tend's instructions should say what a session must
achieve and leave out how a harness gets it there, since harness
mechanics go stale between releases. This removes six passages that
describe harness mechanics, and adds the rule that keeps new ones out.

- **The `.claude/skills/` write workaround** in propose-instructions and
review-runs (read-only mount, harness write-guard, write to `$TMPDIR`
then `mv`) no longer holds. anthropics/claude-code#37157 was fixed in
2.1.126 and tend pins 2.1.330. A probe on 2.1.332 wrote into
`.claude/skills/` with no denial, and the mount went with the sandbox
runtime in #1354. If that probe misled us, the edit fails visibly.
Tend's own running-tend overlay loses its pointer to the workaround too.
- **ground-claims' 32 KB threshold** was measured on Claude only. The
rule to project narrowly stays.
- **run-tend's "the harness does not load them…" clause** explains a
rule that stays.
- **Three asides** that the tools' own descriptions already carry.

propose-instructions' "What the text carries" gains the rule.
AGENTS.md's "Mechanics ship freely" narrows to match: it is the clause
that let #1676's first draft through.

Kept: Codex's `yield_time_ms` waits (#1448, #1641), reading skills in
full with `cat` (#551), absolute paths for file-writing tools, and the
command timeouts.

pre-commit passes locally; CI runs the suite.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty pushed a commit that referenced this pull request Nov 28, 2026
…sher, and backgrounding (#1755)

Fixes three comments and skill lines that describe mechanisms which have
since been retired. Nothing they render or run changes: the two
`macros.yaml.j2` edits are inside Jinja comments, and the generator
regtests pass unchanged.

- `generator/src/tend/templates/macros.yaml.j2`: `block_input` said it
rendered "`prompt`, and the three `sandbox_*` levers". `config.py` now
rejects `sandbox_env`, `sandbox_path` and `sandbox_setup`, and the
macro's actual callers are `prompt` and `args`.
- The same file's header named "the weekly workflow" as Codex's refresh
owner. That owner is the generated `tend-codex-auth-refresh` workflow,
or the consumer's own refresher when `codex.auth_refresh: false`.
- `plugins/tend-ci-runner/skills/fix-a-bug/SKILL.md`: **The local bar**
cites **Complete the task before ending the turn** in `run-tend` and
then restated the old form of that rule ("backgrounding a long suite
before push risks ending the session"). #1676 rewrote that
section to say that ending the turn, not backgrounding, is what loses
the work. The clause is dropped, so the citation carries the rule.

No regression test, since these are documentation-only changes.

Co-authored-by: tend-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run-tend: a background Agent subagent outlasting ~10 min is killed after the parent ends its turn

2 participants