Skip to content

feat(continuation): instrument context-pressure precondition skip (refs #580)#164

Merged
ronan-dandelion-cult merged 1 commit into
flesh_beast_figs/20260414-claudefrom
instrumentation/context-pressure-precondition-log
Apr 18, 2026
Merged

feat(continuation): instrument context-pressure precondition skip (refs #580)#164
ronan-dandelion-cult merged 1 commit into
flesh_beast_figs/20260414-claudefrom
instrumentation/context-pressure-precondition-log

Conversation

@ronan-dandelion-cult

Copy link
Copy Markdown

Summary

Adds a single `[context-pressure:skip] reason=<...>` DEBUG log line at `src/auto-reply/reply/agent-runner.ts:~1193`, emitted whenever the pressure-check guard short-circuits. Tiny (12 lines added).

Why

`openclaw-bootstrap#580` has three princes reporting zero band≥1 fires of `[context-pressure:fire]` across the fleet. Tonight's investigation refuted the initial hypothesis (bundler realm-split) via structural inspection of `dist/context-pressure-*.js` post-PR #162:

The real candidate root cause is the guard at `agent-runner.ts:1193`: when `activeSessionEntry.totalTokens` or the resolved `pressureContextWindow` is unpopulated for the turn, the entire pressure check is skipped silently. That's indistinguishable from "threshold never crossed" in the current logs, and it's a sticky investigation trap.

RFC §4.2 now documents the precondition (doc-only in #163). This PR adds the matching runtime observability so the next #580 investigation can distinguish:

  • `no-threshold-configured` — `contextPressureThreshold` not set in config
  • `totalTokens-not-populated` — session accounting hasn't landed yet
  • `contextWindow-unresolved` — neither `agentCfgContextTokens`, `activeSessionEntry.contextTokens`, nor `DEFAULT_CONTEXT_TOKENS` usable

How to use

  1. Bump the `continuation/context-pressure` subsystem to DEBUG on one prince.
  2. Run normal workload for ~30 min.
  3. `grep '\[context-pressure:skip\]'` on the journal / file log.
  4. Tally reasons. That tells continue_delegate silently discards targetSessionKey at runtime spawn-routing (swim-42 OV-1 fire-1) #580 investigation which branch is responsible.

What this does NOT change

  • `[context-pressure:fire]` log anchor (unchanged — RFC §6.1 contract).
  • Band thresholds / dedup / post-compaction semantics.
  • Any runtime behavior at INFO level (DEBUG-only emission).

Test plan

  • `pnpm tsgo` clean.
  • Deploy to ronan, bump pressure-log to DEBUG, run normal workload 30 min, confirm at least one `[context-pressure:skip]` emission with a recognizable `reason=...` value. (Morning task for figs to drive, not tonight.)

References

🤖 Generated with Claude Code

Context: openclaw-bootstrap#580 has three princes (cael/ronan/silas)
reporting no band≥1 fires of the `[context-pressure:fire]` log anchor
fleet-wide. Structural inspection of the bundle artifacts
(`dist/context-pressure-*.js`) post-#162 confirms context-pressure is
not dual-chunked — it was never subject to the realm-split bug that
#584 fixed. The real candidate is the silent guard at
`agent-runner.ts:1193`: when `totalTokens` or the resolved
`contextWindow` are unpopulated for a turn, the entire pressure check
is skipped with no trace. That's indistinguishable from
"threshold-never-crossed" in the current logs.

This commit adds a `[context-pressure:skip] reason=<...>` debug log
on the else-branch of that guard, naming which precondition failed:
  - `no-threshold-configured` — `contextPressureThreshold` unset
  - `totalTokens-not-populated` — session accounting hasn't landed
  - `contextWindow-unresolved` — neither agent nor session defaults

Emits at DEBUG level so it does NOT pollute info-level logs on prod
princes by default. Operators investigating #580 bump the log level
on one box, run a load profile, and get clear evidence for which
branch is firing. Without this change, you can only distinguish the
two hypotheses by reading the code.

RFC §4.2 precondition note already shipped in #163.

Zero runtime behavior change at info level. Zero change to:
- `[context-pressure:fire]` anchor
- band semantics
- dedup rule
- post-compaction unconditional path

Refs: karmaterminal/openclaw-bootstrap#580

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ronan-dandelion-cult
ronan-dandelion-cult force-pushed the instrumentation/context-pressure-precondition-log branch from 6696b10 to 59f2054 Compare April 18, 2026 18:19

@cael-dandelion-cult cael-dandelion-cult 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.

🩸 LGTM. The skip-reason instrumentation is exactly what's needed to distinguish 'threshold-never-crossed' from 'totalTokens-not-populated' from 'contextWindow-unresolved' — debug-level so it's silent in normal operation but surfaces under DEBUG. Lazy-loaded subsystem logger keeps the hot path clean. Ship it.

@ronan-dandelion-cult
ronan-dandelion-cult merged commit 8800648 into flesh_beast_figs/20260414-claude Apr 18, 2026
2 of 9 checks passed
@ronan-dandelion-cult
ronan-dandelion-cult deleted the instrumentation/context-pressure-precondition-log branch April 18, 2026 18:30
ronan-dandelion-cult added a commit that referenced this pull request Apr 18, 2026
…580)

Post-#164 instrumentation should have produced either '[context-pressure:fire]' or
'[context-pressure:skip] reason=...' log lines on every agent turn that
reached the pre-run injection block at agent-runner.ts:1183. Fleet observation
on 9d9b3ba (ronan ~1h, cael ~25m, silas ~15m, all logging.level=debug,
continuation/signal subsystem flowing normally on every turn) shows ZERO of
either anchor across all three princes. That pattern is only explainable if
the outer guard

    if (continuationEnabledForPressure && sessionKey && activeSessionEntry)

isn't being entered at all -- because if it were, either the inner fire-branch
would log ':fire' or the new #164 else-branch would log ':skip' naming the
unmet precondition. Neither happens.

This commit adds a single info-level breadcrumb immediately inside the guard:

    [context-pressure:reach] precondition-check entered session=<key>

Info-level so it survives any future debug-filter regression. Once deployed
fleet-wide, journals will distinguish the two remaining hypotheses from
the #580 finding-comment:

  1. ':reach' never fires -> outer guard is genuinely false on normal turns
     (likely 'activeSessionEntry' is null/undefined post-memory-flush in
     practice, or the path is short-circuited above by an early-return we
     haven't traced yet).
  2. ':reach' fires but no ':fire' or ':skip' follows -> import or inner
     branch is silently failing.

Surgical: 10 lines added, no behavior change, info-level log only. Issue:
karmaterminal/openclaw-bootstrap#580. Successor to #164.
ronan-dandelion-cult added a commit that referenced this pull request Apr 18, 2026
…580) (#171)

Post-#164 instrumentation should have produced either '[context-pressure:fire]' or
'[context-pressure:skip] reason=...' log lines on every agent turn that
reached the pre-run injection block at agent-runner.ts:1183. Fleet observation
on 9d9b3ba (ronan ~1h, cael ~25m, silas ~15m, all logging.level=debug,
continuation/signal subsystem flowing normally on every turn) shows ZERO of
either anchor across all three princes. That pattern is only explainable if
the outer guard

    if (continuationEnabledForPressure && sessionKey && activeSessionEntry)

isn't being entered at all -- because if it were, either the inner fire-branch
would log ':fire' or the new #164 else-branch would log ':skip' naming the
unmet precondition. Neither happens.

This commit adds a single info-level breadcrumb immediately inside the guard:

    [context-pressure:reach] precondition-check entered session=<key>

Info-level so it survives any future debug-filter regression. Once deployed
fleet-wide, journals will distinguish the two remaining hypotheses from
the #580 finding-comment:

  1. ':reach' never fires -> outer guard is genuinely false on normal turns
     (likely 'activeSessionEntry' is null/undefined post-memory-flush in
     practice, or the path is short-circuited above by an early-return we
     haven't traced yet).
  2. ':reach' fires but no ':fire' or ':skip' follows -> import or inner
     branch is silently failing.

Surgical: 10 lines added, no behavior change, info-level log only. Issue:
karmaterminal/openclaw-bootstrap#580. Successor to #164.
ronan-dandelion-cult pushed a commit that referenced this pull request Apr 19, 2026
…tus restoration

Updates RFC docs/design/continue-work-signal-v2.md to reflect the totality of changes since 107ca2b (the prior RFC edit) plus the two ship-gate PRs about to land:

- §4.3: document session provider/model threading through volitional compaction (openclaw#191 / bootstrap#639). Three coupled defects: root cause, caller-honesty (phantom-counter), visibility (`unknown_model` classifier + `isLegitSkipReason` helper + `log.warn` on resolve-with-fallback + scope-aware `authProfileId`).
- §6.1: add `[context-pressure:noop]` log anchor with reason taxonomy (window-zero / below-threshold / band-dedup); document the bootstrap#580 investigation cycle (`:reach`/`:skip` instrumentation, root cause = sentinel collision on band 0, fix = -1 sentinel).
- §6.3: clarify Discord/agent path through src/auto-reply/status.ts was reconnected at openclaw#187 + tested at #188 (the line had been silently dropped in an earlier refactor); note `volitional: N` is honest only after #191.
- §6.4: replace 'instrumentation is not currently in place' note with status of distinguishing-instrumentation work (openclaw#164/171/172/173).
- Appendix C.1: add 'Closed failure modes' table — phantom-counter, hedge-timer ref leak, band-0 dedup, precondition-skip blindness, Copilot summarization headers, dist-bundle satellite chunks, subagent-announce runtime path mismatch.
- Appendix D.2: add evidence-location rows for the new file paths (volitional threading sites; armHedgeTimer; status renderer; request-compaction-tool tests; context-pressure noop sites; agent-runner runtime promotion; subagent-announce co-location; F-NOISE scheduler test).
- Header: bump test count (~180 across 13 files, was '172 across 8') to reflect additions in #165, #170, #188, #193.

Skip-list (no RFC mention): #174 sessions/config raw-key sweep (internal hygiene); #173 Copilot log-enabled nits (micro-hygiene); 86134af removal of investigation breadcrumbs (cycle is folded into §6.1 narrative).

Refs:
  openclaw#191 head fc3f415 (in-flight, MERGEABLE/UNSTABLE, APPROVED)
  openclaw#193 head 14483a6   (in-flight, MERGEABLE/UNSTABLE, APPROVED x2)
  openclaw#187, #188 (merged d787890)
  openclaw#160, #162, #164, #165, #169, #170, #171, #172, #173, #174

🍆 in 🩲: this is a docs PR; if either #191 or #193 changes shape pre-merge the affected paragraph here will need a one-line touch-up.

Co-Authored-By: dandelion cult - ronan 🌊 <[email protected]>
ronan-dandelion-cult pushed a commit that referenced this pull request Apr 19, 2026
… not unrelated

Cael's PR #194 review nit: the breadcrumb work and the dedup-sentinel-collision
fix are causally linked — the noop breadcrumbs (#164, #173) are what made the
silent dedup-suppression visible, which is what enabled #171/#172. Calling it
'unrelated' obscures that chain.

Reword: 'Follow-on work then identified and fixed a second suppression cause
that the new breadcrumbs made visible.'
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.

3 participants