DAO Proposals & Community
View active proposals, submit new ideas, and connect with the SWARMS community.
This PR adds token streaming to the Agent class. When streaming_on=True, the agent's responses will now print to the console token-by-token for a more interactive feel. This is handled by updating the LiteLLM wrapper to return the raw stream and having the Agent class iterate through it. Also includes a fix for an AuthenticationError by ensuring the llm_api_key is correctly passed through all relevant methods. Note: This requires the litellm package to be installed (pip install litellm)  <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--926.org.readthedocs.build/en/926/ <!-- readthedocs-preview swarms end -->
**Description:** This PR implements lazy loading for the VLLM wrapper class, significantly improving initialization performance by deferring the creation of the underlying LLM and sampling parameters until they're actually needed. The implementation adds a private `_ensure_initialized()` method that creates these resources on first use, rather than at object creation time. **Key Changes:** - Modified `VLLMWrapper` to defer LLM and sampling parameters creation until first use - Created a new `_ensure_initialized()` method that loads resources on demand - Updated the `run()` and `batched_run()` methods to call `_ensure_initialized()` - Updated documentation and examples to clearly indicate the new lazy loading behavior - Fixed related code comments across the codebase for consistency **Benefits:** - Improved performance for applications that create VLLM wrappers but don't immediately use them - Reduced memory usage until the model is actually needed - Faster application startup time when working with multiple potential models **Issue:** #924 **Dependencies:** None <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--925.org.readthedocs.build/en/925/ <!-- readthedocs-preview swarms end -->
This pull request fixes the issue #922 introduces a new multimodal example for security analysis and improves error handling in tool execution across the codebase. The changes focus on adding functionality for analyzing danger levels, enhancing logging and debugging, and gracefully handling cases where responses or API calls return `None`. ### New functionality for multimodal security analysis: * [`examples/multi_modal/multimodal_example.py`](diffhunk://#diff-0144dbb700256798848d77d603aeebadb5664a638755d5c4abb4d46ceceba810R1-R91): Added a new example showcasing a `Quality Control Agent` that analyzes images and performs security analysis based on danger levels. Includes a custom system prompt and a `security_analysis` function to handle "low," "medium," and "high" danger levels. ### Improved error handling in tool execution: * `swarms/structs/agent.py`, `def _run`: Updated tool execution logic to skip execution and log warnings when the response is `None`. Similarly, added checks for MCP tool handling to avoid processing when no valid response is returned. * `swarms/structs/agent.py`, `def temp_llm_instance_for_tool_summary`: Added a safeguard to log warnings and return early if the response is `None`, ensuring tools are not executed with invalid data. * `swarms/tools/base_tool.py`, `def execute_function_calls_from_api_response`: Enhanced error handling by replacing the `ToolValidationError` with a warning log and returning empty results when the API response is `None`. <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--923.org.readthedocs.build/en/923/ <!-- readthedocs-preview swarms end -->
There is an crash in agent, when we use multi-modal with tool calling ! ```shell PS D:\Github\swarms> python -u "d:\Github\swarms\multimodal2.py" 2025-06-25 08:44:50 | INFO | swarms.structs.agent:handle_sop_ops:2497 - SOP Uploaded into the memory โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Agent Name Quality Control Agent [Max Loops: 1 ] โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ Quality Control Agent: None โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ 2025-06-25 08:45:00 | ERROR | swarms.structs.agent:_run:1119 - Attempt 1: Error generating response: API response cannot be None โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Agent Name Quality Control Agent [Max Loops: 1 ] โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ Quality Control Agent: None ``` So, the main problem here is its not handling the proper response from the LLM, if its none, the above aren't errors they are bad error handling issues, so we need to improve the error handling gracefully ! if i comment out the in base_tool.py : ```py if api_response is None: raise .... ``` then the whole program gets working and it doesn't gets error everytime sometimes it works sometimes it doesn't , we need to handle the errors gracefully ! the other problem was in the below example in the issue #897 , where the example isn't that good for making the model use functions, that is leading the issues !! , the system_prompt and task weren't defined clearly so as to make use of the tool call
- Implement streaming into agent.py and litellm_wrapper.py
**Description:** This PR removes the hardcoded API token from the telemetry module and replaces it with dynamic token loading from environment variables. Instead of embedding a token directly in the code, the telemetry client now looks for a `SWARMS_API_KEY` environment variable and includes it in API requests only when available. This change aligns with security best practices by avoiding hardcoded credentials in source code. **Key Changes:** - Removed the hardcoded API token from main.py. - Modified the session creation to include the API key from `os.getenv("SWARMS_API_KEY")` only if provided. - Added documentation for the `SWARMS_API_KEY` environment variable in README.md. - Added proper import for the `os` module. **Issue:** N/A **Dependencies:** None **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--920.org.readthedocs.build/en/920/ <!-- readthedocs-preview swarms end -->
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--919.org.readthedocs.build/en/919/ <!-- readthedocs-preview swarms end -->
Bumps [pypdf](https://github.com/py-pdf/pypdf) from 5.1.0 to 5.6.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/py-pdf/pypdf/releases">pypdf's releases</a>.</em></p> <blockquote> <h2>Version 5.6.1, 2025-06-22</h2> <h2>What's new</h2> <h3>New Features (ENH)</h3> <ul> <li>Add PDF/A XMP metadata support (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3314">#3314</a>) by <a href="https://github.com/Arya-A-Nair"><code>@โArya-A-Nair</code></a></li> </ul> <h3>Robustness (ROB)</h3> <ul> <li>Deal with annotations not being lists on merge (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3321">#3321</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> <li>Handle NullObject for cmap encoding Differences entry (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3317">#3317</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> </ul> <h3>Developer Experience (DEV)</h3> <ul> <li>Update ruff to 0.12.0 (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3316">#3316</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> </ul> <p><a href="https://github.com/py-pdf/pypdf/compare/5.6.0...5.6.1">Full Changelog</a></p> <h2>Version 5.6.0, 2025-06-01</h2> <h2>What's new</h2> <h3>New Features (ENH)</h3> <ul> <li>Add basic support for JBIG2 by using jbig2dec (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3163">#3163</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> </ul> <h3>Bug Fixes (BUG)</h3> <ul> <li>Fix crashes by removing unnecessary line (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3293">#3293</a>) by <a href="https://github.com/larsga"><code>@โlarsga</code></a></li> <li>Add delimiters to NameObject.renumber_table (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3286">#3286</a>) by <a href="https://github.com/ztravis"><code>@โztravis</code></a></li> </ul> <h3>Robustness (ROB)</h3> <ul> <li>Handle DecodeParms being a NullObject (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3285">#3285</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> </ul> <h3>Code Style (STY)</h3> <ul> <li>Update to mypy 1.16.0 (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3300">#3300</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> </ul> <p><a href="https://github.com/py-pdf/pypdf/compare/5.5.0...5.6.0">Full Changelog</a></p> <h2>Version 5.5.0, 2025-05-11</h2> <h2>What's new</h2> <h3>New Features (ENH)</h3> <ul> <li>Add support for IndirectObject.<strong>iter</strong> (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3228">#3228</a>) by <a href="https://github.com/bryan-brancotte"><code>@โbryan-brancotte</code></a></li> <li>Allow filtering by font when removing text (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3216">#3216</a>) by <a href="https://github.com/samuelbradshaw"><code>@โsamuelbradshaw</code></a></li> </ul> <h3>Bug Fixes (BUG)</h3> <ul> <li>Add missing named destinations being ByteStringObjects (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3282">#3282</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> <li>Get font information more reliably when removing text (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3252">#3252</a>) by <a href="https://github.com/samuelbradshaw"><code>@โsamuelbradshaw</code></a></li> <li>T* 2D Translation consistent with PDF 1.7 Spec (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3250">#3250</a>) by <a href="https://github.com/hackowitz-af"><code>@โhackowitz-af</code></a></li> <li>Add font stack to q/Q operations in layout mode (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3225">#3225</a>) by <a href="https://github.com/hackowitz-af"><code>@โhackowitz-af</code></a></li> <li>Avoid completely hiding image loading issues like exceeding image size limits (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3221">#3221</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> <li>Using compress_identical_objects on transformed content duplicates differing content (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3197">#3197</a>) by <a href="https://github.com/danio"><code>@โdanio</code></a></li> <li>Consider BlackIs1 parameter for CCITTFaxDecode filter (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3196">#3196</a>) by <a href="https://github.com/stefan6419846"><code>@โstefan6419846</code></a></li> </ul> <h3>Robustness (ROB)</h3> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/py-pdf/pypdf/blob/main/CHANGELOG.md">pypdf's changelog</a>.</em></p> <blockquote> <h2>Version 5.6.1, 2025-06-22</h2> <h3>New Features (ENH)</h3> <ul> <li>Add PDF/A XMP metadata support (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3314">#3314</a>)</li> </ul> <h3>Robustness (ROB)</h3> <ul> <li>Deal with annotations not being lists on merge (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3321">#3321</a>)</li> <li>Handle NullObject for cmap encoding Differences entry (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3317">#3317</a>)</li> </ul> <h3>Developer Experience (DEV)</h3> <ul> <li>Update ruff to 0.12.0 (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3316">#3316</a>)</li> </ul> <p><a href="https://github.com/py-pdf/pypdf/compare/5.6.0...5.6.1">Full Changelog</a></p> <h2>Version 5.6.0, 2025-06-01</h2> <h3>New Features (ENH)</h3> <ul> <li>Add basic support for JBIG2 by using jbig2dec (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3163">#3163</a>)</li> </ul> <h3>Bug Fixes (BUG)</h3> <ul> <li>Fix crashes by removing unnecessary line (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3293">#3293</a>)</li> <li>Add delimiters to NameObject.renumber_table (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3286">#3286</a>)</li> </ul> <h3>Robustness (ROB)</h3> <ul> <li>Handle DecodeParms being a NullObject (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3285">#3285</a>)</li> </ul> <h3>Code Style (STY)</h3> <ul> <li>Update to mypy 1.16.0 (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3300">#3300</a>)</li> </ul> <p><a href="https://github.com/py-pdf/pypdf/compare/5.5.0...5.6.0">Full Changelog</a></p> <h2>Version 5.5.0, 2025-05-11</h2> <h3>New Features (ENH)</h3> <ul> <li>Add support for IndirectObject.<strong>iter</strong> (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3228">#3228</a>)</li> <li>Allow filtering by font when removing text (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3216">#3216</a>)</li> </ul> <h3>Bug Fixes (BUG)</h3> <ul> <li>Add missing named destinations being ByteStringObjects (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3282">#3282</a>)</li> <li>Get font information more reliably when removing text (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3252">#3252</a>)</li> <li>T* 2D Translation consistent with PDF 1.7 Spec (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3250">#3250</a>)</li> <li>Add font stack to q/Q operations in layout mode (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3225">#3225</a>)</li> <li>Avoid completely hiding image loading issues like exceeding image size limits (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3221">#3221</a>)</li> <li>Using compress_identical_objects on transformed content duplicates differing content (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3197">#3197</a>)</li> <li>Consider BlackIs1 parameter for CCITTFaxDecode filter (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3196">#3196</a>)</li> </ul> <h3>Robustness (ROB)</h3> <ul> <li>Deal with insufficient cm matrix during text extraction (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3283">#3283</a>)</li> <li>Allow merging when annotations miss D entry (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3281">#3281</a>)</li> <li>Fix merging documents if there are no Dests (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3280">#3280</a>)</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/py-pdf/pypdf/commit/c721d1f01725fecf285fc7a44292195426270f87"><code>c721d1f</code></a> REL: 5.6.1</li> <li><a href="https://github.com/py-pdf/pypdf/commit/07f26f79c2f6ea9d49e1cc53899a2b7ffc442557"><code>07f26f7</code></a> ROB: Deal with annotations not being lists on merge (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3321">#3321</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/a5845a55582b5db5b53f8937d4c5b9f595b174ae"><code>a5845a5</code></a> ROB: Handle NullObject for cmap encoding Differences entry (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3317">#3317</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/5f84a8b89c02e5365ea6c5b90aaa61ecdab3a563"><code>5f84a8b</code></a> DEV: Update ruff to 0.12.0 (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3316">#3316</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/e8e2ab685cb61a9fc623a0a066244d717928963f"><code>e8e2ab6</code></a> ENH: Add PDF/A XMP metadata support (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3314">#3314</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/67d1ba14e192d813fb1119534f9e029e80a2ad80"><code>67d1ba1</code></a> MAINT: Improve benchmarking code (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3315">#3315</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/4fbc38db01ce84823900eaaa12c7e1775b8cab4d"><code>4fbc38d</code></a> MAINT: Update comment (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3311">#3311</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/05300d5b9e190c7d8219c5359107451fe6abf8a0"><code>05300d5</code></a> DEV: Use latest requests version (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3307">#3307</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/1c9eacd8e766585c87a601601df81a0e7e10dde5"><code>1c9eacd</code></a> MAINT: Use mypy recursive type support (<a href="https://redirect.github.com/py-pdf/pypdf/issues/2898">#2898</a>)</li> <li><a href="https://github.com/py-pdf/pypdf/commit/9ffa6c60138047e189cd2d21cc89a0a2617b78c0"><code>9ffa6c6</code></a> DEV: Remove ignore Ruff rule B028 (<a href="https://redirect.github.com/py-pdf/pypdf/issues/3214">#3214</a>)</li> <li>Additional commits viewable in <a href="https://github.com/py-pdf/pypdf/compare/5.1.0...5.6.1">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--918.org.readthedocs.build/en/918/ <!-- readthedocs-preview swarms end -->
Updates the requirements on [pymdown-extensions](https://github.com/facelessuser/pymdown-extensions) to permit the latest version. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/facelessuser/pymdown-extensions/releases">pymdown-extensions's releases</a>.</em></p> <blockquote> <h2>10.16</h2> <ul> <li><strong>NEW</strong>: Add early support for Python 3.14.</li> <li><strong>NEW</strong>: Drop support for Python 3.8.</li> <li><strong>NEW</strong>: Snippets: Added <code>max_retries</code> and <code>backoff_retries</code> options to configure new retry logic for HTTP 429 errors (Too Many Requests client error).</li> <li><strong>NEW</strong>: Caption: Prefix templates are now preserved exactly as specified allowing the insertion of HTML tags if desired.</li> <li><strong>FIX</strong>: Caption: Fix issue where manual numbers in auto were not respected appropriately.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/7d3d4f990463e50b1ba1e20830832285d92990c7"><code>7d3d4f9</code></a> Add early support for Python 3.14 (<a href="https://redirect.github.com/facelessuser/pymdown-extensions/issues/2697">#2697</a>)</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/beb841e6f968b81403166d685b083fe2bde84bbc"><code>beb841e</code></a> Docs: Update JS deps</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/620d7fded457a0b5317019fa461a27f484a0d3d4"><code>620d7fd</code></a> Docs: update JS deps</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/a49f32aa4ac91d97c7c10c9abe7f654b5ec802e5"><code>a49f32a</code></a> Refactor for mypy issue</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/52a481b5591879f49baffecf4275f351d27a3759"><code>52a481b</code></a> Docs: update JS dependencies</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/2a1828accdc2371d97610fbbb574dd878e090b54"><code>2a1828a</code></a> Allow raw HTML in caption prefix (<a href="https://redirect.github.com/facelessuser/pymdown-extensions/issues/2679">#2679</a>)</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/fbf4bf22da3bc864f24b4ee6a2c05b145fb6c304"><code>fbf4bf2</code></a> Fix issue where manual captions in auto were not respected properly (<a href="https://redirect.github.com/facelessuser/pymdown-extensions/issues/2678">#2678</a>)</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/70cf820aae36d57cf493ca9c8c2e24ab11c6c445"><code>70cf820</code></a> Fix spelling of marketplace for GitHub (<a href="https://redirect.github.com/facelessuser/pymdown-extensions/issues/2674">#2674</a>)</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/553251d5a68999a95b71bd155fa83b3f9a4f7997"><code>553251d</code></a> Add retry logic for rate limited HTTP errors (429) (<a href="https://redirect.github.com/facelessuser/pymdown-extensions/issues/2669">#2669</a>)</li> <li><a href="https://github.com/facelessuser/pymdown-extensions/commit/bd2f267557e27d1482db5ad7c0a9db4c619a6004"><code>bd2f267</code></a> Drop Python 3.8 (<a href="https://redirect.github.com/facelessuser/pymdown-extensions/issues/2654">#2654</a>)</li> <li>Additional commits viewable in <a href="https://github.com/facelessuser/pymdown-extensions/compare/10.15...10.16">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--917.org.readthedocs.build/en/917/ <!-- readthedocs-preview swarms end -->
#912 Description This PR adds support for multiple images in the agent by enhancing the img parameter in the LiteLLM class to accept both a single image path (string) or multiple image paths (list of strings). The implementation maintains backward compatibility while adding new functionality. Changes Enhanced the img parameter in run(), arun(), and related methods to accept Union[str, List[str]] type Modified _prepare_messages() method to handle both single image (string) and multiple images (list) Updated vision processing methods to process lists of images Added appropriate type hints and updated docstrings Ensured backward compatibility with existing code Implementation Details The implementation takes a simple yet effective approach by modifying the existing img parameter to accept either a single string or a list of strings. When a string is provided, it's converted to a single-item list internally for uniform processing. This approach avoids adding a new parameter and keeps the API clean while extending functionality. Single image input (backward compatibility) Multiple image inputs with both OpenAI and Anthropic models Various image formats through URLs and local files User Impact Users can now pass multiple images to the LiteLLM Wrapper in one of two ways: Previous usage (still supported) agent.run(task, img='path/to/img') New usage with multiple images agent.run(task, img=['img1', 'img2', 'img3']) No changes are required for existing code as backward compatibility is maintained. <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--916.org.readthedocs.build/en/916/ <!-- readthedocs-preview swarms end -->
Overview This PR implements an agent instance caching mechanism for the ReasoningAgentRouter class, significantly optimizing performance when handling agent requests with identical configurations. By maintaining an instance cache at the class level, we avoid redundant creation of agent instances with the same configuration, reducing memory usage and initialization overhead. Problem Statement In the original implementation, a completely new agent instance was created each time the select_swarm() method was called, regardless of whether the configuration was identical. For high-frequency calls or batch processing scenarios, this led to unnecessary object creation and memory consumption, particularly noticeable when processing large-scale task sets. Solution I've implemented a configuration-based agent instance caching mechanism: Added a cache dictionary at the class level to store previously created agent instances Generated unique cache keys based on agent configurations Prioritized reusing existing instances by checking the cache before creating new ones Provided a cache clearing method to support memory release when necessary Performance Improvements Reduced Instantiation Overhead: For agents with identical configurations, instances are created only once Lower Memory Footprint: Avoids storing multiple instances with identical functionality Improved Response Time: Eliminates redundant constructor calls and initialization processes Resource Efficiency: More efficient utilization of system resources, especially in high-load scenarios Technical Details Modifications Added Class-level Cache: _agent_cache: Dict[Tuple[Hashable, ...], Any] = {} Added Cache Key Generation Method: def _get_cache_key(self) -> Tuple[Hashable, ...]: return ( self.swarm_type, self.agent_name, # ... other configuration parameters ) Optimized select_swarm Method: def select_swarm(self): cache_key = self._get_cache_key() if cache_key in self.__class__._agent_cache: return self.__class__._agent_cache[cache_key] # Original instance creation logic agent = self.agent_factories[self.swarm_type]() self.__class__._agent_cache[cache_key] = agent return agent Added Cache Management Method: @classmethod def clear_cache(cls): cls._agent_cache.clear() Backward Compatibility This modification specifically focuses on maintaining the stability of existing interfaces and behavior: Unchanged Public API: No changes to class constructor parameters No modifications to any public method signatures Consistent return values for existing methods Incremental Internal Implementation Changes: No removal of any existing functionality or methods Caching logic enhances existing methods rather than replacing them Original error handling mechanisms preserved Zero Impact on External Dependencies: All modifications encapsulated within the class No introduction of new external dependencies No requirement for callers to change usage patterns Practical Application Scenarios This optimization is particularly effective in the following scenarios: Batch Processing: When handling numerous tasks with similar configurations Microservice Architecture: Using identical agent configurations across multiple requests High-Frequency Invocations: Multiple agent usages of the same type within short timeframes Long-Running Applications: Reducing resource accumulation in long-term running programs <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--915.org.readthedocs.build/en/915/ <!-- readthedocs-preview swarms end -->
- Add multiple images into the agent.run(imgs = [url_1, etc]) - Add the logic into litellm_wrapper.py
- Making Products weekly - Accountant Tax Agent - Products from the Implementation of Papers -
[TUTORIAL][Idea] Make full stack apps with swarms and v0.dev [maybe video or blog] - Make a video on how to build a full stack application with the swarms api - Make a blog and tutorial on how to build a full stack application with the swarms api - Create back office swarm app for tax and or accounting - Cursor/personal hedge fund for stock analysis - Mini app for tree of thoughts where you can see agents reasoning in trees - Deep research app in the swarms app store styled it like: https://x.com/BrettFromDJ/status/1935776171288875214 - Use swarms app as the main account to sign in with swarms, deduct credits, create a monopoly
[BLOG][Make a blog for InteractiveGroupChatSwarm] - Make a blog and post it to medium
- Create an interactive groupchat video
 If we just want to fix the current bug, we donโt need to change a lot of code. We just need to replace โresponse = self.parse_llm_output(response)โ with the part in the red box in the screenshot. fix #897 I've reproduced and analyzed this bug. The issue occurs in the _run method of agent.py when dealing with multi-modal requests without images. Root Cause Analysis: The main problem is that in your example code, you commented out the image upload line: python img=factory_image This causes the LLM call to receive no image input while in multi-modal mode. In agent.py, when self.call_llm(...) is executed without proper image data, it returns an empty response. This empty response is then passed to self.parse_llm_output(response), which tries to standardize the LLM output but fails because there's nothing to parse. The error becomes visible when executing: python self.short_memory.add( role=self.agent_name, content=format_dict_to_string(response), ) The format_dict_to_string() method (defined in swarms\utils\index.py) fails because it's trying to format an empty dictionary into a string. Additional Finding: I also noticed a potential circular dependency issue in the agent.py file with this function calling pattern: call_llm โ run โ _run โ call_llm While this isn't causing the current error (as the dependency between _run โ call_llm isn't fully formed), it creates a risky architecture that could lead to infinite recursion and stack overflow errors in future development. <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--906.org.readthedocs.build/en/906/ <!-- readthedocs-preview swarms end -->
This pull request introduces a comprehensive integration of Retrieval-Augmented Generation (RAG) functionality into the Swarms framework. It includes a new example script (`simple_rag_example.py`), updates to the `Agent` class to support RAG operations, and enhancements to the `AgentRAGHandler`. These changes aim to improve the framework's ability to retrieve and utilize external knowledge dynamically. ### RAG Integration Enhancements: * **New Example Script**: Added `simple_rag_example.py`, demonstrating the usage of RAG with a simple memory store and Swarms Agent. The example includes memory querying, manual saves, and integration of RAG into agent workflows. * **Agent Class Updates**: Extended the `Agent` class with methods for enabling, disabling, and managing RAG functionality, including memory queries, saving to memory, and retrieving statistics. Legacy methods were replaced with new RAG-specific handlers. [[1]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR281-R292) [[2]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR605-R627) [[3]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR2908-R2989) * **RAG Handler Enhancements**: Improved the `AgentRAGHandler` to ensure default relevance keywords are used when none are provided in the RAG configuration. ### Code Refactoring: * **Initialization Improvements**: Refactored `Agent` initialization to support RAG configuration directly and ensure proper setup of the RAG handler. Legacy methods for memory querying and handling were deprecated. [[1]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR605-R627) [[2]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fL2020-R2110) * **Memory and Tool Handling**: Updated `_run` and related methods in `Agent` to incorporate RAG operations seamlessly during task execution and final memory consolidation. [[1]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fL974-R1007) [[2]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR1191-R1199) ### Framework Updates: * **Structs Module**: Added `RAGConfig` to the Swarms `structs` module to facilitate RAG configuration management. [[1]](diffhunk://#diff-a17ecbb7ffeb5a1dd98bcbe4d602fd32d73f6826ee8747b9dfc1ef74a8b748a5R3) [[2]](diffhunk://#diff-a17ecbb7ffeb5a1dd98bcbe4d602fd32d73f6826ee8747b9dfc1ef74a8b748a5R162) * **Agent Persistence**: Enhanced `_save_additional_components` and `_reinitialize_after_load` methods to support saving and reinitializing RAG handler statistics. [[1]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR1614-R1631) [[2]](diffhunk://#diff-76dda3e4659d2af1a87d31ef5b71580793ac95d3a00e2a0aeffb288e15f5a44fR1759-R1772) #880 <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--903.org.readthedocs.build/en/903/ <!-- readthedocs-preview swarms end -->
**Description:** This PR introduces a concise example demonstrating how to configure and apply custom stopping conditions to a running swarm. The new example shows how to halt a swarmโs execution when a user-defined function evaluates to `True`, improving control over swarm lifecycle management. The example is linked in the documentation for swarm lifecycle control and referenced in the relevant API docs. **Key Changes:** - Added swarm_stopping_condition.py to demonstrate stopping conditions in a round-robin swarm. - Created swarm_stopping_condition.md with a code snippet and explanation. - Linked the new example in abstractswarm.md under the โStopping Conditionsโ section. - Updated mkdocs.yml to include the example in the navigation. **Issue:** N/A **Dependencies:** N/A **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--899.org.readthedocs.build/en/899/ <!-- readthedocs-preview swarms end -->
- update the api docs with the latest changes
- Add more examples about templates from the swarms organization github - add in docs/examples - Add file path in mkdocs
**Description:** This PR enhances Swarms agents by enabling connectivity to multiple MCP (Modular Command Protocol) servers simultaneously, allowing tools to be executed across different microservices. The implementation supports both configuring MCP URLs directly through the agent constructor and via environment variables. **Key Features:** - Support for multiple MCP servers through `mcp_urls` parameter or `MCP_URLS` environment variable - New `handle_multiple_mcp_tools` method for executing tools across different servers - Added `execute_mcp_call` function for direct server-specific tool execution - Enhanced error handling with retry logic for reliable tool execution - Robust JSON payload extraction from model responses - Complete documentation of the multi-MCP workflow and payload format - Example servers (`weather_server.py` and `news_server.py`) for testing **Impact:** - Enables distributed tool execution across specialized microservices - Improves system architecture by separating tool concerns - Provides fault tolerance through connection to multiple servers - Maintains backward compatibility with existing single-server implementations **Issue:** Closes #881 **Testing:** - Added unit tests in `test_multi_mcp.py` - Created end-to-end examples with local MCP servers - Manual verification with demo servers **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--891.org.readthedocs.build/en/891/ <!-- readthedocs-preview swarms end -->
Bumps [pydantic](https://github.com/pydantic/pydantic) from 2.11.4 to 2.11.7. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pydantic/pydantic/releases">pydantic's releases</a>.</em></p> <blockquote> <h2>v2.11.7 2025-06-14</h2> <!-- raw HTML omitted --> <h2>What's Changed</h2> <h3>Fixes</h3> <ul> <li>Copy <code>FieldInfo</code> instance if necessary during <code>FieldInfo</code> build by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11980">pydantic/pydantic#11980</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/pydantic/pydantic/compare/v2.11.6...v2.11.7">https://github.com/pydantic/pydantic/compare/v2.11.6...v2.11.7</a></p> <h2>v2.11.6 2025-06-13</h2> <h2>v2.11.6 (2025-06-13)</h2> <h3>What's Changed</h3> <h4>Fixes</h4> <ul> <li>Rebuild dataclass fields before schema generation by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11949">#11949</a></li> <li>Always store the original field assignment on <code>FieldInfo</code> by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11946">#11946</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/pydantic/pydantic/compare/v2.11.5...v2.11.6">https://github.com/pydantic/pydantic/compare/v2.11.5...v2.11.6</a></p> <h2>v2.11.5 2025-05-22</h2> <!-- raw HTML omitted --> <h2>What's Changed</h2> <h3>Fixes</h3> <ul> <li>Check if <code>FieldInfo</code> is complete after applying type variable map by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11855">#11855</a></li> <li>Do not delete mock validator/serializer in <code>model_rebuild()</code> by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11890">#11890</a></li> <li>Do not duplicate metadata on model rebuild by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11902">#11902</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/pydantic/pydantic/compare/v2.11.4...v2.11.5">https://github.com/pydantic/pydantic/compare/v2.11.4...v2.11.5</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pydantic/pydantic/blob/main/HISTORY.md">pydantic's changelog</a>.</em></p> <blockquote> <h2>v2.11.7 (2025-06-14)</h2> <p><a href="https://github.com/pydantic/pydantic/releases/tag/v2.11.7">GitHub release</a></p> <h3>What's Changed</h3> <h4>Fixes</h4> <ul> <li>Copy <code>FieldInfo</code> instance if necessary during <code>FieldInfo</code> build by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11898">#11898</a></li> </ul> <h2>v2.11.6 (2025-06-13)</h2> <p><a href="https://github.com/pydantic/pydantic/releases/tag/v2.11.6">GitHub release</a></p> <h3>What's Changed</h3> <h4>Fixes</h4> <ul> <li>Rebuild dataclass fields before schema generation by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11949">#11949</a></li> <li>Always store the original field assignment on <code>FieldInfo</code> by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11946">#11946</a></li> </ul> <h2>v2.11.5 (2025-05-22)</h2> <p><a href="https://github.com/pydantic/pydantic/releases/tag/v2.11.5">GitHub release</a></p> <h3>What's Changed</h3> <h4>Fixes</h4> <ul> <li>Check if <code>FieldInfo</code> is complete after applying type variable map by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11855">#11855</a></li> <li>Do not delete mock validator/serializer in <code>model_rebuild()</code> by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11890">#11890</a></li> <li>Do not duplicate metadata on model rebuild by <a href="https://github.com/Viicos"><code>@โViicos</code></a> in <a href="https://redirect.github.com/pydantic/pydantic/pull/11902">#11902</a></li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pydantic/pydantic/commit/5f033e46c54fea1b59b6894d6527daf49475e690"><code>5f033e4</code></a> Prepare release v2.11.7</li> <li><a href="https://github.com/pydantic/pydantic/commit/c3368b83c411f421a7322959bc29f3bea4bd252a"><code>c3368b8</code></a> Copy <code>FieldInfo</code> instance if necessary during <code>FieldInfo</code> build (<a href="https://redirect.github.com/pydantic/pydantic/issues/11980">#11980</a>)</li> <li><a href="https://github.com/pydantic/pydantic/commit/3987b23db4b31ff35e9fa15c21c0c1d1c9808838"><code>3987b23</code></a> Prepare release v2.11.6</li> <li><a href="https://github.com/pydantic/pydantic/commit/dc7a9d20bee55a3a6e7397ee46abfcd9057b627b"><code>dc7a9d2</code></a> Always store the original field assignment on <code>FieldInfo</code></li> <li><a href="https://github.com/pydantic/pydantic/commit/c284c279a5b8c95d32ab5ec31d2511b3b27bfa87"><code>c284c27</code></a> Rebuild dataclass fields before schema generation</li> <li><a href="https://github.com/pydantic/pydantic/commit/5e6d1dc71fe9bd832635cb2e9b4af92286fd00b8"><code>5e6d1dc</code></a> Prepare release v2.11.5</li> <li><a href="https://github.com/pydantic/pydantic/commit/1b63218c42b515bd1f6b0dd323190236ead14bdb"><code>1b63218</code></a> Do not duplicate metadata on model rebuild (<a href="https://redirect.github.com/pydantic/pydantic/issues/11902">#11902</a>)</li> <li><a href="https://github.com/pydantic/pydantic/commit/5aefad873b3dfd60c419bd081ffaf0ac197c7b60"><code>5aefad8</code></a> Do not delete mock validator/serializer in <code>model_rebuild()</code></li> <li><a href="https://github.com/pydantic/pydantic/commit/8fbe6585f4d6179e5234ab61de00059c52e57975"><code>8fbe658</code></a> Check if <code>FieldInfo</code> is complete after applying type variable map</li> <li><a href="https://github.com/pydantic/pydantic/commit/12b371a0f7f800bf65daa3eaada1b4348348d9c4"><code>12b371a</code></a> Update documentation about <code>@dataclass_transform</code> support</li> <li>Additional commits viewable in <a href="https://github.com/pydantic/pydantic/compare/v2.11.4...v2.11.7">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--889.org.readthedocs.build/en/889/ <!-- readthedocs-preview swarms end -->
**Description:** This PR enhances the `data_to_text` utility to properly handle binary files. Previously, binary files would cause errors when the function attempted to read them as text. With this improvement, binary files are now detected by their extensions and automatically handled appropriately: 1. Added recognition for common binary file extensions (.png, .jpg, .jpeg, .gif, .bmp, .wav, .mp3, .mp4) 2. Implemented base64 encoding for binary files, allowing them to be properly represented as strings 3. Improved error handling with more descriptive messages for different file types **Technical Details:** - Created `BINARY_EXTENSIONS` set containing common binary file extensions - Modified `data_to_text()` to check file extensions and use binary mode when appropriate - Added base64 encoding for binary content to ensure proper string representation - Improved error handling with more specific exception messages **Testing:** - Added dedicated test file with tests for both binary and text file handling - Verified with `pytest tests/utils/test_data_to_text.py -q` **Impact:** - Significantly improves robustness when processing mixed file types - Enables applications to handle binary files without separate code paths - Prevents cryptic encoding errors when processing directories with mixed content **Dependencies:** None **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--885.org.readthedocs.build/en/885/ <!-- readthedocs-preview swarms end -->
**Description:** This PR fixes a common Python anti-pattern by replacing mutable default parameters (empty lists) with `None` across multiple swarm structure classes. This prevents the well-known issue where mutable defaults are instantiated once at definition time rather than per function call, which can lead to unexpected behavior and hard-to-debug issues. **Technical Details:** - Changed default parameters from `[]` to `None` in 11 structure classes - Added the pattern `self.agents = agents or []` inside each constructor - Classes updated include: `ConcurrentWorkflow`, `DynamicConversationalSwarm`, `GroupChat`, `InteractiveGroupChat`, `MajorityVoting`, `MALT`, `MixtureOfAgents`, `MultiAgentRouter`, `SequentialWorkflow`, `SpreadsheetSwarm`, and `SwarmRouter` - This follows the Python best practice for handling mutable default arguments **Impact:** - Prevents potential bugs where agent lists could be unexpectedly shared between instances - Makes the code more robust and follows Python best practices - Maintains backward compatibility with all existing code **Issue:** N/A **Dependencies:** None **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--884.org.readthedocs.build/en/884/ <!-- readthedocs-preview swarms end -->
- Add Multiple MCP execution to the agents by fetching a list of mcp urls - Then the agent outputs a function call - Then the function data is parsed, name is found on which server url, and then the tool is executed with the execute_mcp_call function. - then add to agent.md and agent_mcp.md docs - Create examples in the examples docs/examples folder
- Signifcantly improve RAG through a flexible and fluid system - Integrate llama index or pinecone or chromadb and create examples and docs for this - Make it easy to change embedding models and more
{'status': 'ok'} {'detail': '500: An unexpected error occurred: Failed to execute MCP tools sync: This event loop is already running'} ## Problematic code is here - problematic code is here: https://github.com/kyegomez/swarms/blob/master/swarms/tools/mcp_client_call.py ```python import os import requests from dotenv import load_dotenv import json from swarms.utils.formatter import formatter load_dotenv() API_KEY = os.getenv("SWARMS_API_KEY") BASE_URL = "https://swarms-api-285321057562.us-east1.run.app" # BASE_URL = "http://localhost:8080" headers = {"x-api-key": API_KEY, "Content-Type": "application/json"} def run_health_check(): """Check if the API is healthy""" response = requests.get(f"{BASE_URL}/health", headers=headers) return response.json() def run_single_agent(): """Run a single agent with the new AgentCompletion format""" payload = { "agent_config": { "agent_name": "Research Analyst", "description": "An expert in analyzing and synthesizing research data", "system_prompt": ( "You are a Research Analyst with expertise in data analysis and synthesis. " "Your role is to analyze provided information, identify key insights, " "and present findings in a clear, structured format. " "Focus on accuracy, clarity, and actionable recommendations." ), "model_name": "claude-3-5-sonnet-20240620", "role": "worker", "max_loops": 1, "max_tokens": 8192, "temperature": 1, "auto_generate_prompt": False, "tools_list_dictionary": None, "mcp_url": "http://localhost:11434/sse", }, "task": "What are the best ways to find samples of diabetes from blood samples?", # "history": [ # { # "role": "user", # "content": "What are the best ways to find samples of diabetes from blood samples?", # } # ], } response = requests.post( f"{BASE_URL}/v1/agent/completions", headers=headers, json=payload ) return response.json() if __name__ == "__main__": # Check API health health = run_health_check() print(health) # Run single agent agent_result = run_single_agent() print(agent_result) ```
**Description:** This PR adds a new `list-agents` command to the Swarms CLI that displays all agents registered in a YAML configuration file. The command loads agents from the specified YAML file, registers them, and displays their names in a formatted table. Example usage: ```bash python swarms/cli/main.py list-agents --yaml-file examples/cli_examples/agents.yaml ``` Expected output with the provided test file: ``` Registered Agents โโโโโโโโโโโโโโโโ โ Agent Name โ โกโโโโโโโโโโโโโโโฉ โ Test-Agent-1 โ โ Test-Agent-2 โ โโโโโโโโโโโโโโโโ ``` **Implementation Details:** - Added `list_registered_agents()` function in main.py - Added CLI argument handling for the new command - Added "list-agents" to the commands list - Added comprehensive test coverage in test_list_agents.py - Included example YAML file in examples/cli_examples/agents.yaml - Uses the `rich` library for formatted table output **Issue:** NA **Dependencies:** NA [DEMO VIDEO](https://drive.google.com/file/d/1ACVM7qUlH1NJ1YNGZLbmblRWnk4jzeWO/view?usp=sharing) **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--876.org.readthedocs.build/en/876/ <!-- readthedocs-preview swarms end -->
**Description:** This PR adds and improves documentation for telemetry configuration in Swarms. It explains the bootup routine, how to enable or disable telemetry via the `USE_TELEMETRY` environment variable, and details the environment variables set during initialization. The documentation helps users understand how telemetry and logging are managed, and how to control them for their use case. **Issue:** N/A **Dependencies:** N/A **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--874.org.readthedocs.build/en/874/ <!-- readthedocs-preview swarms end -->
**Description:** This PR optimizes the agent inference time by improving the conversation history caching mechanism in the `Conversation` class. The new implementation ensures that repeated stringification of conversation history is cached and reused, significantly reducing redundant computation during agent inference. **Key Changes:** - Refactored `Conversation` to cache the stringified conversation history. - Added a performance benchmark example (conversation_cache_example.py) demonstrating >2x speedup. - Added unit and performance tests: - test_conversation_cache_simple.py (correctness) - test_conversation_cache_perf.py (asserts at least 2x speedup) - Updated internal usage to leverage the new cache for all agent operations. **How the 2x speedup was achieved:** Previously, every call to `get_str()` rebuilt the conversation string from scratch. Now, the string is cached and only rebuilt when the conversation changes. This reduces the time spent in agent `_run` (which calls `get_str()`), resulting in a measured speedup of 2xโ3x in both tests and manual benchmarks. **Files Changed:** - conversation.py (core cache logic) - agent.py (internal usage) - conversation_cache_example.py (demo/benchmark) - test_conversation_cache_simple.py (unit test) - test_conversation_cache_perf.py (performance test) [**Demo Video** ](https://drive.google.com/file/d/1MWTorBB1pbIA48DMxiw1mgKJl9PQb--z/view?usp=sharing) **Issue:** Closes #848 **Dependencies:** N/A **Tag maintainer:** @kyegomez <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--864.org.readthedocs.build/en/864/ <!-- readthedocs-preview swarms end -->
**Describe the bug** We need to enable the llm to output multiple function calls and execute multiple mcp tools all at once **To Reproduce** ```python from swarms import Agent from swarms.schemas.mcp_schemas import MCPConnection mcp_config = MCPConnection( url="http://0.0.0.0:8000/sse", # headers={"Authorization": "Bearer 1234567890"}, timeout=5, ) mcp_url = "http://0.0.0.0:8000/sse" # Initialize the agent agent = Agent( agent_name="Financial-Analysis-Agent", agent_description="Personal finance advisor agent", # system_prompt=FINANCIAL_AGENT_SYS_PROMPT, max_loops=1, mcp_url=mcp_url, # mcp_config=mcp_config, output_type="all", ) # Create a markdown file with initial content out = agent.run( "Fetch the price for bitcoin on both functions get_htx_crypto_price and get_crypto_price", ) print(out) ```
Updates the requirements on [transformers](https://github.com/huggingface/transformers) to permit the latest version. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/huggingface/transformers/releases">transformers's releases</a>.</em></p> <blockquote> <h1>Patch release v4.52.3</h1> <p>We had to protect the imports again, a series of bad events. Here are the two prs for the patch:</p> <ul> <li>Fix tp error when torch distributed is already initialized (<a href="https://redirect.github.com/huggingface/transformers/issues/38294">#38294</a>) by <a href="https://github.com/SunMarc"><code>@โSunMarc</code></a></li> <li>Protect ParallelInterface (<a href="https://redirect.github.com/huggingface/transformers/issues/38262">#38262</a>) by <a href="https://github.com/ArthurZucker"><code>@โArthurZucker</code></a> and <a href="https://github.com/LysandreJik"><code>@โLysandreJik</code></a></li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/huggingface/transformers/commit/f4fc42216cd56ab6b68270bf80d811614d8d59e4"><code>f4fc422</code></a> v 4.52.3</li> <li><a href="https://github.com/huggingface/transformers/commit/48459c97d72d0d787058e836d965a5eb86b3b165"><code>48459c9</code></a> Fix tp error when torch distributed is already initialized (<a href="https://redirect.github.com/huggingface/transformers/issues/38294">#38294</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/597e1591458d56bc34bc3a973a4d09ff88fecb72"><code>597e159</code></a> Protect ParallelInterface (<a href="https://redirect.github.com/huggingface/transformers/issues/38262">#38262</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/237c7c356cce5f8a6befc0a5f71bc952bb5adc9a"><code>237c7c3</code></a> update kenlm</li> <li><a href="https://github.com/huggingface/transformers/commit/55f6c7fd2c871bf68bb7314734009d673031166c"><code>55f6c7f</code></a> Clearer error on import failure (<a href="https://redirect.github.com/huggingface/transformers/issues/38257">#38257</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/723563d8fd697f5cb325d0ae27286262d3ad3498"><code>723563d</code></a> tp plan should not be NONE (<a href="https://redirect.github.com/huggingface/transformers/issues/38255">#38255</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/9df95ec4fc4c048b6867f3c24628ea503673a69d"><code>9df95ec</code></a> Relase: 4.52.2</li> <li><a href="https://github.com/huggingface/transformers/commit/945727948c1143a10ac6f7d811aa58bb0d126b5b"><code>9457279</code></a> Release: v4.52.1</li> <li><a href="https://github.com/huggingface/transformers/commit/eaa301673a0a7a1a8c5d3f11c046d1592a7ae16b"><code>eaa3016</code></a> Revert parallelism temporarily (<a href="https://redirect.github.com/huggingface/transformers/issues/38240">#38240</a>)</li> <li><a href="https://github.com/huggingface/transformers/commit/b5f494632c0fff2527dd3140423408644a9b0076"><code>b5f4946</code></a> Protect ParallelInterface</li> <li>Additional commits viewable in <a href="https://github.com/huggingface/transformers/compare/v4.39.0...v4.52.3">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> <!-- readthedocs-preview swarms start --> ---- ๐ Documentation preview ๐: https://swarms--852.org.readthedocs.build/en/852/ <!-- readthedocs-preview swarms end -->
**Description:** This PR implements a robust solution for fully saving, loading, and restoring `Agent` objects, including all non-serializable properties (`tokenizer`, `long_term_memory`, `logger_handler`, `agent_output`, `executor`): - Adds a helper module (`agent_non_serializable.py`) with dummy fallback classes and restoration logic, now using LiteLLMโs tokenizer if available. - Integrates restoration into the `Agent` class, ensuring all non-serializable properties are reliably restored after loading (with safe fallbacks if needed). - Implements custom `__getstate__` and `__setstate__` methods for safe serialization/deserialization. - Updates the user-facing example (agent_save_load_full.py) to clearly demonstrate the full save/load/restore cycle and confirm agent usability post-restore. **Issue:** Fixes #640 **Dependencies:** No new dependencies. **Maintainer:** @kyegomez **Demo Video:** [ISSUE 640 FIX](https://drive.google.com/file/d/1VOVydbf-vDu3dGaNP-ZWF9S6qwEaorKy/view?usp=sharing)
Goal: accelerate the agent inference time by atleast 2x by optimizing the _run