Przejdź do treści
Biblioteka skilli
AI i agenci · Budowanie i kod

ag2

/ag2

Pomaga budować agentów AI i systemy wieloagentowe w AG2 (dawniej AutoGen), z narzędziami, zatwierdzaniem przez człowieka i wykonywaniem kodu, oraz migrować kod z AutoGen i pyautogen.

Repozytorium
skills ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
25.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
3
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Pomaga budować agentów AI i systemy wieloagentowe w AG2 (dawniej AutoGen), z narzędziami, zatwierdzaniem przez człowieka i wykonywaniem kodu, oraz migrować kod z AutoGen i pyautogen.

Oryginalny opis (EN)

AG2 (formerly AutoGen) is an open-source Python framework for building AI agents and multi-agent systems that use tools, human approval and structured conversations. Use it when you need agents that call functions, collaborate in a group chat, execute code, or when you are migrating AutoGen or pyautogen code to AG2 v1 or ag2-classic.

Jak działa

  1. Overview
  2. Instructions
  3. Examples
  4. Guidelines
Sekcje z nagłówków SKILL.md, w oryginale · 133 linii, 874 słów
Podgląd SKILL.md
---
name: ag2
description: >-
  AG2 (formerly AutoGen) is an open-source Python framework for building AI
  agents and multi-agent systems that use tools, human approval and structured
  conversations. Use it when you need agents that call functions, collaborate
  in a group chat, execute code, or when you are migrating AutoGen or
  pyautogen code to AG2 v1 or ag2-classic.
license: Apache-2.0
compatibility: Python 3.10+, an API key for the chosen model provider
metadata:
  author: terminal-skills
  version: 1.1.0
  category: data-ai
  repository: https://github.com/ag2ai/ag2
  tags: "multi-agent, autogen, orchestration, python, agents"
---

# AG2 (AutoGen) — Multi-Agent Conversation Framework

## Overview

AG2 is the community continuation of Microsoft's AutoGen. Since **v1.0** (current: 1.1.1, September 2026) it is a new, async-first framework and is **not backward compatible** with classic AutoGen:

| You see in code | You have | Install |
|---|---|---|
| `from ag2 import Agent`, `from ag2.config import OpenAIConfig` | AG2 v1 | `pip install "ag2[openai]"` |
| `from autogen import ConversableAgent, GroupChat, UserProxyAgent` | classic AutoGen / AG2 0.x | `pip install ag2-classic` (its README also shows `autogen[openai]`) |

Classic is in maintenance mode (security fixes only). Do not mix the two APIs in one file. Provider extras for v1: `ag2[openai]`, `ag2[anthropic]`, `ag2[gemini]`, `ag2[ollama]` and others. Docs: https://docs.ag2.ai (v1) and https://classic.docs.ag2.ai (classic).

## Instructions

### AG2 v1: an agent with a tool

```python
import asyncio
from ag2 import Agent, tool
from ag2.config import OpenAIConfig      # also AnthropicConfig, GeminiConfig, OllamaConfig, ...


@tool
async def count_lines(path: str) -> str:
    """Count the lines in a source file inside the current project."""
    with open(path, encoding="utf-8") as f:
        return f"{path}: {sum(1 for _ in f)} lines"


reviewer = Agent(
    "reviewer",
    prompt="You review Python code. Use tools to inspect files before judging them.",
    config=OpenAIConfig("gpt-4o-mini"),   # key is read from OPENAI_API_KEY
    tools=[count_lines],
)


async def main() -> None:
    reply = await reviewer.ask("How big is app/main.py?")
    print(reply.body)
    follow_up = await reply.ask("Is that too large for one module?")  # keeps the history
    print(follow_up.body)


asyncio.run(main())
```

- `agent.ask(...)` returns a reply; `reply.body` is the text and `reply.ask(...)` continues the same conversation.
- A tool is a typed function with a docstring decorated with `@tool`; the signature and docstring become the schema the model sees.
- Stream or observe a turn with `async with agent.run("...") as run: run.start(); async for event in run.stream...` and `await run.result()`.
- Human approval: pass `hitl_hook=` to `Agent`; it receives a `HumanInputRequest` (from `ag2.events`) and returns a `HumanMessage(content=...)`.
- Test without an LLM: `from ag2.testing import TestConfig` and pass `TestConfig("scripted reply")` (or `ToolCallEvent`s) as `config`.

### AG2 v1: several agents

v1 replaces `GroupChat`, swarm and nested chats with a **Network**: a `Hub` registers agents, and they talk over typed channels (`conversation` for free two-party chat, `consulting` for one question and one answer, `discussion` for round-robin among N agents, `workflow` for a `TransitionGraph` of conditional handoffs, the closest analogue to GroupChat). Read the group-chat migration guide on docs.ag2.ai before writing this part; the classes live in `ag2.network` (`Hub`, `Channel`, `TransitionGraph`, `Handoff`).

### Classic AutoGen (`ag2-classic`): two agents and group chat

Only for existing code that imports `autogen`.

```python
from autogen import ConversableAgent, LLMConfig, UserProxyAgent, register_function
from autogen.agentchat import run_group_chat
from autogen.agentchat.group.patterns import AutoPattern

llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")   # key from OPENAI_API_KEY

engineer = ConversableAgent(
    name="engineer",
    system_message="You write clean, tested Python. Explain design decisions briefly.",
    llm_config=llm_config,
)
runner = UserProxyAgent(
    name="runner",
    human_input_mode="NEVER",              # NEVER / ALWAYS / TERMINATE
    max_consecutive_auto_reply=10,
    is_termination_msg=lambda m: "TERMINATE" in (m.get("content") or ""),
    code_execution_config={"work_dir": "workspace", "use_docker": True},
)
result = runner.initiate_chat(engineer, message="Write a FastAPI /health endpoint with a pytest test.", max_turns=6)

reviewer = ConversableAgent(name="reviewer", system_message="You review code for bugs and security issues.", llm_config=llm_config)
pattern = AutoPattern(
    agents=[engineer, reviewer],
    initial_agent=engineer,
    group_manager_args={"name": "manager", "llm_config": llm_config},
)
response = run_group_chat(pattern=pattern, messages="Build a rate limiter for our API.", max_rounds=12)
```

Tools in classic: `register_function(fn, caller=engineer, executor=runner, description="...")`. The caller proposes the call, the executor runs it. Classic also has `LLMConfig.from_json(path="OAI_CONFIG_LIST")` for a config file. Only the register and `run_group_chat` calls above were checked against the classic README; check other classic details at classic.docs.ag2.ai.

## Examples

### Example 1: Single agent that inspects a repository

**User request:** "Make me an AG2 agent that can count lines in files and answer questions about them."

Install with `python -m venv .venv && .venv/bin/pip install "ag2[openai]"`, save the v1 code above as `reviewer.py`, set `OPENAI_API_KEY` in the environment and run `.venv/bin/python reviewer.py`. The agent calls `count_lines` for `app/main.py`, then prints a sentence such as "app/main.py has 212 lines". The follow-up question reuses the same history.

### Example 2: Unit-test an agent without calling an LLM

**User request:** "I want to test my AG2 tool wiring in CI without an API key."

```python
from ag2 import Agent
from ag2.events import ToolCallEvent
from ag2.testing import TestConfig

config = TestConfig(
    ToolCallEvent(name="count_lines", arguments='{"path": "app/main.py"}'),
    "app/main.py has 212 lines",
)
agent = Agent("reviewer", prompt="Use tools.", config=config, tools=[count_lines])
reply = await agent.ask("How big is app/main.py?")
assert "212" in reply.body
```

The scripted model requests the tool, AG2 runs the real `count_lines`, and the scripted second turn is the answer. Each `ask` consumes scripted turns, so supply enough for follow-ups.

## Guidelines

- Check which API a file uses (`ag2` vs `autogen` imports) before editing; v1 and classic are different libraries.
- Keep keys in environment variables, never in code or a committed `OAI_CONFIG_LIST`.
- Give each agent a narrow prompt and only the tools it needs; vague prompts produce unfocused loops.
- Always bound loops: `max_turns` / `max_rounds` and `max_consecutive_auto_reply` in classic, and watch token usage in group chats.
- Classic code execution runs model-written code: keep `use_docker: True`, and never point `work_dir` at a real project.
- Require human approval (`hitl_hook` in v1, `human_input_mode="ALWAYS"` or `"TERMINATE"` in classic) before irreversible actions.
- Do not migrate a working classic system to v1 unprompted; v1 is a rewrite of orchestration, not a version bump.
Pliki w paczce (2)
  • SKILL.md 7 KB
  • _scores.json 3 KB

Wersje

W bazie nie ma innych skilli o nazwie ag2.

Migawka bazy z 28.10.2026 · wersja paczki 112b4a3534ae (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100microsoft-agent-framework
    Pomaga budować agentów AI i przepływy wieloagentowe w Microsoft Agent Framework w Pythonie i .NET oraz migrować z agentów Semantic Kernel.
  • 100autogen
    Buduje konwersacyjne systemy wieloagentowe w Microsoft AutoGen: AssistantAgent, UserProxyAgent, GroupChat, wykonywanie kodu, zagnieżdżone czaty, narzędzia i MCP.
  • 100crewai-and-autogen-multi-agent-frameworks
    Prowadzi budowę systemów wieloagentowych we frameworkach opartych na rolach, CrewAI (crew, task, process) i Microsoft AutoGen (agenty konwersacyjne), także przy wyborze między nimi.
  • 100agent-architecture-patterns
    Pomaga wybrać architekturę agenta LLM lub systemu wieloagentowego, na przykład ReAct, Reflexion, Router, Supervisor, LangGraph, AutoGen czy CrewAI.
  • 100a2a-framework-integration
    Łączy protokół A2A z frameworkami agentowymi, takimi jak Google ADK, LangGraph, CrewAI i AutoGen, do komunikacji między agentami.
  • 100trace-multi-agent-system
    Dodaje obserwowalność do systemów wielu agentów: drzewo spanów z wywołań agentów, narzędzi i przekazań, by wiedzieć, który agent zawiódł.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.