Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Clarify image upscaling guidance in prompts and tool definitions

Flightdeck Agent34d61d15af1a
diff --git a/backend/agent/tools/definitions.py b/backend/agent/tools/definitions.py
index 57060a19..6f367ef7 100644
--- a/backend/agent/tools/definitions.py
+++ b/backend/agent/tools/definitions.py
@@ -224,9 +224,9 @@ def canonical_tool_definitions(
CanonicalToolDefinition(
name="edit_image",
description=(
- "Edit one or more images using a text prompt. Provide the main "
- "image first, followed by optional reference images. Returns a URL "
- "to the edited image."
+ "Edit or upscale one or more images using a text prompt. Provide the "
+ "main image first, followed by optional reference images. Returns a "
+ "URL to the edited image."
),
parameters=_edit_image_schema(),
)
diff --git a/backend/prompts/create/image.py b/backend/prompts/create/image.py
index c24e121c..bf2949ec 100644
--- a/backend/prompts/create/image.py
+++ b/backend/prompts/create/image.py
@@ -27,7 +27,8 @@ Generate code for a web page that looks exactly like the provided screenshot(s).
- Use the exact text from the screenshot.
- Since our goal is to make the web page look as close to the screenshot as possible, we need to extract the exact image assets where possible and generate images for the assets that are not extractable.
- Extracting assets can be done with the extract_assets tool. After extracting assets, make sure to inspect the extracted image closely to ensure that it is what we want.
-- When available, use the edit_image tool to edit the assets when needed. A good example of this might be if the extracted asset is very low resolution or pixelated, or if the extracted asset has unwanted elements.
+- When available, use edit_image for asset edits such as removing unwanted elements.
+- If an extracted or supplied asset is visibly low-resolution or pixelated and must render larger, upscale it with edit_image—not CSS stretching or generate_images.
- If an asset in the original screenshot is not extractable (for example, occluded by other objects or is the background), when available, use generate_images to create image URLs from prompts (you may pass multiple prompts).
- {image_policy}
diff --git a/backend/prompts/system_prompt.py b/backend/prompts/system_prompt.py
index a17ab1d1..73fe158f 100644
--- a/backend/prompts/system_prompt.py
+++ b/backend/prompts/system_prompt.py
@@ -21,7 +21,8 @@ You are a coding agent that's an expert at building front-ends.
## Image manipulation
- Use extract_assets (when available) to extract existing visual assets from the input screenshot.
- If an asset in the original screenshot is not extractable (for example, occluded by other objects or is the background image), use generate_images (when available) to create image URLs from prompts (you may pass multiple prompts). NEVER USE this tool to extract the entire screenshot and embed it on the page. Our goal here is to create nicely coded pages. We should only use extracted assets for images, not for layout, etc.
-- Use edit_image to edit existing images. It can also be used to upscale pixelated images or change aspect ratios with the appropriate instruction.
+- Use edit_image to edit existing images or change their aspect ratios.
+- If an extracted or supplied asset is visibly low-resolution or pixelated and must render larger, upscale it with edit_image—not CSS stretching or generate_images.
- Re: transparency, generate_images and edit_image are not capable of generating images with a transparent background. Use remove_background to remove backgrounds when needed (you may pass in multiple image URLs at once).
# Stack-specific instructions
diff --git a/backend/tests/test_agent_tools.py b/backend/tests/test_agent_tools.py
index 40e603a2..2f626d1b 100644
--- a/backend/tests/test_agent_tools.py
+++ b/backend/tests/test_agent_tools.py
@@ -229,6 +229,7 @@ def test_canonical_tool_definitions_include_edit_image() -> None:
tool_names = [tool.name for tool in tools]
assert "edit_image" in tool_names
edit_image_tool = next(tool for tool in tools if tool.name == "edit_image")
+ assert "upscale" in edit_image_tool.description.lower()
assert edit_image_tool.parameters["required"] == ["prompt", "image_urls"]
properties = edit_image_tool.parameters["properties"]
assert properties["image_urls"]["type"] == "array"
diff --git a/backend/tests/test_image_generation_replicate.py b/backend/tests/test_image_generation_replicate.py
index f9d0a1c8..381a8e7a 100644
--- a/backend/tests/test_image_generation_replicate.py
+++ b/backend/tests/test_image_generation_replicate.py
@@ -133,6 +133,7 @@ async def test_edit_image_uses_pruna_model_and_normalizes_output(
)
assert result == "https://example.com/edited.png"
+ assert replicate.P_IMAGE_EDIT_MODEL_PATH == "prunaai/p-image-edit"
assert captured["model_path"] == replicate.P_IMAGE_EDIT_MODEL_PATH
assert captured["input"] == {
"prompt": "Make image 1 monochrome",
diff --git a/backend/tests/test_prompts.py b/backend/tests/test_prompts.py
index 6c465ed6..3ea32d6b 100644
--- a/backend/tests/test_prompts.py
+++ b/backend/tests/test_prompts.py
@@ -130,6 +130,39 @@ class TestCreatePrompt:
assert "## Design system" in text
assert "Reuse .mockup-frame" in text
+ @pytest.mark.asyncio
+ async def test_image_mode_create_requires_edit_image_for_upscaling(self) -> None:
+ messages = await build_prompt_messages(
+ stack=self.TEST_STACK,
+ input_mode="image",
+ generation_type="create",
+ prompt={"text": "", "images": [self.TEST_IMAGE_URL], "videos": []},
+ history=[],
+ )
+
+ system_text = messages[0].get("content")
+ assert isinstance(system_text, str)
+ user_content = messages[1].get("content")
+ assert isinstance(user_content, list)
+ text_part = next(
+ part
+ for part in user_content
+ if isinstance(part, dict) and part.get("type") == "text"
+ )
+ user_text = text_part.get("text")
+ assert isinstance(user_text, str)
+
+ upscale_instruction = (
+ "If an extracted or supplied asset is visibly low-resolution or pixelated "
+ "and must render larger, upscale it with edit_image—not CSS stretching or "
+ "generate_images."
+ )
+ removed_instruction = 'Pass its source first, set aspect_ratio: "match_input_image"'
+ assert upscale_instruction in system_text
+ assert upscale_instruction in user_text
+ assert removed_instruction not in system_text
+ assert removed_instruction not in user_text
+
def test_plan_update_with_history_uses_history_strategy(self) -> None:
plan = derive_prompt_construction_plan(
stack=self.TEST_STACK,