ISAA (Intelligent System Agent Architecture) Module Documentation¶
Version: 0.2.0
1. Overview¶
The ISAA module provides a comprehensive framework for building, managing, and orchestrating AI agents. It leverages the EnhancedAgent
and EnhancedAgentBuilder
for creating sophisticated agents with capabilities like tool use, code execution, web interaction, and persistent memory. The module is designed to be extensible and configurable, allowing developers to create complex multi-agent systems and automated workflows.
Key features include:
* Advanced Agent System: Based on EnhancedAgent
for robust and production-ready agents.
* Flexible Agent Configuration: Uses EnhancedAgentBuilder
for fluent and detailed agent setup.
* Task Chain Management: Define and execute sequences of agent actions or tool uses.
* Interactive Code Execution Pipelines: Stateful Python execution environments for agents.
* Semantic Memory: Persistent knowledge storage and retrieval using AISemanticMemory
.
* Tool Integration: Supports ADK-compatible tools, custom functions, and has provisions for LangChain tools.
* Asynchronous Operations: Many core functionalities are async
for better performance.
2. Core Concepts¶
2.1. EnhancedAgent
¶
The EnhancedAgent
is the primary agent class in ISAA. It integrates:
* LiteLLM: For interaction with a wide range of LLMs.
* ADK (Agent Development Kit): For structured tool use, planning, and code execution (if ADK is available and configured).
* A2A (Agent-to-Agent): For inter-agent communication (if A2A is available).
* MCP (Model Context Protocol): For exposing agent capabilities (if MCP is available).
* World Model: A dictionary-like persistent state for the agent.
* Cost Tracking: Built-in user cost tracking.
* Callbacks: For streaming, progress, and post-run actions.
2.2. EnhancedAgentBuilder
¶
The EnhancedAgentBuilder
provides a fluent API to configure and construct EnhancedAgent
instances. Key aspects:
* Configuration Model (BuilderConfig
): A Pydantic model that holds all serializable configurations for an agent. This can be saved to and loaded from JSON.
* Model Configuration: Specify LLM model, API keys (via env vars), temperature, etc.
* Behavior: Streaming, logging, initial world model data.
* Framework Integrations: Enable and configure ADK, A2A, MCP.
* Tool Management: Add ADK tools (including wrapped functions).
* Cost Tracking: Configure persistence for user costs.
* Telemetry: Configure OpenTelemetry.
3. Initialization and Configuration (Tools
Class)¶
The Tools
class is the main entry point for interacting with the ISAA module.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
3.1. Configuration (isaa.config
)¶
The isaa.config
dictionary holds various settings:
* DEFAULTMODEL*
: Default LLM model identifiers for different agent types (e.g., DEFAULTMODEL0
, DEFAULTMODELCODE
). These can be overridden by environment variables.
* agents-name-list
: A list of registered agent names.
* controller_file
: Path to the JSON file for ControllerManager
(LLM modes).
* Other internal states and paths.
API keys (like OPENAI_API_KEY
, GEMINI_API_KEY
, etc.) are typically loaded from environment variables by LiteLLM or explicitly set in the EnhancedAgentBuilder
via with_api_key_from_env()
.
3.2. isaa.on_exit()
¶
Called when the application or module shuts down. It saves:
* Agent builder configurations (BuilderConfig
dicts from isaa.agent_data
).
* ControllerManager
state.
* AgentChain
definitions.
* Scripts
definitions.
* ISAA Tools
class configuration.
4. Agent Management¶
All agent management functions are now primarily async
.
4.1. Getting an Agent Builder (async get_agent_builder
)¶
This method returns a pre-configured EnhancedAgentBuilder
instance.
1 2 3 4 5 6 7 8 9 10 11 |
|
runAgent
, memorySearch
, searchWeb
, and shell
.
4.2. Registering an Agent (async register_agent
)¶
Once an EnhancedAgentBuilder
is configured, its configuration can be registered with ISAA. The agent instance itself will be built on demand.
1 2 3 4 5 6 |
|
.data/app_id/Agents/my_query_agent.agent.json
) and stores the config dictionary in isaa.agent_data
.
4.3. Retrieving an Agent Instance (async get_agent
)¶
This async
method retrieves (and builds if necessary) an EnhancedAgent
instance.
1 2 3 4 5 6 7 8 9 |
|
isaa.config['agent-instance-{name}']
.
5. Running Agents and Tasks¶
5.1. Running an Agent (async run_agent
)¶
This is the primary method to interact with a registered agent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
run_agent
method now calls the EnhancedAgent.a_run()
method, which supports features like session-based history, world model updates, ADK tool execution, etc.
5.2. Mini Task Completion (async mini_task_completion
)¶
For quick, one-off LLM calls without full agent capabilities.
1 2 3 4 5 6 |
|
5.3. Structured Output (async format_class
)¶
To get LLM output structured according to a Pydantic model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
6. Task Chains¶
Task chains allow defining a sequence of operations involving agents or tools.
6.1. Defining a Task Chain¶
Task chains are defined as lists of dictionaries, where each dictionary represents a task.
The TaskChain
Pydantic model from toolboxv2.mods.isaa.types
can be used for validation.
Example structure for a task in the list:
1 2 3 4 5 6 |
|
6.2. Creating a Task Chain (async crate_task_chain
)¶
Uses an LLM (typically "TaskChainAgent") to generate a task chain definition from a natural language prompt.
1 2 3 4 5 6 7 8 9 |
|
6.3. Managing Task Chains¶
isaa.add_task(chain_name, task_definition_list)
: Manually add/update a chain.isaa.get_task(chain_name)
: Get the definition of a chain.isaa.list_task()
: List names of all available chains.isaa.save_task(chain_name=None)
: Save one or all chains to file.isaa.load_task(chain_name=None)
: Load one or all chains from file.
6.4. Running a Task Chain (async run_task
)¶
Executes a defined task chain.
1 2 3 4 5 6 7 8 |
|
ChainTreeExecutor
handles variable injection ($variable_name
, $user-input
) and result passing between tasks.
7. Pipelines for Code Execution (Pipeline
Class)¶
The Pipeline
class (from toolboxv2.mods.isaa.CodingAgent.live
) provides a stateful environment for agents to execute Python code iteratively. It uses a mock IPython interface.
7.1. Getting a Pipeline Instance (async get_pipe
)¶
Retrieves or creates a Pipeline
instance associated with a specific ISAA agent. The agent's context (variables, potentially its LLM for thinking within the pipeline) can influence the pipeline's behavior.
1 2 3 4 5 6 7 8 9 |
|
7.2. Running a Pipeline (async run_pipe
)¶
Executes a task within the pipeline. The agent associated with the pipeline will "think" and generate code or actions to be executed by the pipeline's IPython environment.
1 2 3 4 5 6 7 8 9 10 11 |
|
Pipeline.run
method involves multiple turns of the agent thinking, generating code/actions, and the pipeline executing them, until the task is marked "done" or iterations are exhausted.
8. Semantic Memory (AISemanticMemory
)¶
ISAA uses AISemanticMemory
for persistent, semantic storage and retrieval of information.
8.1. Accessing Memory (isaa.get_memory
)¶
1 2 3 4 5 6 |
|
8.2. Interacting with Memory¶
The AISemanticMemory
class (and its underlying KnowledgeBase
instances) provides methods like:
* async add_data(memory_name: str, data: ..., metadata: ...)
: Adds data to a specific memory space.
* async query(query: str, memory_names: ..., to_str: bool)
: Queries one or more memory spaces.
* async unified_retrieve(...)
: A more comprehensive retrieval method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
EnhancedAgent
instances often have their world model, but can also interact with AISemanticMemory
via tools for broader knowledge. ChatSession
(used by Pipeline
) also uses AISemanticMemory
.
9. Tool Integration¶
9.1. Default ISAA Tools¶
Agents created with get_agent_builder
automatically get several tools:
* runAgent
: To call other registered ISAA agents.
* memorySearch
: To query the AISemanticMemory
.
* saveDataToMemory
: To save data into the agent's context in AISemanticMemory
.
* searchWeb
: Uses WebScraper
to search the internet.
* shell
: Executes shell commands using shell_tool_function
.
* runCodePipeline
(for agents like "self", "code"): To invoke a Pipeline
task.
These are added as ADK-compatible function tools to the EnhancedAgentBuilder
.
9.2. Adding Custom and LangChain Tools (async init_tools
)¶
The init_tools
method is intended for adding external tools, particularly LangChain tools, to an agent builder.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
args_schema
) into ADK FunctionTool
s (which prefer simpler schemas or Pydantic models for arguments) can be non-trivial. init_tools
will need careful implementation to handle schema mapping or require tools to be provided as simple callables.
10. Example Usage Flow¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
11. Important Notes¶
- Asynchronous Nature: Most core methods of the
Tools
class are nowasync
. Ensure your calling code usesawait
appropriately or runs within an asyncio event loop. - Agent Configuration: Agent capabilities are primarily defined by their system message, the tools provided to them via the
EnhancedAgentBuilder
, and their underlying LLM model. - Error Handling: Robust error handling should be implemented around
async
calls, especially for network-dependent operations like LLM calls or web interactions. - ADK Integration: Full ADK functionality (planning, advanced tool schemas, long-running operations) requires Google ADK to be installed and properly configured. The
EnhancedAgentBuilder
provides methods likewith_adk_code_executor
,with_adk_tool_instance
, etc. - Security: Be cautious when enabling code execution (
unsafe_simple
executor is for development only) or shell access.
This documentation provides a starting point for using the refactored ISAA module. As the module evolves, further details on specific component interactions (e.g., advanced ADK planner configurations, A2A/MCP server setup via builder) will be crucial.