Skip to content

fix(force-model): skip leading injected tag blocks before leading-line guard#238

Merged
steventohme merged 1 commit into
mainfrom
steven/force-model-skip-system-reminder
May 23, 2026
Merged

fix(force-model): skip leading injected tag blocks before leading-line guard#238
steventohme merged 1 commit into
mainfrom
steven/force-model-skip-system-reminder

Conversation

@steventohme
Copy link
Copy Markdown
Collaborator

Summary

/force-model and /unforce-model silently no-op'd in prod (reason=no_pin on every request) because Claude Code prepends <system-reminder>, <command-name>, <local-command-stdout>, etc. ahead of the user's typed text on every turn. The parser's leading-non-empty-line guard saw the injected tag instead of the command and bailed; the pin was never written, cluster routing picked the default, sticky affinity latched the session onto whatever the scorer chose.

leadingInjectedPrefixEnd skips complete <tag>...</tag> blocks at the head of the message before applying the leading-line check. Strict tag-name matching (identifier only — letters, digits, -, _, no attributes) preserves the original paste-safety guard: arbitrary HTML/XML, unclosed tags, and attribute-bearing tags still terminate the prefix scan, so a stray /force-model buried in pasted content is still ignored.

Skipped blocks are preserved in the stripped body so downstream prompt context (system-reminders, command metadata) reaches the upstream intact.

Test plan

  • go test ./internal/translate/... ./internal/proxy/... — all green
  • New cases in force_model_test.go:
    • leading <system-reminder> before command
    • multiple stacked tag blocks
    • multi-line tag body
    • unclosed tag does NOT unlock the guard
    • tag with attributes does NOT unlock the guard

…e guard

Claude Code prepends <system-reminder>, <command-name>, etc. ahead of the
user's typed text on every turn, which buried /force-model past the first
non-empty line and caused parseForceModelCommand to bail. The pin was never
written, cluster routing picked the default, and sticky session affinity
latched onto whatever the scorer chose — observed in prod as /force-model
silently no-op'ing with reason=no_pin.

leadingInjectedPrefixEnd skips complete <tag>...</tag> blocks at the head
of the message before applying the leading-line check. Strict tag-name
matching (identifier only, no attributes) preserves the original paste-
safety guard: arbitrary HTML/XML, unclosed tags, and attribute-bearing
tags still terminate the prefix scan.
@steventohme steventohme merged commit 372f1ea into main May 23, 2026
7 checks passed
@steventohme steventohme deleted the steven/force-model-skip-system-reminder branch May 23, 2026 05:40
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