HKUDS/nanobot · error · ImageGenerationError
reference_images must be inside the workspace or nanobot…
Error message
reference_images must be inside the workspace or nanobot media directory
What it means
Raised by _resolve_reference_image when resolve_allowed_path throws WorkspaceBoundaryError: the reference image path escapes both the current tool workspace root and the nanobot media directory. This is the sandbox path-escape guard for image generation inputs.
Solutions
- Place reference images inside the workspace or the nanobot media directory
- Reference the image with a path relative to the workspace root
- Copy the file into the workspace before using it as a reference
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at nanobot/agent/tools/image_generation.py:162 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26).
Data as JSON: /api/errors/710158e354c40148.
Report an issue: GitHub.
Appendix: source
Thrown at nanobot/agent/tools/image_generation.py:162
"extra_body": provider.extra_body
if provider and isinstance(provider.extra_body, dict) else None,
"proxy": provider.proxy if provider and isinstance(provider.proxy, str) else None,
}
return cls(**kwargs)
def _resolve_reference_image(self, value: str) -> str:
access = current_tool_workspace(self.workspace, restrict_to_workspace=True)
workspace = access.project_path or self.workspace
try:
resolved = resolve_allowed_path(
value,
workspace=workspace,
allowed_root=access.allowed_root,
extra_allowed_roots=[get_media_dir()] if access.allowed_root is not None else None,
strict=True,
)
except WorkspaceBoundaryError as exc:
raise ImageGenerationError(
"reference_images must be inside the workspace or nanobot media directory"
) from exc
except OSError as exc:
raise ImageGenerationError(f"reference image not found: {value}") from exc
if not resolved.is_file():
raise ImageGenerationError(f"reference image is not a file: {value}")
raw = resolved.read_bytes()
if detect_image_mime(raw) is None:
raise ImageGenerationError(f"unsupported reference image: {value}")
return str(resolved)
def _resolve_reference_images(self, values: list[str] | None) -> list[str]:
if not values:
return []
return [self._resolve_reference_image(value) for value in values if value]
async def execute( # pyright: ignore[reportIncompatibleMethodOverride]
self,View on GitHub (pinned to 42f37dc4c0)