Skip to content

fix: per-turn reinforcement in UserPromptSubmit hook#119

Merged
JuliusBrussee merged 2 commits intoJuliusBrussee:mainfrom
hummat:fix/per-turn-reinforcement
Apr 15, 2026
Merged

fix: per-turn reinforcement in UserPromptSubmit hook#119
JuliusBrussee merged 2 commits intoJuliusBrussee:mainfrom
hummat:fix/per-turn-reinforcement

Conversation

@hummat
Copy link
Copy Markdown
Contributor

@hummat hummat commented Apr 12, 2026

The problem

Caveman's SessionStart hook injects the full ruleset once per session. This works great in isolation, but falls apart when other plugins inject competing style instructions on every turn.

I run caveman alongside an output-style plugin (explanatory mode). That plugin emits a style reminder via <system-reminder> on every user message. Caveman's one-shot injection from SessionStart quietly loses the priority fight — the model sees "be educational and verbose" on every turn but only saw "drop articles, fragments OK" once at the start. As it turns out, recency and repetition win in LLM attention. Caveman was active but the model wrote full verbose prose anyway.

The fix

The mode-tracker hook already fires on every UserPromptSubmit — it just didn't emit anything. This adds a short structured reminder (via hookSpecificOutput) when the flag file exists. The full rules from SessionStart stay in context; this simply keeps them visible in the model's attention window.

The reminder uses the same hookSpecificOutput.additionalContext JSON format that Claude Code expects from hooks — no raw stdout.

What changes

hooks/caveman-mode-tracker.js: after processing mode changes and deactivation, checks if the flag file exists and emits a one-line reinforcement. Silent-fails on all filesystem errors, same as existing code.

Testing

Ran with an active output-style plugin that previously caused caveman to be ignored. With the reinforcement, caveman style persists across turns.

The SessionStart hook injects caveman rules once, but models lose them
when other plugins (output styles, learning modes) inject competing
style instructions on every turn. Recency and repetition win in LLM
attention — a one-shot injection loses to per-turn reinforcement.

Emit a short structured reminder via hookSpecificOutput on every user
message when caveman is active. Uses the same JSON format Claude Code
expects from hooks, keeping the full ruleset from SessionStart in
context while this reminder keeps it top-of-mind.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ed7b732b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hooks/caveman-mode-tracker.js Outdated
Comment on lines +65 to +67
additionalContext: "CAVEMAN MODE ACTIVE (" + activeMode + "). " +
"Drop articles/filler/pleasantries/hedging. Fragments OK. " +
"Code/commits/security: write normal."
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid full-mode reinforcement for commit/review modes

This reminder text is emitted for every active mode, including commit, review, and compress, but the injected guidance is the base caveman rule set (Drop articles... and Code/commits/security: write normal.). After users switch to /caveman-commit or /caveman-review, each turn now gets instructions that conflict with those specialized modes, so outputs can regress to normal prose instead of the expected commit/review behavior. Restrict this reinforcement to base intensity modes (full/lite/ultra/wenyan*) or emit mode-specific context for independent modes.

Useful? React with 👍 / 👎.

Independent modes have their own skill behavior — emitting base caveman
rules ("Drop articles, fragments OK") on every turn conflicts with the
specialized format those modes expect.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JuliusBrussee JuliusBrussee merged commit e50325b into JuliusBrussee:main Apr 15, 2026
@JuliusBrussee JuliusBrussee mentioned this pull request Apr 15, 2026
3 tasks
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.

2 participants