v5.0.0: SatisfactionCapture drops every bare numeric rating ('9'→never captured) — MIN_PROMPT_LENGTH=3 blocks explicit-rating parser. Fresh-issue follow-up to closed #1091.
Summary
hooks/SatisfactionCapture.hook.ts in v5.0.0 silently drops every bare numeric explicit rating ("1" through "9", and "10"). The file's own header documents Explicit rating (bare "8") → capture directly (line 12), but the implementation never reaches that branch because the MIN_PROMPT_LENGTH = 3 length filter runs before the explicit-rating parser. Net effect: explicit rating capture is functionally dead in v5.
This is the same class of issue as the (closed) v4 bug #1091 ("RatingCapture misinterprets AskUserQuestion menu selections as low ratings") — the v5 fix appears to have over-corrected by raising MIN_PROMPT_LENGTH instead of doing context-aware detection.
Closing comment on #1091 from @danielmiessler:
If the same class of issue reproduces in
SatisfactionCaptureunder v5.0.0, please open a fresh issue against the new release.
Filing as requested.
Reproducer
- Send a single character message:
9(or any 1-9, or10) - Observe
~/.claude/PAI/MEMORY/LEARNING/SIGNALS/ratings.jsonl— no"source":"explicit"entry is written - The hook log shows:
[SatisfactionCapture] Prompt too short, skipping
Code path
hooks/SatisfactionCapture.hook.ts in main branch v5.0.0 release:
// line 70
const MIN_PROMPT_LENGTH = 3;
// line 329 — runs FIRST
if (prompt.length < MIN_PROMPT_LENGTH) {
console.error('[SatisfactionCapture] Prompt too short, skipping');
process.exit(0);
}
// line 335 — explicit rating parser, never reached for bare digits
const explicitResult = parseExplicitRating(prompt);
if (explicitResult) { /* ... write rating ... */ }
For any prompt with length < 3, the function exits before parseExplicitRating runs. parseExplicitRating("9") correctly returns {rating: 9} when tested in isolation, but the filter prevents it from being called.
Verification
I ran parseExplicitRating against every plausible bare rating input. All return correct results when called directly:
| Input | parseExplicitRating | Length filter blocks? |
|---|---|---|
"1" … "9" |
{rating: N} |
YES (length 1) |
"10" |
{rating: 10} |
YES (length 2) |
"9!" |
{rating: 9} |
YES (length 2) |
"nine" |
{rating: 9} |
NO (length 4) |
Bare numbers fail. Word-form ratings still work. The asymmetry confirms the length filter is the root cause.
Proposed fix (context-aware)
Move parseExplicitRating() before the length filter, but gate it on whether the previous assistant turn used AskUserQuestion:
function wasLastTurnAskUserQuestion(transcriptPath: string): boolean {
// Read transcript JSONL backwards, find last assistant turn,
// return true if it contains tool_use with name === 'AskUserQuestion'
// Fail-safe: any error returns false (preserves rating capture)
}
// In main(), after system-text skip:
const explicitResult = parseExplicitRating(prompt);
if (explicitResult) {
if (wasLastTurnAskUserQuestion(data.transcript_path)) {
// It's a menu selection — issue #1091 case
process.exit(0);
}
// Capture rating normally
// ...
process.exit(0);
}
// Length filter still applies to non-rating prompts
if (prompt.length < MIN_PROMPT_LENGTH) process.exit(0);
This:
- Restores bare-number explicit ratings ("9" → captured as rating 9)
- Preserves the v5 protection against AskUserQuestion menu false positives ("2" after a menu → skipped)
- Keeps the length filter useful for the praise/inference paths where short non-rating noise is genuinely noise
Environment
- PAI v5.0.0
- Algorithm v6.3.0
- Claude Code 2.1.118
- macOS Monterey, Bun, fresh v5 install (post-migration from v4.0.3)
Local patch
I've applied this fix locally and documented it as P-002 in my CUSTOM_PATCHES.md. Tested against 4 cases (bare digit captures, AskUserQuestion menu skips, short non-rating skips, praise fast-path). All pass. Happy to send a PR if useful.
This is still open and reproduces on current main (v5.0.0-17-g2fde1bb, fetched 2026-06-11). Independent confirmation of the bug + a tested implementation of the context-aware approach @jacobo-ortiz proposed.
wasLastTurnAskUserQuestion(transcriptPath) reads the transcript JSONL backward, finds the most recent assistant entry, returns true only if its message.content includes a tool_use block whose name === "AskUserQuestion". Fail-safe to false on any read or parse error so the explicit-rating path isn't broken by transcript hiccups.
Gate is applied inside the explicit-rating branch, after parseExplicitRating returns a hit but before writeRating. Diff against the v5.0.0 file:
+function wasLastTurnAskUserQuestion(transcriptPath: string | undefined): boolean {
+ try {
+ if (!transcriptPath || !existsSync(transcriptPath)) return false;
+ const content = readFileSync(transcriptPath, 'utf-8');
+ const lines = content.trim().split('\n');
+ for (let i = lines.length - 1; i >= 0; i--) {
+ const line = lines[i].trim();
+ if (!line) continue;
+ try {
+ const entry = JSON.parse(line);
+ if (entry.type !== 'assistant') continue;
+ const msgContent = entry.message?.content;
+ if (!Array.isArray(msgContent)) return false;
+ return msgContent.some((c: any) => c?.type === 'tool_use' && c?.name === 'AskUserQuestion');
+ } catch { continue; }
+ }
+ return false;
+ } catch { return false; }
+}
@@ main() — after system-text skip @@
- if (prompt.length < MIN_PROMPT_LENGTH) { ... process.exit(0); }
-
// ── FAST PATH: Explicit rating ──
const explicitResult = parseExplicitRating(prompt);
if (explicitResult) {
+ if (wasLastTurnAskUserQuestion(data.transcript_path)) {
+ console.error(`[SatisfactionCapture] Bare number "${prompt.trim()}" follows AskUserQuestion — treating as menu selection, not rating`);
+ process.exit(0);
+ }
console.error(`[SatisfactionCapture] Explicit rating: ${explicitResult.rating}`);
...
process.exit(0);
}
+ // Length guard now gates only the implicit/inference paths
+ if (prompt.length < MIN_PROMPT_LENGTH) { ... process.exit(0); }
Test matrix (all pass on local install):
| Prompt | Transcript last-assistant turn | Behavior | Expected |
|---|---|---|---|
9 |
text only | captured | ✓ |
2 |
AskUserQuestion tool_use |
skipped | ✓ |
7 |
text (AUQ earlier in history) | captured | ✓ |
10 |
no transcript path provided | captured (fail-safe) | ✓ |
Leaving the PR to @jacobo-ortiz since this is his proposed design — happy to share the full file if helpful, but he owns the fix.
Env: PAI v5.0.0, Ubuntu 24.04, Bun, Claude Code 2.1.150.
Great catch, and thank you for the thorough writeup (and for tracing it to MIN_PROMPT_LENGTH). Confirmed exactly as you described: the length check short-circuited before the explicit-rating parser, so a bare 9 was dropped as "too short" and never captured.
Fixed in source — the explicit-rating parse now runs before the length skip, so single-digit ratings are captured. Verified a bare 9 now records an explicit rating instead of being skipped. Ships in the next release (we port fixes into our source tree, which regenerates the public repo). Thank you. 🙏