By default, if llm_config is not specified, a default configuration
will be created using the provided model and api_type.
If runnable_builder is not specified, a default runnable builder will
be used, configured with the system_instruction, runnable_name and
runnable_kwargs.
Parameters
Name
Description
model
str
Required. The name of the model (e.g. "gemini-1.0-pro"). Used to create a default llm_config if one is not provided. This parameter is ignored if llm_config is provided.
runnable_name
str
Required. The name of the runnable. This name is used as the default runnable_kwargs["name"] unless runnable_kwargs already contains a "name", in which case the provided runnable_kwargs["name"] will be used.
api_type
str
Optional. The API type to use for the language model. Used to create a default llm_config if one is not provided. This parameter is ignored if llm_config is provided.
llm_config
Mapping[str, Any]
Optional. Configuration dictionary for the language model. If provided, this configuration will be used directly. Otherwise, a default llm_config will be created using model and api_type. This llm_config is used as the default runnable_kwargs["llm_config"] unless runnable_kwargs already contains a "llm_config", in which case the provided runnable_kwargs["llm_config"] will be used.
system_instruction
str
Optional. The system instruction for the agent. This instruction is used as the default runnable_kwargs["system_message"] unless runnable_kwargs already contains a "system_message", in which case the provided runnable_kwargs["system_message"] will be used.
runnable_kwargs
Mapping[str, Any]
Optional. Additional keyword arguments for the constructor of the runnable. Details of the kwargs can be found in https://docs.ag2.ai/docs/api-reference/autogen/ConversableAgent. runnable_kwargs only supports human_input_mode="NEVER". Other human_input_mode values will trigger a warning.
runnable_builder
Callable[..., "ConversableAgent"]
Optional. Callable that returns a new runnable. This can be used for customizing the orchestration logic of the Agent. If not provided, a default runnable builder will be used.
tools
Sequence[Callable[..., Any]]
Optional. The tools for the agent to be able to use. All input callables (e.g. function or class method) will be converted to a AG2 tool . Defaults to None.
enable_tracing
bool
Optional. Whether to enable tracing in Cloud Trace. Defaults to False.
Optional. The maximum number of turns to run the agent for. If not provided, the agent will run indefinitely. If max_turns is a float, it will be converted to int through rounding.
set_up
set_up()
Sets up the agent for execution of queries at runtime.
It initializes the runnable, binds the runnable with tools.
This method should not be called for an object that being passed to
the ReasoningEngine service for deployment, as it initializes clients
that can not be serialized.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class AG2Agent (1.95.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.95.1 (latest)](/python/docs/reference/vertexai/latest/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.94.0](/python/docs/reference/vertexai/1.94.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.93.1](/python/docs/reference/vertexai/1.93.1/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.92.0](/python/docs/reference/vertexai/1.92.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.91.0](/python/docs/reference/vertexai/1.91.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.90.0](/python/docs/reference/vertexai/1.90.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.89.0](/python/docs/reference/vertexai/1.89.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.88.0](/python/docs/reference/vertexai/1.88.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.87.0](/python/docs/reference/vertexai/1.87.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.86.0](/python/docs/reference/vertexai/1.86.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.85.0](/python/docs/reference/vertexai/1.85.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.84.0](/python/docs/reference/vertexai/1.84.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.83.0](/python/docs/reference/vertexai/1.83.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.82.0](/python/docs/reference/vertexai/1.82.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.81.0](/python/docs/reference/vertexai/1.81.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.80.0](/python/docs/reference/vertexai/1.80.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.79.0](/python/docs/reference/vertexai/1.79.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.78.0](/python/docs/reference/vertexai/1.78.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.77.0](/python/docs/reference/vertexai/1.77.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.76.0](/python/docs/reference/vertexai/1.76.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.75.0](/python/docs/reference/vertexai/1.75.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.74.0](/python/docs/reference/vertexai/1.74.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.73.0](/python/docs/reference/vertexai/1.73.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.72.0](/python/docs/reference/vertexai/1.72.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.71.1](/python/docs/reference/vertexai/1.71.1/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.70.0](/python/docs/reference/vertexai/1.70.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.69.0](/python/docs/reference/vertexai/1.69.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.68.0](/python/docs/reference/vertexai/1.68.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.67.1](/python/docs/reference/vertexai/1.67.1/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.66.0](/python/docs/reference/vertexai/1.66.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.65.0](/python/docs/reference/vertexai/1.65.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.63.0](/python/docs/reference/vertexai/1.63.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.62.0](/python/docs/reference/vertexai/1.62.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.60.0](/python/docs/reference/vertexai/1.60.0/vertexai.preview.reasoning_engines.AG2Agent)\n- [1.59.0](/python/docs/reference/vertexai/1.59.0/vertexai.preview.reasoning_engines.AG2Agent) \n\n AG2Agent(\n model: str,\n runnable_name: str,\n *,\n api_type: typing.Optional[str] = None,\n llm_config: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n system_instruction: typing.Optional[str] = None,\n runnable_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n runnable_builder: typing.Optional[typing.Callable[[...], ConversableAgent]] = None,\n tools: typing.Optional[typing.Sequence[typing.Callable[[...], typing.Any]]] = None,\n enable_tracing: bool = False\n )\n\nAn AG2 Agent.\n\nSee \u003chttps://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/develop/ag2\u003e\nfor details.\n\nMethods\n-------\n\n### AG2Agent\n\n AG2Agent(\n model: str,\n runnable_name: str,\n *,\n api_type: typing.Optional[str] = None,\n llm_config: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n system_instruction: typing.Optional[str] = None,\n runnable_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n runnable_builder: typing.Optional[typing.Callable[[...], ConversableAgent]] = None,\n tools: typing.Optional[typing.Sequence[typing.Callable[[...], typing.Any]]] = None,\n enable_tracing: bool = False\n )\n\nInitializes the AG2 Agent.\n\nUnder-the-hood, assuming .set_up() is called, this will correspond to \n\n # runnable_builder\n runnable = runnable_builder(\n llm_config=llm_config,\n system_message=system_instruction,\n **runnable_kwargs,\n )\n\nWhen everything is based on their default values, this corresponds to \n\n # llm_config\n llm_config = {\n \"config_list\": [{\n \"project_id\": initializer.global_config.project,\n \"location\": initializer.global_config.location,\n \"model\": \"gemini-1.0-pro-001\",\n \"api_type\": \"google\",\n }]\n }\n\n # runnable_builder\n runnable = ConversableAgent(\n llm_config=llm_config,\n name=\"Default AG2 Agent\"\n system_message=\"You are a helpful AI Assistant.\",\n human_input_mode=\"NEVER\",\n )\n\nBy default, if `llm_config` is not specified, a default configuration\nwill be created using the provided `model` and `api_type`.\n\nIf `runnable_builder` is not specified, a default runnable builder will\nbe used, configured with the `system_instruction`, `runnable_name` and\n`runnable_kwargs`.\n\n### clone\n\n clone() -\u003e vertexai.preview.reasoning_engines.templates.ag2.AG2Agent\n\nReturns a clone of the AG2Agent.\n\n### query\n\n query(\n *,\n input: typing.Union[str, typing.Mapping[str, typing.Any]],\n max_turns: typing.Optional[int] = None,\n **kwargs: typing.Any\n ) -\u003e typing.Dict[str, typing.Any]\n\nQueries the Agent with the given input.\n\n### set_up\n\n set_up()\n\nSets up the agent for execution of queries at runtime.\n\nIt initializes the runnable, binds the runnable with tools.\n\nThis method should not be called for an object that being passed to\nthe ReasoningEngine service for deployment, as it initializes clients\nthat can not be serialized."]]