Spaces:
Sleeping
Sleeping
Charles Grandjean commited on
Commit Β·
56aa261
1
Parent(s): de9078a
more logs
Browse files- subagents/doc_editor.py +17 -0
- utils/doc_editor_tools.py +10 -4
subagents/doc_editor.py
CHANGED
|
@@ -322,6 +322,23 @@ class DocumentEditorAgent:
|
|
| 322 |
logger.info(f"π Size change: {size_change:+d} bytes ({size_change/len(doc_text)*100:+.1f}%)")
|
| 323 |
logger.info(f"π¬ Message: {message[:100]}{'...' if len(message) > 100 else ''}")
|
| 324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
if not success:
|
| 326 |
max_iters = final_state.get("max_iterations", 10)
|
| 327 |
if iteration_count >= max_iters:
|
|
|
|
| 322 |
logger.info(f"π Size change: {size_change:+d} bytes ({size_change/len(doc_text)*100:+.1f}%)")
|
| 323 |
logger.info(f"π¬ Message: {message[:100]}{'...' if len(message) > 100 else ''}")
|
| 324 |
|
| 325 |
+
# Log final document content
|
| 326 |
+
logger.info("=" * 80)
|
| 327 |
+
logger.info("π FINAL DOCUMENT CONTENT")
|
| 328 |
+
logger.info("=" * 80)
|
| 329 |
+
if final_doc_size <= 1000:
|
| 330 |
+
# Log full document if small enough
|
| 331 |
+
logger.info(final_state["doc_text"])
|
| 332 |
+
else:
|
| 333 |
+
# Log first 500 and last 500 characters for readability
|
| 334 |
+
doc_content = final_state["doc_text"]
|
| 335 |
+
logger.info(f"[BEGINNING - first 500 chars]")
|
| 336 |
+
logger.info(doc_content[:500])
|
| 337 |
+
logger.info(f"...")
|
| 338 |
+
logger.info(f"[ENDING - last 500 chars]")
|
| 339 |
+
logger.info(doc_content[-500:])
|
| 340 |
+
logger.info("=" * 80)
|
| 341 |
+
|
| 342 |
if not success:
|
| 343 |
max_iters = final_state.get("max_iterations", 10)
|
| 344 |
if iteration_count >= max_iters:
|
utils/doc_editor_tools.py
CHANGED
|
@@ -87,10 +87,11 @@ async def replace_html(doc_text: str, search: str, replace: str, expected_matche
|
|
| 87 |
logger.info(f" π’ Actual matches found: {m}")
|
| 88 |
|
| 89 |
if m != expected_matches:
|
| 90 |
-
|
|
|
|
| 91 |
return {
|
| 92 |
"ok": False,
|
| 93 |
-
"error":
|
| 94 |
"matches": m
|
| 95 |
}
|
| 96 |
|
|
@@ -164,10 +165,15 @@ async def add_html(doc_text: str, anchor_search: str, insert: str,
|
|
| 164 |
logger.info(f" π’ Actual anchor matches found: {m}")
|
| 165 |
|
| 166 |
if m != expected_matches:
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
return {
|
| 169 |
"ok": False,
|
| 170 |
-
"error":
|
| 171 |
"matches": m
|
| 172 |
}
|
| 173 |
|
|
|
|
| 87 |
logger.info(f" π’ Actual matches found: {m}")
|
| 88 |
|
| 89 |
if m != expected_matches:
|
| 90 |
+
error_msg = f"Search pattern not found in document. Searched for: '{search[:100]}{'...' if len(search) > 100 else ''}'. Found {m} occurrences, expected {expected_matches}. The HTML must match exactly (including whitespace and attributes). Please examine the document content and try again with a different search pattern that exists in the document."
|
| 91 |
+
logger.warning(f" β οΈ {error_msg}")
|
| 92 |
return {
|
| 93 |
"ok": False,
|
| 94 |
+
"error": error_msg,
|
| 95 |
"matches": m
|
| 96 |
}
|
| 97 |
|
|
|
|
| 165 |
logger.info(f" π’ Actual anchor matches found: {m}")
|
| 166 |
|
| 167 |
if m != expected_matches:
|
| 168 |
+
error_msg = f"Anchor not found in document. Searched for: '{anchor_search[:100]}{'...' if len(anchor_search) > 100 else ''}'. Found {m} occurrences, expected {expected_matches}. The anchor HTML must match exactly (including whitespace and attributes). Please examine the document content and try again with a different anchor that exists in the document."
|
| 169 |
+
logger.error(f" β ANCHOR NOT FOUND!")
|
| 170 |
+
logger.error(f" π Searched for anchor ({len(anchor_search)} chars):")
|
| 171 |
+
logger.error(f" {anchor_search[:200]}{'...' if len(anchor_search) > 200 else ''}")
|
| 172 |
+
logger.error(f" π’ Found {m} occurrence(s), expected {expected_matches}")
|
| 173 |
+
logger.error(f" π‘ LLM has been notified and will retry with a different anchor")
|
| 174 |
return {
|
| 175 |
"ok": False,
|
| 176 |
+
"error": error_msg,
|
| 177 |
"matches": m
|
| 178 |
}
|
| 179 |
|