Skip to content

Add AUTO mode gates for prompt repetition (PR2)#572

Open
qicesun wants to merge 7 commits intolangchain4j:mainfrom
qicesun:feat/prompt-repetition-pr2-auto
Open

Add AUTO mode gates for prompt repetition (PR2)#572
qicesun wants to merge 7 commits intolangchain4j:mainfrom
qicesun:feat/prompt-repetition-pr2-auto

Conversation

@qicesun
Copy link
Contributor

@qicesun qicesun commented Feb 15, 2026

What

  • Add PromptRepetitionMode.AUTO
  • Add maxChars gate
  • Add reasoningKeywords gate
  • Add builder config for PromptRepetitionPolicy
  • Keep idempotence robust for separator-heavy inputs

Behavior

  • AUTO: skip too long and reasoning-intent prompts
  • ALWAYS: still repeats unless already repeated
  • Input guardrail still skips RAG-augmented input by default

Tests

  • Positive/negative/edge/corner coverage for all AUTO gates
  • Gate order checks (ALREADY_REPEATED before other AUTO gates)
  • Case-insensitive keyword detection and maxChars boundary checks
  • Randomized idempotence stress checks
  • ./mvnw -pl langchain4j-community-core verify -DskipITs

Depends on #571
Related #570

@qicesun qicesun changed the title [Draft] Prompt repetition PR2: AUTO mode stop-loss gates Add AUTO mode gates for prompt repetition (PR2) Feb 16, 2026
@qicesun qicesun marked this pull request as ready for review February 16, 2026 07:47
@Martin7-1 Martin7-1 added enhancement New feature or request P2 High priority P3 Medium priority labels Feb 20, 2026
@qicesun
Copy link
Contributor Author

qicesun commented Mar 7, 2026

Quick update: I opened #592 as the new draft PR that carries prompt repetition forward in the dedicated langchain4j-community-prompt-repetition module requested during review.

I also found an upstream langchain4j bug in AiServices input-guardrail sequencing:

Because of that, #592 is now the main review target and this PR is effectively superseded by the dedicated-module draft plus the upstream fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request P2 High priority P3 Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants