Use a Agent Development Kit agent

In addition to the general instructions for using an agent, this page describes features that are specific to AdkApp.

Before you begin

This tutorial assumes that you have read and followed the instructions in:

Supported operations

The following operations are supported for AdkApp:

To list all supported operations, run the following command:

import pprint

pprint.pprint(remote_app.operation_schemas())

Manage sessions

AdkApp uses cloud-based managed sessions after you deploy the agent to Vertex AI Agent Engine. This section describes how to use managed sessions.

Create a session

To create a session for a user:

session = remote_app.create_session(user_id="USER_ID")

where USER_ID is a user-defined ID with a character limit of 128.

List sessions

To list the sessions for a user:

remote_app.list_sessions(user_id="USER_ID")

where USER_ID is a user-defined ID with a character limit of 128.

Get a session

To get a specific session, you need both the user ID and the session ID:

session = remote_app.get_session(user_id="USER_ID", session_id="SESSION_ID")

Delete a session

To delete a session, you need both the user ID and the session ID:

remote_app.delete_session(user_id="USER_ID", session_id="SESSION_ID")

Stream a response to a query

To stream responses from an agent in a session:

for event in remote_app.stream_query(
    user_id="USER_ID",
    session_id="SESSION_ID",  # Optional
    message="What is the exchange rate from US dollars to SEK today?",
):
   print(event)

What's next