feat: Implement configuration-driven agent creation#1
Open
sidpan1 wants to merge 1 commit into
Open
Conversation
This commit introduces a new system for defining and loading agents
and their capabilities via YAML configuration files.
Key features and changes:
- **Pydantic Models for Configuration:**
New models (`RootConfig`, `LlmAgentConfig`, `SequentialAgentConfig`,
`ParallelAgentConfig`, `ToolReferenceConfig`) are defined in
`src/google/adk/config/models.py` to represent the YAML structure.
- **Configuration Loader & Agent Factory:**
`src/google/adk/config/loader.py` provides `load_configuration`
which parses the main YAML, loads specified capability libraries (also YAML),
and uses an `AgentFactory` to instantiate the defined agents.
The factory resolves capability references and recursively builds agent
hierarchies.
- **Flexible Agent Definitions:**
- Agents can be of different types (LLM, Sequential, Parallel).
- Agents can be defined inline within a parent agent's
configuration or referenced by name from a top-level agent definition,
allowing for reusable agent components.
- LLM agents can be configured with models, instructions, capabilities,
output keys (for state sharing), and output schemas.
- **Capability Library Configuration:**
Capability libraries can be defined in separate YAML files, specifying
data sources, individual capabilities (e.g., SQLite capabilities), and capability sets.
The loader currently supports a structure similar to existing ADK
capability YAMLs.
- **Sample Implementation:**
A comprehensive sample is provided in `samples/configurable_agents/`:
- `config.yaml`: Demonstrates various agent types, hierarchy,
agent referencing (inline and by name), and capability usage.
- `sample_tools.yaml`: Defines sample SQLite capabilities and a capability set.
- `sample_db.sqlite`: A small SQLite database for the sample capabilities.
- **Basic Integration Test:**
`tests/integration/config/test_config_loading.py` includes a test
to verify that the sample configuration can be loaded successfully.
- **Documentation:**
`samples/configurable_agents/README.md` provides detailed
documentation on the YAML schema for agents and capabilities, usage examples,
and how to load configurations programmatically.
This feature significantly enhances the flexibility and manageability of
creating and deploying agents within the ADK framework.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit introduces a new system for defining and loading agents and their capabilities via YAML configuration files.
Key features and changes:
Pydantic Models for Configuration: New models (
RootConfig,LlmAgentConfig,SequentialAgentConfig,ParallelAgentConfig,ToolReferenceConfig) are defined insrc/google/adk/config/models.pyto represent the YAML structure.Configuration Loader & Agent Factory:
src/google/adk/config/loader.pyprovidesload_configurationwhich parses the main YAML, loads specified capability libraries (also YAML), and uses anAgentFactoryto instantiate the defined agents. The factory resolves capability references and recursively builds agent hierarchies.Flexible Agent Definitions:
Capability Library Configuration: Capability libraries can be defined in separate YAML files, specifying data sources, individual capabilities (e.g., SQLite capabilities), and capability sets. The loader currently supports a structure similar to existing ADK capability YAMLs.
Sample Implementation: A comprehensive sample is provided in
samples/configurable_agents/:config.yaml: Demonstrates various agent types, hierarchy, agent referencing (inline and by name), and capability usage.sample_tools.yaml: Defines sample SQLite capabilities and a capability set.sample_db.sqlite: A small SQLite database for the sample capabilities.Basic Integration Test:
tests/integration/config/test_config_loading.pyincludes a test to verify that the sample configuration can be loaded successfully.Documentation:
samples/configurable_agents/README.mdprovides detailed documentation on the YAML schema for agents and capabilities, usage examples, and how to load configurations programmatically.This feature significantly enhances the flexibility and manageability of creating and deploying agents within the ADK framework.