Skip to content

Make the finish_session mandate the last thing a non-interactive agent reads - #211

Merged
artempartos merged 1 commit into
developfrom
fix/finish-session-critical-context
Sep 5, 2026
Merged

artempartos merged 1 commit into
developfrom
fix/finish-session-critical-context

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Non-interactive agents keep skipping the call that ends their session.

The mandate was already in the context — as a subsection buried inside <critical-rules> at the very top, ahead of thousands of tokens of workspace, board, tool and skill context. What actually rendered last were the reference listings: shell tools and MCP servers.

What changed

  • New ContextBuilders::SessionCompletion (non-interactive only) owns the mandate as its own <session-completion> section.
  • New :footer position on ContextSection, sorting below even the bottom-of-context listings — so the mandate is the last thing in the prompt.
  • The wording states the cost, not just the instruction: the container keeps burning budget until the sweeper reaps it, the workflow step waiting on the session stalls for that whole time, and the work lands as a stale failure instead of as the result it was. Partial work is spelled out as a fail_session.
  • The top block is now a short pointer to that section (primacy kept, detail moved).
  • The renderer's sort is now stable. sort_by is not, so two sections with the same (position, priority) rendered in an arbitrary order — exactly the property this change depends on. Ties now break by builder order.

OutputRules keeps its one-line reminder: three mentions of the same rule is deliberate here, not drift.

Checks

docker compose exec -T web make check_all — green.

🤖 Generated with Claude Code

…an agent reads

Non-interactive agents were skipping the call that ends their session. The
mandate was there, but as a subsection buried inside <critical-rules> at the
very top of a context that then runs for thousands of tokens — and the sections
that DID render last were the reference listings of shell tools and MCP servers.

It now has its own builder and its own section, and the section carries a new
:footer position that sorts below even the bottom-of-context listings, so it is
the last thing in the prompt. The wording states the cost rather than only the
instruction: the container keeps burning budget until the sweeper reaps it, the
workflow step waiting on the session stalls for that whole time, and the work is
recorded as a stale failure. The block at the top is now a short pointer to it.

The renderer's sort was not stable, so two sections with the same (position,
priority) rendered in an arbitrary order — which is precisely the property this
change depends on. It now breaks ties by builder order.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit ad79fb1 into develop Sep 5, 2026
7 checks passed
aixle-com Bot pushed a commit that referenced this pull request Nov 8, 2026
aixle-com Bot pushed a commit that referenced this pull request Nov 8, 2026
aixle-com Bot pushed a commit that referenced this pull request Nov 8, 2026
…nd the session's locks, heal counters under the lock, a real-shell snapshot test (task #211, CR round 1)

- Sessions::AuthPause#pause! and #unpause! lock the workflow run, then the
  session, and change the marker and the run's state in one transaction.
  A delivery can no longer land between the marker and the run's pause,
  and two sessions of one run unpaused at once resume it.
- #resume! returns the unpause's result and logs only what happened. The
  resume prompt is still typed before the compare-and-set.
- #heal! counts its attempt under the session's row lock, re-reading the
  counter and, from the pass, heal_due? there.
- A test runs Snapshot::Command#argv through /bin/sh with stub tmux and stat.

Signed-off-by: Aixle Flow <[email protected]>
aixle-com Bot pushed a commit that referenced this pull request Nov 8, 2026
…es (task #211, CR round 1)

Checks::NoOutput#message redacts the whole screen with
Sessions::SecretRedactor.for_session before AuthErrorDetector reads it,
as LiveLogReader#tail did. Checks::Base#fail_session redacts the final
message too, which also covers the quota, blocking-prompt and turn-end
messages.

Signed-off-by: Aixle Flow <[email protected]>
aixle-com Bot pushed a commit that referenced this pull request Nov 9, 2026
… and turn-end confirmation, a threaded unpause test (task #211, CR round 2)

- Sessions::AuthPause#pause! redacts the banner before storing auth_pause_reason.
- #expire! and #unpause_quietly take the auth_paused_at the pass observed and act only
  if the locked row still holds it; #expire! computes the expiry from the locked row.
- Checks::TurnEnd#give_up requires turn_end_screen and turn_end_seen_at to match the
  confirmation it acts on, under the lock.
- The two-sessions-of-one-run unpause test moves to auth_pause_concurrency_test.rb,
  on two threads with their own connections.

Signed-off-by: Aixle Flow <[email protected]>
aixle-com Bot pushed a commit that referenced this pull request Nov 9, 2026
…he concurrency test's sessions have a prompt (task #211, CR round 2)

Signed-off-by: Aixle Flow <[email protected]>
NOX73 added a commit that referenced this pull request Nov 9, 2026
…ks for the quota scan's checks (task #211, step 1) (#671)

* feat(sessions): one snapshot per session per pass, and Sessions::Checks for the quota scan's checks (task #211, step 1)

Signed-off-by: Aixle Flow <[email protected]>

* docs(sessions): the session monitor, its parts registry, the checks and their kept state (task #211)

Signed-off-by: Aixle Flow <[email protected]>

* fix(sessions): pause and unpause in one transaction under the run's and the session's locks, heal counters under the lock, a real-shell snapshot test (task #211, CR round 1)

- Sessions::AuthPause#pause! and #unpause! lock the workflow run, then the
  session, and change the marker and the run's state in one transaction.
  A delivery can no longer land between the marker and the run's pause,
  and two sessions of one run unpaused at once resume it.
- #resume! returns the unpause's result and logs only what happened. The
  resume prompt is still typed before the compare-and-set.
- #heal! counts its attempt under the session's row lock, re-reading the
  counter and, from the pass, heal_due? there.
- A test runs Snapshot::Command#argv through /bin/sh with stub tmux and stat.

Signed-off-by: Aixle Flow <[email protected]>

* fix(sessions): redact the auth banner, act only on the observed pause and turn-end confirmation, a threaded unpause test (task #211, CR round 2)

- Sessions::AuthPause#pause! redacts the banner before storing auth_pause_reason.
- #expire! and #unpause_quietly take the auth_paused_at the pass observed and act only
  if the locked row still holds it; #expire! computes the expiry from the locked row.
- Checks::TurnEnd#give_up requires turn_end_screen and turn_end_seen_at to match the
  confirmation it acts on, under the lock.
- The two-sessions-of-one-run unpause test moves to auth_pause_concurrency_test.rb,
  on two threads with their own connections.

Signed-off-by: Aixle Flow <[email protected]>

* test(sessions): the redaction case attaches its secret to the step, the concurrency test's sessions have a prompt (task #211, CR round 2)

Signed-off-by: Aixle Flow <[email protected]>

---------

Signed-off-by: Aixle Flow <[email protected]>
Co-authored-by: Aixle Flow <[email protected]>
aixle-com Bot pushed a commit that referenced this pull request Nov 9, 2026
…demand snapshot for the token-refresh sweep (task #211, step 2) (#672)
aixle-com Bot pushed a commit that referenced this pull request Nov 10, 2026
Conflicts resolved:
- Files touched on staging only by the pre-squash branches of task #209 (PR #669)
  and task #211 (PRs #667/#668) take develop's version, which carries the
  reviewed, merged form of the same work (#670, #671, #672).
- test/integration/web/company/billing_test.rb: keeps the billing redesign's
  (#646) test body with develop's 14-day trial values (#678).
- CHANGELOG.md: develop's 1.11.0 entry for the 14-day trial; the billing
  redesign entry already present above is kept once.

Signed-off-by: Alex <[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.

1 participant