LibreChat/api/app/clients/tools/structured
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
..
specs 🖼️ fix: Correct ToolMessage Response Format for Agent-Mode Image Tools (#12310) 2026-03-19 15:33:46 -04:00
AzureAISearch.js 🦥 refactor: Event-Driven Lazy Tool Loading (#11588) 2026-02-01 08:50:57 -05:00
credentials.js 🎥 feat: YouTube Tool (#5582) 2025-01-31 19:11:04 -05:00
DALLE3.js 🖼️ fix: Correct ToolMessage Response Format for Agent-Mode Image Tools (#12310) 2026-03-19 15:33:46 -04:00
FluxAPI.js 🖼️ fix: Correct ToolMessage Response Format for Agent-Mode Image Tools (#12310) 2026-03-19 15:33:46 -04:00
GeminiImageGen.js 🪙 feat: Add messageId to Transactions (#11987) 2026-02-27 23:50:13 -05:00
GoogleSearch.js 🦥 refactor: Event-Driven Lazy Tool Loading (#11588) 2026-02-01 08:50:57 -05:00
OpenAIImageTools.js 🏞️ feat: Modifiable OpenAI Image Gen Model Environment Variable (#11082) 2025-12-25 12:45:38 -05:00
OpenWeather.js 🦥 refactor: Event-Driven Lazy Tool Loading (#11588) 2026-02-01 08:50:57 -05:00
StableDiffusion.js 🖼️ fix: Correct ToolMessage Response Format for Agent-Mode Image Tools (#12310) 2026-03-19 15:33:46 -04:00
TavilySearch.js 🖥️ feat: Add Proxy Support for Tavily API Tool (#10770) 2025-12-02 09:11:56 -05:00
TavilySearchResults.js 🦥 refactor: Event-Driven Lazy Tool Loading (#11588) 2026-02-01 08:50:57 -05:00
TraversaalSearch.js 🦥 refactor: Event-Driven Lazy Tool Loading (#11588) 2026-02-01 08:50:57 -05:00
Wolfram.js 🦥 refactor: Event-Driven Lazy Tool Loading (#11588) 2026-02-01 08:50:57 -05:00