You can incrementally build your AI Agent in Agent Lab and keep track of development work by saving the configuration of the core components of the agent.
When you save your agent configuration, you can choose to save it as different asset types. Saving your work as an asset makes it possible to share your work with collaborators in the current project.
Asset type | When to use this asset type | What is saved | How to retrieve the asset |
---|---|---|---|
Agent asset | When you create an agent that generates the results you want using a combination of a specific model and a set of tools and want to reuse the agent. | The agent name and description, foundation model and related parameter settings, quick start questions, instructions for the model, and tools used by the agent.
Note: The output that is generated by the agent is not saved as part of the Agent asset.
|
From the Saved agents tab in Agent Lab |
Standard notebook asset | When you want to work with agents programmatically, but want to start from the Agent Lab interface for a better agent development experience. | The foundation model and related parameter settings, and tools used by the agent are formatted as Python code and stored as a Python notebook. | From the Assets page of the project |
Deployment notebook | When your agent can do advanced functions such as search grounding documents for answers to questions from a chat and you want to deploy the function as an AI service. | A deployable AI service that can be consumed by REST APIs. | From the Assets page of the project |
Each of these asset types is available from the project's Assets page. Project collaborators with the Admin or Editor role can open and work with the assets. Your agent asset is locked automatically if you open it in Edit mode which prevents other users from using it. You can access the agent asset in Preview mode without locking it.
Saving your agent development work
To save your agent development work, complete the following steps:
-
From the header of the agent editor, click the Save work icon , and then click Save as.
-
Choose an asset type.
If you choose to create a deployable Gen AI flow notebook, you must associate the agent with a deployment space. For more information, see Deployment spaces.
-
Name the asset, and then optionally add a description.
-
Click Save.
Working with agents saved in a notebook
When you save your work as a notebook asset, a Python notebook is built.
To work with an agent notebook asset, follow the procedure for your notebook type.
Standard notebook
-
Open the notebook asset from the Assets tab of your project.
-
Click the Edit icon to instantiate the notebook so you can step through the code.
The notebook contains runnable code that manages the following steps for you:
- Authenticates with the service.
- Defines a Python class.
- Defines the selected foundation model and its parameters, a set of tools, and instructions to be used to create the agent.
- Creates and runs the agent by pairing it with a question as input to generate a response.
-
Use the notebook as is, or change it to meet the needs of your use case.
The Python code that is generated by using the Agent Lab executes successfully. You must test and validate any changes that you make to the code.
Deployment notebook
-
Open the notebook asset from the Assets tab of your project.
-
Click the Edit icon to instantiate the notebook so you can step through the code.
The notebook contains runnable code that manages the following steps for you:
- Authenticates with the service.
- Connects to the target space and promotes the assets so that their data can be accessed from the AI service.
- Defines the AI service to be deployed. This includes code to create the agent, formats the input for the agent, and runs the agent to generate responses.
- Tests the AI service locally.
- Deploys the AI service to the target space.
- Tests the deployed AI service.
-
Use the notebook as is, or change it to meet the needs of your use case.
The Python code that is generated by using the Agent Lab executes successfully. You must test and validate any changes that you make to the code.
-
The AI service deployed by the notebook can be consumed using a REST API. The following is an example cURL request to call your deployment:
curl --location '${PUBLIC_ENDPOINT}' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ${IAM_TOKEN}' \ --data '{ \ "messages": [{$MESSAGES}] }'
where
- PUBLIC_ENDPOINT is the public endpoint of your deployment. See Creating online deployments.
- IAM_TOKEN is the authentication token to access IBM Cloud services. See Credentials for programmatic access. The access token that you use must be associated with the same account as the project that is referenced in the notebook.
- MESSAGES is an array of the chat history text entries with the following schema:
{ "role": type, // "user" or "assistant" "content": content // The text content of the message }
For details about how to deploy and inference AI services, see Deploying AI services with tools.
Working with saved agent assets
To continue working with a saved agent, open it from the Saved agents tab of the Agent Lab.
When you open a saved agent, Autosave is on, which means that any changes you make to the agent will be reflected in the saved agent asset. If you want the agent that you saved to remain unchanged, click New agent to start creating a new agent.
Parent topic: Agent Lab