## AG2 Shell Tool Integration: Command Execution and Multi-Tool DevOps Orchestration

AG2's shell tool integration with OpenAI's Responses API enables agents to execute shell commands directly, unlocking powerful automation capabilities for filesystem operations, build processes, and system diagnostics. Combined with the apply_patch tool, you can orchestrate complete DevOps pipelines—from project creation to deployment validation—all within a single agent workflow.

This article explores how to leverage AG2's built-in tools for command execution, file operations, and multi-tool orchestration, with practical examples for automating development workflows and building production-ready DevOps pipelines.

## AG2 Event Logging: Standardized Observability with Python Logging

AG2 now integrates with Python's standard `logging` module for event output, giving you full control over how agent events are captured, formatted, and processed. This integration brings enterprise-grade observability directly into your agent workflows.

This article explores how to configure and customize AG2 event logging, with practical examples for testing, monitoring, and production deployments.

## GPT-5.1 Apply Patch Tool: Automated Code Editing in AG2

AG2 now supports the **apply_patch** tool (from GPT-5.1 onward) through OpenAI's Responses API, enabling agents to create, update, and delete files using structured diffs. This integration brings precise, controlled file operations directly into your agent workflows.

This article explores how to use apply_patch in AG2, with practical examples for automated code editing, project scaffolding, and multi-file refactoring.

### What is Apply Patch?

The `apply_patch` tool is a built-in capability in GPT-5.1 and above models that enables agents to perform structured file operations using unified diff format. Unlike traditional code generation approaches where agents output raw code blocks that you must manually integrate, apply_patch provides a standardized interface for file modifications that can be directly applied to your codebase.

The tool handles three core operations: 
- **create_file**: Generate new files with specified content 
- **update_file**: Modify existing files using unified diff format 
- **delete_file**: Remove files from the workspace

## A2A Protocol Support in AG2 v0.10

AG2 v0.10 introduces native support for the [Agent2Agent (A2A) Protocol](https://a2a-protocol.org/latest/), enabling agents to communicate across different processes, frameworks, and languages through a standardized interface.

This article walks through implementing A2A in AG2, with a focus on practical patterns for building distributed agent systems.

### What is A2A?

A2A is a JSON-RPC 2.0 protocol over HTTP(S) for agent-to-agent communication. It provides a framework-agnostic interface that allows agents built with different tools (AG2, LangGraph, CrewAI, Semantic Kernel, Pydantic AI, etc.) to communicate without custom integration code.

The protocol handles: 
- Task delegation and execution 
- Bidirectional communication between agents 
- Authentication and security 
- Observability and monitoring

## Cascadia AI Hackathon Winner: Dino Park Meets AG2

#### Cascadia AI Hackathon Winner: Dino Park Meets AG2

Last weekend at the Cascadia AI Hackathon in Seattle, developers showed off what's possible with multi-agent systems.

The prize for Best Use of AG2 went to Jeff Linwood, who built a dinosaur park simulation game where rangers, guests, and even the dinosaurs themselves are represented as AI agents orchestrated in a swarm.

Jeff reflected on the experience:

"I got a chance to work on some fun tech and build out a ridiculous dinosaur-themed simulation game using AI-based NPCs. I ended up winning the prize for best use of the AG2 agentic framework!"

We loved seeing AG2 power such a creative and playful project — and we're excited to see what else the open-source community will build next.

👏 Huge congrats Jeff, and thanks to Carter Rabasa and the Cascadia AI organizers for bringing this community together.

## From Reasoning to Evaluation: Advanced ReAct Loops

#### From Reasoning to Evaluation: Advanced ReAct Loops for Multi-Agent Essay Evaluation

[ReAct](https://www.promptingguide.ai/techniques/react) is a powerful prompting technique in prompt engineering. The ability to Reason and then Act based on that reasoning (e.g. execute a tool call) and subsequently observe the result before proceeding to the next step gives engineers the flexibility to embed complex workflows by chaining multiple actions (and re-actions).

ReAct Loops enhances this by allowing the agent to iteratively perform a set of tasks while providing it with the autonomy to decide what to do next and when to break out.

However, implementing a reliable ReAct loop in a production environment can be challenging. The inherently non-deterministic nature of LLM outputs and iterations may produce inaccurate outputs or even never-ending loops, leading to unexpected API costs.

This article explores a real-world multi-agent workflow designed to evaluate student essays, showcasing the implementation of advanced ReAct loops within a collaborative agentic system.

We introduce a scenario in which a multi-agent system collaboratively evaluates student-submitted essays, using advanced ReAct loops to emulate nuanced grading behavior.

For this we create the following agents:

**Student (representative agent):** An agent to represent the student (the student's essay), who can intelligently and descriptively answer questions by reading and understanding the essay's content.

**Examiner:** An examiner agent that evaluates student essays using a predefined set of grading criteria.

**Evaluator:** A scorer agent that evaluates the responses provided by the student representative to the examiner's questions and determines a final score using a structured scoring rubric.

**Group chat moderator:** This agent will moderate the group chat but will not influence the logic executed within the system.

The architecture of the agentic workflow is illustrated below.

For each essay we initiate a new group chat.

**Note:** The ReAct loop runs within the group-chat for each evaluation.

This article also explores various agent roles and their functions during the evaluation and scoring process. For example:

### Student Agent

```python
from autogen import ConversableAgent, GroupChat, GroupChatManager

essay = get_essay_content()  # Retrieve the essay content from its source

system_message = f"""You are an agent representing a student. You have access to the following essay content: {essay}.

Your task is to answer questions about the essay strictly based on information found in the essay content.

Instructions:

Analysis of the essay
- Carefully analyze the essay for the following:
Does the essay meaningfully engage with ethical considerations?
Are issues like fairness, bias, equity, accessibility, or unintended consequences addressed?
Does the exploration consider multiple perspectives thoughtfully, or does it present a simplistic or biased viewpoint?

Answering questions from the examiner:
- Provide descriptive answers based on the essay content,
- Use only the essay content. Do not fabricate or make up any answers or descriptions that do not reflect the essay content.
- If you cannot find any information relevant to the question in the essay content, simply say 'I cannot see that point being addressed in the essay'.
"""

agent = ConversableAgent(
    name="Student", # You can derive the student name and assign it here as well, but there is an ethical consideration in doing so
    system_message=system_message,
    description="Student representative, answers questions based on a student essay",
    llm_config=llm_config_gpt_4o
)
```

### Examiner Agent:

```python
questions = get_examination_questions()  # Retrieve the list of questions for the examiner

examiner = ConversableAgent(
    name="Examiner",
    system_message=f"""I am an examiner who will cross-examine an agent representing a student.

Actions:
- I will ask all the questions starting from the beginning, one-by-one in order.
- I will not skip any questions.
- I will ensure that I state 'Examination Complete - [EVALUATOR_START]' before ending the conversation.
""",
    description="Examiner, examines the essay using a list of questions that address a specific set of criteria.",
    is_termination_msg=lambda x: "EVALUATION-END" in (x.get("content", "") or "").upper(),
    human_input_mode="NEVER",
    llm_config=llm_config_gpt_4o
)
```

### Evaluator Agent:

```python
evaluation_criteria = get_evaluation_criteria()  # Retrieve the evaluation criteria
scoring_rubric = get_scoring_rubric()  # Retrieve the scoring rubric

evaluator = ConversableAgent(
    name="Evaluator",
    system_message=f"""You are an agent who evaluates a student essay based on an examination conducted between an examiner and a representative agent on behalf of a student.

Actions:
1. Evaluate the essay using the criteria: {evaluation_criteria}
2. Compute a score on a scale of 100 based on your evaluation using the scoring rubric: {scoring_rubric}.

response_format:
### EVALUATION-START ###
### evaluation-summary-start ### <Detailed evaluation> ### evaluation-summary-end ###
### score-start ### <numeric score> ### score-end ###
### EVALUATION-END ###
""",
    description="Evaluator, Evaluates the essay based on the answers provided and the student",
    llm_config=llm_config_gpt_4o
)
```

### Initiating the group chat

The following code snippet defines the allowed transitions, creates the group chat, sets up the group chat manager, and initiates the examination.

```python
allowed_transitions = {
    examiner: [student, examiner],
    student: [examiner],
    examiner: [evaluator],
    evaluator: []
}

group_chat = GroupChat(
    agents=[examiner, student, evaluator],
    messages=[],
    max_round=100,
    send_introductions=True,
    allowed_or_disallowed_speaker_transitions=allowed_transitions,
    speaker_transitions_type="allowed",
)

group_chat_manager = GroupChatManager(
    name="Chat_Manager",
    groupchat=group_chat,
    llm_config=llm_config_gpt_4o,
)

# Start the examination
examination = examiner.initiate_chat(
    group_chat_manager,
    message="I am starting the examination",
    summary_method=my_summary_method
)
```

The overall approach ensures accurate and nuanced evaluations, providing insights into how to set up conversational agents effectively.
