Fix battleship AI hallucination bug with skip_condition system

Add skip_condition logic to feedback prompts to prevent AI from generating
false ship destruction messages when no ships were actually destroyed.

Changes:
- Add skip_condition parameter support in provide_feedback_prompts()
- Support all_null, all_false, and all_true condition types
- Apply skip_condition to battleship Ship Status and Game Over prompts
- Add comprehensive unit tests covering all skip condition scenarios
- Test real battleship scenario that was causing hallucinations

This prevents the AI from creating false positive ship destruction messages
when metadata indicates no ships were actually sunk (all null values).
This commit is contained in:
Russell Ballestrini 2025-08-11 17:04:17 -04:00
parent 060a91d2e1
commit fca7addaa5
4 changed files with 325 additions and 0 deletions

View file

@ -230,6 +230,7 @@ sections:
metadata_filter:
- user_sunk_ship_this_round
- ai_sunk_ship_this_round
skip_condition: "all_null"
- name: "Game Over"
tokens_for_ai: |
@ -245,6 +246,7 @@ sections:
- game_over
- user_wins
- ai_wins
skip_condition: "all_false"
processing_script: |
import random

View file

@ -208,6 +208,7 @@ sections:
metadata_filter:
- user_sunk_ship_this_round
- ai_sunk_ship_this_round
skip_condition: "all_null"
- name: "Game Over"
tokens_for_ai: |
@ -223,6 +224,7 @@ sections:
- game_over
- user_wins
- ai_wins
skip_condition: "all_false"
processing_script: |
import random