Skip to content

Agent Config Changes modified as per adk python - #104

Merged
manojkumarredbus merged 1 commit into
redbus-labs:mainfrom
chhitiz-t:main
Dec 23, 2025
Merged

Agent Config Changes modified as per adk python#104
manojkumarredbus merged 1 commit into
redbus-labs:mainfrom
chhitiz-t:main

Conversation

@chhitiz-t

Copy link
Copy Markdown

Feature: Configuration Agent Loading Refactor & Hot-Reload

This Pull Request introduces a significant refactoring of the configuration-based agent loading system to strictly align with established Python ADK patterns. The primary goals are to enhance extensibility, optimize resource usage, and add crucial hot-reloading support for configuration changes.

Key Architectural Changes

| AgentLoader (Interface) | dev/web | Extended interface for better cache management and resource cleanup. |
| ConfigAgentLoader | maven_plugin | New, complete configuration-based implementation handling hot-reloading and lazy access. |
| ConfigAgentWatcher | maven_plugin | Dedicated file watcher for monitoring configuration directory changes. |

-- Detailed Changes and Improvements

1. AgentLoader Interface Enhancements

The base interface has been extended to support crucial cache management and lifecycle methods, inspired by the Python ADK:

  • hasAgent(String name): Checks for agent existence (default implementation provided).
  • removeAgentFromCache(String name): Removes a specific agent instance, forcing a reload on next access (aligned with Python ADK cache invalidation).
  • stop(): Provides a cleanup mechanism for resources (e.g., stopping the file watcher).

2. ConfigAgentLoader Implementation

This is the core new class, implementing robust configuration loading:

  • Hot-Reloading Support: Automatically detects changes in YAML files, ensuring agents are reloaded dynamically without a service restart.
  • Performance: Implements Lazy Loading with Memoization—agents are loaded and initialized only upon their first request and then cached.
  • Cache Management API: Provides methods for granular control:
    • removeAgentFromCache()
    • forceReload()
    • forceReloadAll()
  • Reload Callbacks: Introduces setOnAgentsReloadedCallback() to notify external systems when configurations are reloaded (mirroring the Python ADK's runners_to_clean pattern).
  • Extensibility: Uses protected methods allowing subclasses to easily override default behavior for agent discovery, loading logic, and watcher configuration.
  • Robustness: Includes tracking for agents that fail to load, preventing repeated loading attempts.

3. ConfigAgentWatcher (New Component)

This new thread-safe utility manages filesystem monitoring:

  • Configuration Monitoring: Recursively scans configured agent directories for files ending in .yaml or .yml.
  • Polling: Operates on a dedicated, daemon polling thread at configurable intervals (default: 2 seconds).
  • Change Detection: Efficiently detects new, modified, and deleted configuration files.
  • Extensibility: Protected methods allow for custom overriding of directory scanning and file detection logic.

Design Inspiration

This refactoring strictly adheres to established patterns from the Python ADK, specifically:

  • AgentLoader and Cache Invalidation: The core loading logic and removeAgentFromCache method.
  • agent_change_handler.py: The inspiration for the file watching, thread management, and the setOnAgentsReloadedCallback notification system.
  • Extensibility: Architected around inheritance and protected methods to simplify future customization and extension.

@manojkumarredbus
manojkumarredbus merged commit bcf7e04 into redbus-labs:main Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants