Skip to content

fix: enhance agent creation logic to reuse existing agents across Chart, Conversation, Search, and SQL factories#669

Merged
Avijit-Microsoft merged 2 commits into
devfrom
psl-pk-agentcheck
Dec 2, 2025
Merged

fix: enhance agent creation logic to reuse existing agents across Chart, Conversation, Search, and SQL factories#669
Avijit-Microsoft merged 2 commits into
devfrom
psl-pk-agentcheck

Conversation

@Pavan-Microsoft

Copy link
Copy Markdown
Contributor

Purpose

This pull request refactors the agent factory classes to optimize agent creation and improve logging. The main change is that each factory now checks for an existing agent with the expected name before creating a new one, ensuring agent reuse and reducing resource duplication. Additionally, logging is standardized and improved across all agent factories for better traceability and error handling.

Agent creation logic improvements:

  • All agent factories (ChartAgentFactory, SQLAgentFactory, SearchAgentFactory, and ConversationAgentFactory) now attempt to find and reuse an existing agent with the expected name before creating a new one, reducing unnecessary agent creation. [1] [2] [3] [4]
  • If agent listing fails (e.g., due to an exception), the factories log a warning and proceed to create a new agent. [1] [2] [3] [4]

Logging enhancements:

  • Added logging imports and initialized loggers in all agent factory files to standardize logging. [1] [2] [3] [4]
  • Added informative log messages for agent reuse and agent creation, including agent names and IDs. [1] [2] [3] [4]
  • Improved error logging in thread deletion for ConversationAgentFactory by replacing print statements with logger.error.

Documentation updates:

  • Updated docstrings in agent factory classes to clarify that agents are reused if they already exist and only created if not found. [1] [2] [3] [4]

Consistency improvements:

  • Standardized agent naming conventions using formatted strings based on solution_name across all factories. [1] [2] [3] [4]

Error handling:

  • Added exception handling around agent listing in all factories to ensure robust agent creation even if listing fails. [1] [2] [3] [4]

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

…art, Conversation, Search, and SQL factories
@Avijit-Microsoft
Avijit-Microsoft merged commit a2b248c into dev Dec 2, 2025
5 checks passed
@Pavan-Microsoft
Pavan-Microsoft deleted the psl-pk-agentcheck branch December 3, 2025 12:42
@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.16.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants