fixed documents of all rounds in validator prompt

This commit is contained in:
ValueOn AG 2026-01-11 00:02:24 +01:00
parent d87953ce0a
commit e41411e5aa

View file

@ -779,36 +779,62 @@ class ContentValidator:
actionHistoryContext = f"\n\n=== ACTION HISTORY ===\n" + "\n".join(f"- {entry}" for entry in historyEntries)
actionHistoryContext += "\n\nIMPORTANT: This shows the complete workflow that produced the documents. For process-oriented criteria (e.g., 'internet search performed'), check ACTION HISTORY first. Document metadata may only reflect the LAST action, not the entire workflow."
# Build document index context (all documents delivered in current round)
# Build document index context (all documents delivered in current round AND past rounds)
# CRITICAL: Include past rounds so validator can see files produced in previous rounds
# This prevents endless loops when files are produced in multiple sets across rounds
documentIndexContext = ""
if context and self.services and hasattr(self.services, 'chat') and hasattr(self.services, 'workflow') and self.services.workflow:
try:
documentIndex = self.services.chat.getAvailableDocuments(self.services.workflow)
if documentIndex and documentIndex.strip() and documentIndex != "No documents available":
# Extract only "Current round documents" section if present
# Extract BOTH "Current round documents" AND "Past rounds documents" sections
lines = documentIndex.split('\n')
currentRoundSection = []
pastRoundsSection = []
inCurrentRound = False
inPastRounds = False
for line in lines:
if "Current round documents:" in line:
inCurrentRound = True
inPastRounds = False
currentRoundSection.append(line)
elif "Past rounds documents:" in line:
inCurrentRound = False
inPastRounds = True
pastRoundsSection.append(line)
elif "AVAILABLE_CONNECTIONS_INDEX:" in line:
# End of document sections
break
elif inCurrentRound:
if line.strip().startswith("- docList:") or line.strip().startswith(" - docItem:") or line.strip().startswith("- docItem:"):
currentRoundSection.append(line)
elif line.strip() == "":
# Empty line is okay, continue
continue
elif "Past rounds documents:" in line or "AVAILABLE_CONNECTIONS_INDEX:" in line:
# End of current round section
break
else:
# Still in current round section
currentRoundSection.append(line)
elif inPastRounds:
if line.strip().startswith("- docList:") or line.strip().startswith(" - docItem:") or line.strip().startswith("- docItem:"):
pastRoundsSection.append(line)
elif line.strip() == "":
# Empty line is okay, continue
continue
else:
# Still in past rounds section
pastRoundsSection.append(line)
# Build context with both sections
sections = []
if currentRoundSection:
documentIndexContext = "\n\n=== ALL DOCUMENTS DELIVERED IN CURRENT ROUND ===\n" + "\n".join(currentRoundSection)
documentIndexContext += "\n\nIMPORTANT: This shows ALL documents that have been delivered in the current round, not just the ones being validated in this step. Use this to check if all required formats/documents are present across the entire round."
sections.append("=== ALL DOCUMENTS DELIVERED IN CURRENT ROUND ===\n" + "\n".join(currentRoundSection))
if pastRoundsSection:
sections.append("=== ALL DOCUMENTS DELIVERED IN PAST ROUNDS ===\n" + "\n".join(pastRoundsSection))
if sections:
documentIndexContext = "\n\n" + "\n\n".join(sections)
documentIndexContext += "\n\nIMPORTANT: This shows ALL documents that have been delivered in the current round AND past rounds, not just the ones being validated in this step. Use this to check if all required formats/documents are present across ALL rounds. Files produced in previous rounds (e.g., html+css in round 1, python in round 2) should all be visible here."
except Exception as e:
logger.warning(f"Error extracting document index for validation: {str(e)}")
# Continue without document index - not critical