Spaces:
Running
Running
sync: 190 file da Baida98/AI@0e85d915 (2026-08-26 09:54 UTC) [deploy-all]
#73
by Baida07 - opened
agents/unified_loop_tools.py
CHANGED
|
@@ -68,10 +68,15 @@ class DirectToolsMixin:
|
|
| 68 |
r"crypto|bitcoin|ethereum|market\s+cap|capitalizzazione)\b",
|
| 69 |
re.IGNORECASE,
|
| 70 |
)
|
|
|
|
|
|
|
|
|
|
| 71 |
_IMAGE_INTENT_RE = re.compile(
|
| 72 |
-
r"\b(genera|crea|
|
| 73 |
-
r"immagine|foto|illustrazione|ritratto|paesaggio|logo|icona|disegno|grafica|"
|
| 74 |
-
r"image|photo|illustration|portrait|landscape|drawing|graphic|art|artwork)\b"
|
|
|
|
|
|
|
| 75 |
re.IGNORECASE,
|
| 76 |
)
|
| 77 |
_CALC_INTENT_RE = re.compile(
|
|
|
|
| 68 |
r"crypto|bitcoin|ethereum|market\s+cap|capitalizzazione)\b",
|
| 69 |
re.IGNORECASE,
|
| 70 |
)
|
| 71 |
+
# Un verbo generico come «crea» non autorizza un artefatto visivo: richiedi
|
| 72 |
+
# un output immagine esplicito, oppure un verbo artistico inequivoco. Questo
|
| 73 |
+
# evita che «Crea un piano…» diventi una generazione Pollinations/VFS.
|
| 74 |
_IMAGE_INTENT_RE = re.compile(
|
| 75 |
+
r"(?:\b(?:genera|crea|fai|mostra|visualizza|produce|generate|create|make)\b.{0,40}\b"
|
| 76 |
+
r"(?:immagine|foto|illustrazione|ritratto|paesaggio|logo|icona|disegno|grafica|"
|
| 77 |
+
r"image|photo|picture|illustration|portrait|landscape|drawing|graphic|art|artwork)\b)"
|
| 78 |
+
r"|(?:^\s*(?:disegna|illustra|dipingi|render|paint|sketch)\b"
|
| 79 |
+
r"(?!\s+(?:(?:un|una|il|lo|la|the|a|an)\s+)?(?:diagramma|grafico|chart|schema|ui|ux|figma)\b))",
|
| 80 |
re.IGNORECASE,
|
| 81 |
)
|
| 82 |
_CALC_INTENT_RE = re.compile(
|
tests/test_direct_file_conversion.py
CHANGED
|
@@ -106,6 +106,33 @@ Non usare rete, shell, servizi esterni o provider aggiuntivi."""
|
|
| 106 |
}
|
| 107 |
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
def test_direct_image_returns_renderable_terminal_markdown_without_llm():
|
| 110 |
writes = {}
|
| 111 |
_install_tool_stubs(writes)
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
|
| 109 |
+
def test_textual_checkout_plan_does_not_trigger_direct_image_generation():
|
| 110 |
+
writes = {}
|
| 111 |
+
_install_tool_stubs(writes)
|
| 112 |
+
from agents.unified_loop_tools import DirectToolsMixin
|
| 113 |
+
|
| 114 |
+
class Harness(DirectToolsMixin):
|
| 115 |
+
def _max_tokens_for_goal(self, _goal):
|
| 116 |
+
return 4096
|
| 117 |
+
|
| 118 |
+
events = []
|
| 119 |
+
|
| 120 |
+
async def on_step(event):
|
| 121 |
+
events.append(event)
|
| 122 |
+
|
| 123 |
+
output, called, succeeded, errors = asyncio.run(
|
| 124 |
+
Harness()._run_direct_tools(
|
| 125 |
+
"Crea un breve piano per verificare un errore intermittente nel checkout e indica il primo dato da raccogliere.",
|
| 126 |
+
on_step=on_step,
|
| 127 |
+
)
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
assert "E2E_IMAGE_OK" not in output
|
| 131 |
+
assert not any(event.get("action") == "file_written" for event in events)
|
| 132 |
+
assert not any(path.startswith("generated-image-") for path in writes)
|
| 133 |
+
assert (called, succeeded, errors) == (0, 0, 0)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
def test_direct_image_returns_renderable_terminal_markdown_without_llm():
|
| 137 |
writes = {}
|
| 138 |
_install_tool_stubs(writes)
|