-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description:
When an image is generated asynchronously (e.g. via fal.ai), the GenerateImage tool returns a relative path (/app/imagine/{id}) instead of a full absolute URL. This causes the LLM to hallucinate a domain name from its training data and construct an incorrect URL in its response to the user.
Steps to Reproduce:
- Enable the
generate_imagetool in an assistant. - Use an async image generation model (e.g. fal.ai).
- Ask the assistant to generate an image.
- Observe the URL in the assistant's response — the domain is wrong.
Root Cause:
In src/Ai/Infrastructure/Services/Tools/GenerateImage.php, the call() method returns:
'The image is being generated asynchronously. You can view it at: /app/imagine/'
. $image->getId()->getValue()->toString()
. '. The image will be ready in a few seconds.'The relative path is passed as a tool result to the LLM. Since the LLM has no knowledge of the actual deployment domain, it constructs a full URL using a hallucinated domain from its training data.
Expected Behavior:
The tool should return a full absolute URL using the configured site domain and protocol, e.g.:
https://yourdomain.com/app/imagine/{id}
Suggested Fix:
Inject option.site.domain and option.site.is_secure into the GenerateImage class (same pattern already used in src/Ai/Infrastructure/Services/FalAi/Helper.php) and build the full URL before returning it.
Environment:
- Affects all deployments using async image generation models
- Severity: Medium — users receive a broken or misleading link in chat