Skip to content

Test: volitional-compaction provider/model threading + counter truthfulness (regression cover for #639 arc) #209

@ronan-dandelion-cult

Description

@ronan-dandelion-cult

Summary

The headline openclaw#639 ship-gate fix (threading session provider/model/authProfileId through volitional compaction, honoring the real compaction result instead of lying {ok:true}) has no behavioral test. The classifier test (src/agents/pi-embedded-runner/compact-reasons.test.ts:41-47) pins the string match for unknown_model but doesn't assert the call-site threading or counter-truth that the ship-gate was actually about.

Shipping the fix without a regression-pinning test means the next provider/model rename or fallback-dispatcher refactor can silently reintroduce the original bug.

What needs pinning

  1. Provider/model reach the compaction call: both request_compaction call sites (agent-runner-execution.ts:1008-1036 and followup-runner.ts:271-312) pass the session's provider, model, authProfileId to compactEmbeddedPiSession — NOT the hardcoded defaults.

  2. authProfileId fallback-drop: when the compaction runs on the fallback provider (different from persisted primary), authProfileId is dropped (set to undefined).

  3. Counter truthfulness: getVolitionalCompactionCount increments on {ok:true, compacted:true}, does NOT increment on {ok:true, compacted:false, reason:"below_threshold"} (legit skip), does NOT increment on {ok:false, reason:"unknown_model"} (real failure).

  4. Log level per outcome: legit-skip → log.info [system:request_compaction:resolved-skip]; real failure → log.warn [system:request_compaction:resolved-failure].

Approach

Add a new test file src/agents/tools/request-compaction-tool.volitional-threading.test.ts (or extend the existing request-compaction-tool.test.ts) with:

  • Stub compactEmbeddedPiSession via the triggerCompaction closure injected by the callers.
  • Feed three outcomes: {ok:true,compacted:true}, {ok:true,compacted:false,reason:"nothing to compact"}, {ok:false,reason:"unknown model foo"}.
  • Assert counter delta + log call args for each.

Separately, add a call-site test (in followup-runner.test.ts and/or a new agent-runner-execution.*.test.ts) that verifies triggerCompaction receives a closure that calls compactEmbeddedPiSession with the expected provider/model/authProfileId shape.

Acceptance Criteria

  • Test asserts counter does NOT increment on legit-skip reasons (match isLegitSkipReason exactly)
  • Test asserts counter does NOT increment on unknown_model / provider_error_* / freeform failure reasons
  • Test asserts counter DOES increment on {ok:true,compacted:true}
  • Test asserts log level is info for legit-skip and warn for real failure
  • Call-site test covers provider/model/authProfileId threading at both agent-runner-execution.ts and followup-runner.ts triggerCompaction construction
  • Test covers the authProfileId fallback-drop (inner-provider ≠ persisted-primary → authProfileId: undefined)

Context

pr-test-analyzer C1. Direct protection for the openclaw#639 fix arc.

Metadata

Metadata

Labels

P1Priority 1 - blockingcontinuationContinuation featurereview-findingFrom PR review feedback

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions