Files
openhuman/tests
Steven EnamakelandGitHub 3a20599f45 feat: dynamic connected integrations in agent system prompts (#520)
* feat(agent): add support for connected integrations in system prompts

- Introduced a new `fetch_connected_integrations` method to retrieve and populate active Composio integrations for the agent.
- Updated the `Agent` struct to include a `connected_integrations` field, allowing the system prompt to display available external services.
- Enhanced the `build_system_prompt` method to incorporate connected integrations, improving the context provided to users during interactions.
- Added a `ConnectedIntegrationsSection` to the prompt rendering, ensuring visibility of active integrations in the system prompt output.
- Overall, these changes enhance the agent's ability to leverage connected services, improving user experience and interaction capabilities.

* feat(debug_dump): integrate connected integrations into agent prompt dumps

- Added a new `fetch_connected_integrations_for_dump` function to retrieve active integrations for the agent during prompt dumps.
- Updated the `render_main_agent_dump` function to include connected integrations, enhancing the context provided in the debug output.
- Improved the overall structure and clarity of the debug dump process, ensuring that connected integrations are accurately represented in the agent's prompt context.

* refactor(agent): streamline integration fetching for system prompts

- Refactored the `fetch_connected_integrations` method in the `Agent` struct to delegate integration fetching to a new centralized function in the `composio` module, enhancing code clarity and maintainability.
- Updated the `fetch_connected_integrations_for_dump` function to utilize the new centralized fetching logic, ensuring consistent integration retrieval across different contexts.
- Improved the overall structure of integration handling, allowing for better error management and logging during the fetching process.

* feat(agent): add connected integrations support to parent execution context

- Introduced a new field `connected_integrations` in the `ParentExecutionContext` struct to store active Composio integrations.
- Updated relevant functions to utilize the new `connected_integrations` field, ensuring that system prompts and agent dumps reflect the current integrations.
- Enhanced the integration cache management by implementing cache invalidation logic when connections are created or deleted, improving the accuracy of integration data across sessions.
- Overall, these changes enhance the agent's ability to leverage connected services, providing users with better context during interactions.

* feat(agent): initialize connected integrations in subagent context

- Added a `connected_integrations` field to the `ParentExecutionContext` and `Agent` struct, allowing for the storage and retrieval of active Composio integrations.
- Updated the `dispatch_target_agent` function to populate the `connected_integrations` field when creating a new sub-agent context.
- Enhanced the `fetch_connected_integrations` method to return an `Option<Vec<ConnectedIntegration>>`, improving error handling and caching logic.
- These changes improve the agent's ability to manage and utilize connected integrations, enhancing user interactions and context awareness.

* refactor(agent): improve caching logic in fetch_connected_integrations

- Updated the `fetch_connected_integrations` function to handle caching more effectively by using a match statement.
- The function now caches results only when the backend is reachable, preventing unnecessary caching when the client is unavailable.
- This change enhances error handling and ensures that subsequent calls with different configurations can retry without stale data.

* style: apply cargo fmt formatting

* feat(agent): enhance connected integrations handling and caching

- Updated the `dispatch_target_agent` function to initialize connected integrations for sub-agents, ensuring they have access to the latest integrations.
- Improved the caching mechanism for connected integrations by using a `HashMap` keyed by configuration identity, allowing for user-specific caching and better isolation of integration data.
- Refactored the `invalidate_connected_integrations_cache` function to clear the entire cache instead of setting it to `None`, enhancing cache management.
- Added a new method `load_from_default_paths` in the `Config` struct to reliably load user configurations without being affected by environment variable overrides, improving the debug dump process.
- Enhanced the rendering of connected integrations in system prompts to provide clearer instructions based on available tools, improving user interaction clarity.

* feat(agent): add method to set connected integrations

- Introduced a new `set_connected_integrations` method in the `Agent` struct to allow for replacing the agent's connected integrations from external sources, enhancing flexibility in integration management.
- Updated the caching mechanism for connected integrations to utilize `LazyLock`, improving initialization efficiency and thread safety.

* style: apply cargo fmt
2026-04-12 18:37:01 -07:00
..