Migration · 1.4
AG2 1.4.0 removes APIs deprecated in 1.3 and changes some configuration defaults. Use this guide to update your code before upgrading.
Before upgrading:
- On AG2 1.3, run
pytest -W error::DeprecationWarning, or add-W error::DeprecationWarningto the Python command that runs your tests. - Search your code for the names and arguments below, and run your type checker. Warnings alone miss some uses, including
Agent(..., tasks=False),agent.tasks,TaskConfig, andOpenAIConfig(...)orconfig.copy(...)calls that do not reachcreate(). - Check your installed Anthropic SDK version separately; AG2 1.3 did not warn about the 1.x to 2.x upgrade.
| 1.3 use | 1.4 action |
|---|---|
OpenAIConfig selecting Chat Completions | OpenAICompletionsConfig, or OpenAIConfig / OpenAIResponsesConfig for the Responses API |
temperature, top_p, top_k on AnthropicConfig | Remove these arguments; the API rejects them |
anthropic 1.x | anthropic>=2,<3 |
google-genai 2.x | google-genai>=3.2,<4 |
Agent(assembly=...) | middleware=[Middleware(AssemblerMiddleware, ...), Middleware(HaltCheckMiddleware)] |
Agent(knowledge=KnowledgeConfig(...)) | plugins=[KnowledgePlugin(...)] |
Agent(tasks=TaskConfig(...)), Agent.tasks, run_subtask / run_subtasks | Worker Agents exposed through Agent.as_tool() |
Agent.task() | Task(owner_id=agent.name, spec=TaskSpec(...)) |
OpenAIConfig is the Responses API#
OpenAIConfig is now an alias for OpenAIResponsesConfig. If your code needs Chat Completions, including for a compatible server that only serves /chat/completions, use OpenAICompletionsConfig.
If your app passes WAV or MP3 audio bytes as user input (BinaryInput), keep OpenAICompletionsConfig with an audio-capable model. The Responses mapper rejects audio BinaryInput before sending a request, even when the configuration uses only named options.
For example, a Chat Completions configuration written in the 1.3 style, OpenAIConfig(model="gpt-6.2-sol", max_completion_tokens=1024), can be migrated in either of these ways:
GPT-6.2 Sol supports both APIs, but agents using tools must choose Responses. See OpenAI's GPT-6.2 guidance.
OpenAIConfig raises TypeError for Chat Completions-only keyword arguments. When moving to Responses, translate max_completion_tokens to max_output_tokens and reasoning_effort to reasoning. See Model Configuration.
Before replacing OpenAIConfig, find calls that pass options without parameter names. Name those options according to the 1.3 signature, then switch to OpenAICompletionsConfig to keep Chat Completions or translate them for Responses. A positional call may still run in 1.4 but use different settings; the TypeError above catches only removed keyword arguments.
In 1.4, OpenAIConfig requests response storage by default (store=True). If you do not want AG2 to request storage, set OpenAIConfig(model="gpt-6.2-sol", store=False). In 1.3, OpenAIConfig left store unset on Chat Completions requests.
Anthropic SDK 2.x and sampling parameters#
ag2[anthropic] requires anthropic>=2.0.0,<3. 1.3 did not warn about this, so check pip show anthropic and upgrade with pip install -U "anthropic>=2,<3".
AnthropicConfig no longer accepts temperature, top_p or top_k. Remove them; the Messages API rejects these options.
If you pass AnthropicConfig options positionally, rewrite them as named arguments using the 1.3 signature before removing temperature, top_p and top_k. A call that still runs after the upgrade can otherwise use different settings.
google-genai 3.x#
ag2[gemini] requires google-genai>=3.2,<4. Upgrade with pip install -U "google-genai>=3.2,<4". Developer API requests now go to v1 by default; set api_version="v1beta" for the -latest aliases and the -preview models that exist only there. See Gemini API Version and HTTP Client.
Context policies: assembly=#
HaltCheckMiddleware is needed only with AlertPolicy. Policies added by plugins or add_policy() still join the agent's assembler. See Assembly.
Knowledge: knowledge=#
Every other KnowledgeConfig field moves unchanged into KnowledgePlugin. One difference: the plugin's store is a dependency default, so dependencies={KnowledgeStore: other} on the Agent or on ask() now replaces it. See Agent Harness.
Delegation: tasks=TaskConfig(...)#
Build the worker explicitly and give the parent its delegate tool. Set the worker's config, prompt and tools explicitly; those settings do not come from the parent. Dependencies flow separately: request values passed to ask(dependencies=...) override the worker's configured dependencies, while the parent's configured dependencies fill keys the worker has not configured. Eligible scoped variables also propagate. For example, a per-request KnowledgeStore override can reach the worker.
Prompts that named run_subtask or run_subtasks must name the delegate tool (task_worker above). The subagent migration guide maps every TaskConfig field and explains how to cap concurrency without max_concurrency.
Tasks: Agent.task()#
Use dict(payload) when your code may change the original mapping after creating the task; this keeps the task's top-level payload values unchanged, as in 1.3. A fresh literal needs no copy. context, ttl_seconds, checkpoint_store and resume_from are Task arguments; description, payload and capability belong to TaskSpec. See Tasks.