Skip to content

Orchestration pattern/magentic - #18

Draft
Mamorri wants to merge 26 commits into
developfrom
orchestration-pattern/magentic
Draft

Orchestration pattern/magentic#18
Mamorri wants to merge 26 commits into
developfrom
orchestration-pattern/magentic

Conversation

@Mamorri

@Mamorri Mamorri commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Magentic is a peer-workflow orchestration mode.

In agent-as-tool, MADA creates a visible PlanningAgent, exposes specialists as tools, and keeps a reusable planner session. In magentic, MADA creates the configured specialist agents as peers, then creates a hidden manager agent that coordinates a fresh Magentic workflow for each request. The hidden manager is not listed as a participant and its planning/progress chatter is filtered so users receive the final assistant answer.

To enable it in a workflow config, set the top-level orchestration.mode:

  {
    "orchestration": {
      "mode": "magentic",
      "participants": ["JobManagementAgent", "InverseDesignAgent"]
    }
  }
  • Agent-as-tool process_message now runs the planning agent once, using the isolated/copied run_session, then commits that completed session as before.
  • Magentic process_message now builds the candidate transcript in memory, runs the workflow first, and only persists the user/assistant turn after success. Isolated Magentic runs use a fresh transcript.

@Mamorri
Mamorri requested review from bgunnar5 and jmoreno45 August 3, 2026 22:36
@Mamorri Mamorri self-assigned this Aug 3, 2026
@Mamorri Mamorri added the enhancement New feature or request label Aug 3, 2026

@bgunnar5 bgunnar5 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This magentic pattern will be really cool to try out.

I notice that the strategy classes and the Orchestrator are weirdly intertwined and having to make lots of calls to each other in a circular manner. This is a bit difficult to keep track of and I'm wondering if a refactor of this code would help. Maybe some things could even just be moved to the BaseStrategy class to help with this? I'm not sure what's best.


Now that your agents are connected, you're free to start entering prompts into the chat box!

If your configuration uses `magentic` orchestration, the Gradio interface still shows the active specialist agents in the table. The hidden Magentic manager is not displayed as a participant, and only the final assistant answer is streamed back into the chat UI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so users will only see the final agent's response, they won't see anything in between? Is this common for the magentic setup? It feels like having a trace of work between all agents would be useful

Comment thread docs/user_guide/configuration.md Outdated
### How Agent Configuration Works

When MADA starts, it reads the agent configuration and loads each agent by executing the specified server path Python file. The functions decorated with `@mcp.tool` within these scripts become the MCP tools that MADA can call during a session. Agents communicate within a group chat, and the [planning agent](#the-planning-agent) coordinates which helper agent should handle each user request.
When MADA starts, it reads the agent configuration and creates the selected specialist agents. Each specialist can connect to named MCP servers from the `mcp_servers` block, or use the legacy `server_path` setting for a directly launched stdio MCP server. MADA then runs the configured orchestration mode: `agent-as-tool` exposes specialists as tools to a visible planning agent, while `magentic` coordinates specialists in a peer group chat through a hidden manager.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when discussing different orchestration modes, I think we should make this a bulleted list so that it can easily be extended

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and updated the doc structure


```python
--8<-- "src/mada/core/orchestrator.py:200:203"
--8<-- "src/mada/core/orchestrator.py:549:552"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially implemented this as a source file reference but now I'm wondering if we should just copy/paste the base instructions here seeing as the orchestrator file likely has the most updates out of any file in this codebase.


```python
--8<-- "src/mada/core/orchestrator.py:212:216"
--8<-- "src/mada/core/orchestrator.py:561:565"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to previous comment about code reference

Comment thread docs/user_guide/index.md
## What is MADA?

MADA is a framework designed to facilitate collaboration between multiple specialized agents within a unified system. Built on top of the autogen framework, MADA orchestrates a [planning agent](./configuration.md#the-planning-agent) that interprets user input and delegates tasks to relevant helper agents. These agents communicate within a group chat environment, enabling dynamic problem-solving and task execution. MADA provides an intuitive interface for users to interact with the agent group, either through the command-line interface or a Gradio-based web interface, streamlining complex workflows and enhancing automation capabilities.
MADA is a framework designed to facilitate collaboration between multiple specialized agents within a unified system. Built on the Agent Framework, MADA supports an `agent-as-tool` mode where a [planning agent](./configuration.md#the-planning-agent) delegates tasks to relevant specialists, and a `magentic` mode where specialists participate in a peer group chat coordinated by a hidden manager. MADA provides CLI, Gradio, and OpenAI-compatible interfaces for interacting with the configured agent team.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a high-level overview, maybe we should just mention that MADA supports different orchestration modes, link to the orchestration configuration docs, and generalize this paragraph a bit more. This will scale better than having to expand on this each time we add a new orchestration mode.

Comment thread docs/user_guide/index.md
MADA begins by reading your [configuration](./configuration.md), which specifies the [model](./configuration.md#model-configuration), the [agents](./configuration.md#agent-configuration), and the optional [orchestration mode](./configuration.md#optional-orchestration-configuration). If you are using the [Gradio run mode](./usage/index.md#gradio-mode-overview), you can also provide [interface](./configuration.md#optional-gradio-interface-configuration) settings for customizing the Gradio web application UI.

After the group chat is established, MADA waits for user input. When a prompt is received, a [planning agent](./configuration.md#the-planning-agent)—added to the group chat automatically—interprets the input and selects the appropriate helper agent to handle the request using an mcp tool call. The helper agent’s response is streamed back to the user through the chosen interface. This interactive process continues until the session ends, either after 10 messages or when the user enters "TERMINATE".
After orchestration is initialized, MADA waits for user input. In `agent-as-tool` mode, the planning agent selects the appropriate specialist by calling that specialist as a tool. In `magentic` mode, the hidden manager coordinates a fresh peer workflow and returns the final synthesized answer. Responses are streamed back through the chosen interface.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to my generalization comment

Comment on lines 18 to +24
DEFAULT_ORCHESTRATION_MODE = "agent-as-tool"
SUPPORTED_ORCHESTRATION_MODES = frozenset({DEFAULT_ORCHESTRATION_MODE})
SUPPORTED_ORCHESTRATION_MODES = frozenset(
{
DEFAULT_ORCHESTRATION_MODE,
"magentic",
}
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on how well this works, we should consider switching the default to be magentic. Since we know agent-as-tool works already this is fine for now though

return value


class MagenticOrchestrationStrategy(AgentAsToolOrchestrationStrategy):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be inheriting from AgentAsTool or the BaseStrategy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored much more code into the base strategy, so there is no more nested dependency, as intended.
class MagenticOrchestrationStrategy(BaseOrchestrationStrategy):

)

return MagenticBuilder(
participants=orchestrator.specialist_agents,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this specialist list already be filtered based on the user's orchestration block settings in their config file by the time we get here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants