LibreChat/api/app/clients/tools/structured/specs
Danny Avila a88bfae4dd
🖼️ fix: Correct ToolMessage Response Format for Agent-Mode Image Tools (#12310)
* fix: Set response format for agent tools in DALLE3, FluxAPI, and StableDiffusion classes

- Added logic to set `responseFormat` to 'content_and_artifact' when `isAgent` is true in DALLE3.js, FluxAPI.js, and StableDiffusion.js.

* test: Add regression tests for image tool agent mode in imageTools-agent.spec.js

- Introduced a new test suite for DALLE3, FluxAPI, and StableDiffusion classes to verify that the invoke() method returns a ToolMessage with base64 in artifact.content, ensuring it is not serialized into content.
- Validated that responseFormat is set to 'content_and_artifact' when isAgent is true, and confirmed the correct handling of base64 data in the response.

* fix: handle agent error paths and generateFinetunedImage in image tools

- StableDiffusion._call() was returning a raw string on API error, bypassing
  returnValue() and breaking the content_and_artifact contract when isAgent is true
- FluxAPI.generateFinetunedImage() had no isAgent branch; it would call
  processFileURL (unset in agent context) instead of fetching and returning
  the base64 image as an artifact tuple
- Add JSDoc to all three responseFormat assignments clarifying why LangChain
  requires this property for correct ToolMessage construction

* test: expand image tool agent mode regression suite

- Add env var save/restore in beforeEach/afterEach to prevent test pollution
- Add error path tests for all three tools verifying ToolMessage content and
  artifact are correctly populated when the upstream API fails
- Add generate_finetuned action test for FluxAPI covering the new agent branch
  in generateFinetunedImage

* chore: fix lint errors in FluxAPI and imageTools-agent spec

* chore: fix import ordering in imageTools-agent spec
2026-03-19 15:33:46 -04:00
..
DALLE3-proxy.spec.js refactor: Replace tiktoken with ai-tokenizer (#12175) 2026-03-10 23:14:52 -04:00
DALLE3.spec.js refactor: Replace tiktoken with ai-tokenizer (#12175) 2026-03-10 23:14:52 -04:00
GeminiImageGen-proxy.spec.js 🌉 fix: Add Proxy Support to Gemini Image Gen Tool (#11302) 2026-01-12 09:51:48 -05:00
GoogleSearch.spec.js 🔧 fix: API Key Handling for GoogleSearch and TavilySearch Tools (#3541) 2024-08-05 19:29:16 -04:00
imageTools-agent.spec.js 🖼️ fix: Correct ToolMessage Response Format for Agent-Mode Image Tools (#12310) 2026-03-19 15:33:46 -04:00
openWeather.integration.test.js 🌤️ feat: Add OpenWeather Tool for Weather Data Retrieval (#5246) 2025-01-10 08:54:08 -05:00
openweather.test.js 🌤️ feat: Add OpenWeather Tool for Weather Data Retrieval (#5246) 2025-01-10 08:54:08 -05:00
TavilySearchResults.spec.js 🖥️ feat: Add Proxy Support for Tavily API Tool (#10770) 2025-12-02 09:11:56 -05:00