Skip to content
eugennPublic

About

One multi-agent pipeline, four frameworks: NOOA, Microsoft Agent Framework, LangChain and CrewAI side by side.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

nooa-demo — one multi-agent pipeline, four frameworks

This repository is a side-by-side comparison of NOOA (NVIDIA-labs OO Agents, nooa) against three other agent frameworks: Microsoft Agent Framework, LangChain, and CrewAI.

The point of the comparison is not benchmarking speed or answer quality. It is to show the same multi-agent pipeline — identical personas, identical prompts, identical order of operations — expressed four times, so that what is framework ceremony and what is actual application logic becomes visible. Every script produces the same artifact: a panel-reviewed piece of 9th-grade workbook content.

Script Framework What is idiomatic there
nooa_demo.py NOOA (NVIDIA) Agents are Python classes; docstrings are prompts, type annotations are the output contract, and @strategy(...) picks the execution mode
agent_framework_demo.py Microsoft Agent Framework Agents are objects built from instructions + a ChatClient; the panel is a SequentialBuilder orchestration
lang_chain_demo.py LangChain Everything is a prompt | model Runnable; structured output via with_structured_output
crewai_demo.py CrewAI Agents are role/goal/backstory triples; the panel is a sequential Crew where each Task sees the previous ones through context

Table of contents


Providers and models

All four scripts use exactly two providers, and they split the work the same way:

Agent Provider Default model
ContentWriter and its subclasses (HistoryWriter, PhysicsWriter) Gemini gemini-3.6-flash
Everything else — task assigner, all five panel reviewers, the secretary, the orchestrators OpenAI gpt-4o-mini

Both models are overridable via environment variables, but note the two different id formats:

Script Client GEMINI_MODEL format
nooa_demo.py, crewai_demo.py LiteLLM-backed gemini/gemini-3.6-flash — the gemini/ prefix selects the provider
lang_chain_demo.py, agent_framework_demo.py ChatGoogleGenerativeAI / GeminiChatClient gemini-3.6-flash — the provider is already fixed by the client class

OPENAI_MODEL is a bare model id (gpt-4o-mini) everywhere.

Three model instances are built per script:

llm        = build_openai_llm(temperature=0.2)  # reviewers, secretary, orchestrators
router_llm = build_openai_llm(temperature=0.0)  # the task assigner: routing must be deterministic
writer_llm = build_gemini_llm(temperature=0.2)  # the content writers

Each script fails fast at import time if either OPENAI_API_KEY or GEMINI_API_KEY is missing.


Installation

Python 3.12 or 3.13 is required — that is NOOA's supported range (requires-python = ">=3.12,<3.14").

python3.12 -m venv .venv
source .venv/bin/activate

Installing NOOA

NOOA is published on PyPI as nooa:

pip install nooa

With uv, which is what the upstream project uses:

uv add nooa

Optional subsystems ship as extras (or as standalone distributions of the same name):

pip install "nooa[cli,memory,bench]"
Extra / package What it adds
nooa-cli Trace viewer and eval runner
nooa-memory The MemoryManager subsystem
nooa-bench BenchAgent and the Harbor benchmark

None of the extras are needed for this repository — plain nooa is enough.

To track the development branch instead of a release:

pip install "nooa @ git+https://github.com/NVIDIA-NeMo/labs-OO-Agents.git@main"

NOOA pulls in LiteLLM, which is how it reaches both providers used here. Model selection goes through get_llm_client(), which accepts any LiteLLM-supported model string:

from nooa.unifiedllm import get_llm_client

llm = get_llm_client("gpt-4o-mini", temperature=0.2)              # OPENAI_API_KEY
llm = get_llm_client("gemini/gemini-3.6-flash", temperature=0.2)  # GEMINI_API_KEY

Keys are read from the process environment by LiteLLM, so keys.env (loaded via python-dotenv at the top of each script) is all the configuration there is.

Installing the other frameworks

The demos are independent — install only what you intend to run.

# Microsoft Agent Framework demo
pip install -r requirements.txt

# LangChain demo
pip install langchain langchain-core langchain-openai langchain-google-genai

# CrewAI demo
pip install crewai

# Shared by every demo
pip install python-dotenv pydantic

requirements.txt pins the Microsoft Agent Framework stack only (agent-framework, agent-framework-gemini, python-dotenv, pydantic). The OpenAI client used by that demo, agent_framework.openai.OpenAIChatClient, arrives transitively: agent-framework depends on agent-framework-core[all], which includes agent-framework-openai.


Configuration (keys.env)

Each script searches three locations, in order, and loads the first file that exists — the parent directory of the script, ../keys.env, then keys.env in the current working directory. Existing environment variables win (override=False).

OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...

# Optional overrides
OPENAI_MODEL=gpt-4o-mini
GEMINI_MODEL=gemini-3.6-flash        # use gemini/gemini-3.6-flash for the nooa and crewai demos

Running the demos

python nooa_demo.py
python agent_framework_demo.py
python lang_chain_demo.py
python crewai_demo.py

Every script is a single async def main() driven by asyncio.run. nooa_demo.py, lang_chain_demo.py and crewai_demo.py walk through the pipeline piece by piece — first routing, then a bare draft, then the panel, then the full desk — so the intermediate output is visible. agent_framework_demo.py runs the pipeline end to end and prints only the final content.

Expect a dozen or more LLM calls per run: five reviewers plus a secretary is six calls for a single panel pass, and the scripts run the panel more than once.


The agent pipeline

The scenario: a school curriculum desk produces content for a 9th-grade workbook. A question comes in, the desk decides who should answer it, that writer drafts an answer, a review panel of five stakeholders with conflicting agendas critiques the draft, a secretary reconciles their comments into concrete instructions, and the original writer rewrites accordingly.

                    question
                       │
                       ▼
              ┌─────────────────┐
              │  TaskAssigner   │  OpenAI, temperature 0.0
              │  → Assignment   │  structured: {writer, reason}
              └────────┬────────┘
             HISTORIAN │ PHYS_WRITER
                 ┌─────┴─────┐
                 ▼           ▼
        ┌────────────────────────────┐
        │ HistoryWriter │ PhysicsWr. │  Gemini, temperature 0.2
        │        .draft(question)    │
        └─────────────┬──────────────┘
                      │ draft
                      ▼
    ┌──────────────────────────────────────────┐
    │              ReviewPanel                 │  OpenAI, temperature 0.2
    │  round-robin, each reviewer speaks once, │
    │  seeing the transcript so far:           │
    │    1. DistrictRepresentative             │
    │    2. FormalLanguageStickler             │
    │    3. ConservativeParent                 │
    │    4. LiberalParent                      │
    │    5. SchoolAdministrator                │
    │                    │                     │
    │                    ▼                     │
    │              Secretary                   │
    │        → ReviewDirectives                │  structured: {summary, directives[]}
    └────────────────────┬─────────────────────┘
                         │ directives
                         ▼
        ┌────────────────────────────┐
        │   the same writer as above │  Gemini
        │  .revise(question, draft,  │
        │           directives)      │
        └─────────────┬──────────────┘
                      ▼
                 WorkbookEntry
      {question, writer, routing_reason,
       draft, directives, final}

Cast of agents

Router

  • TaskAssigner — runs the desk, knows only that it has a historian and a physics writer. Returns a structured Assignment, never prose. Temperature 0.0 so the same question routes the same way.

Writers (the Gemini agents)

  • ContentWriter — the base: "You write content for a 9th grade workbook." Owns both generation methods, draft() and revise().
  • HistoryWriter — a historian familiar with K-12 curriculum standards; writes two balanced paragraphs.
  • PhysicsWriter — a physics teacher; step-by-step worked explanations with units and reasoning.

Neither subclass overrides a method. They differ only by persona, and inherit draft/revise unchanged — this is the inheritance point the comparison is built around.

Review panel (five reviewers who deliberately disagree)

  • DistrictRepresentative — wants brevity; worries about printing and remediation costs.
  • FormalLanguageStickler — wants formal register throughout.
  • ConservativeParent — wants patriotic framing in history, foundational method in physics.
  • LiberalParent — wants diverse perspectives in history, conceptual understanding in physics.
  • SchoolAdministrator — wants material that is easy to teach and effective.

Each reviewer also receives a shared PANEL_BRIEF prepended to its system prompt: be polite, accommodate other viewpoints, no walkouts, no ultimatums.

Secretary

  • Secretary — reads the whole transcript and emits a structured ReviewDirectives: a two-sentence summary of where the panel agreed and disagreed, plus a short list of concrete rewrite instructions. It is explicitly told to reconcile conflicting requests rather than list both.

Desks (orchestrators)

  • CurriculumDesk — the hand-written pipeline: route → draft → review → revise, returning a WorkbookEntry that carries the full provenance.
  • AutoCurriculumDesk / build_auto_desk() — the same goal, but the workflow itself is decided by the model. See RUN_CODEACT_DEMO.

Stage by stage

  1. Routing. TaskAssigner.assign(question) returns Assignment(writer=..., reason=...). The writer field is a Literal["HISTORIAN", "PHYS_WRITER"], so the value can be used directly as a dictionary key against self.writers — no string parsing, no fallback branch.
  2. Drafting. The selected writer's draft(question) produces the first version. This is the only stage where nothing constrains the output shape: it is plain workbook prose.
  3. Panel round-robin. Reviewers speak in a fixed order. Reviewer n is handed the transcript of reviewers 1..n-1 and told to add something new instead of restating what has been said. The first reviewer receives "(you are the first to speak)". Order matters: later reviewers react to earlier ones, which is what makes the panel a discussion rather than five independent critiques.
  4. Secretary summary. The transcript becomes a ReviewDirectives object. This is the pipeline's compression step — five loosely-worded opinions become a handful of actionable instructions.
  5. Revision. The same writer that drafted gets question, its own draft, and directives.as_instructions() (the summary plus a numbered list). Its instructions tell it to accommodate the directives without losing sight of the audience — the writer is allowed to push back on the panel.

Structured data contracts

Three Pydantic models carry state between stages. They are identical in nooa_demo.py, lang_chain_demo.py and crewai_demo.py; agent_framework_demo.py is the plainer one — it types only the routing decision (TaskAssignmentResponse) and passes the panel's feedback along as raw text, without a secretary-produced directives object:

class Assignment(BaseModel):
    writer: Literal["HISTORIAN", "PHYS_WRITER"]
    reason: str

class ReviewDirectives(BaseModel):
    summary: str
    directives: list[str]
    def as_instructions(self) -> str: ...   # renders "summary\n\n1. …\n2. …"

class WorkbookEntry(BaseModel):
    question: str
    writer: str
    routing_reason: str
    draft: str
    directives: ReviewDirectives
    final: str

How each framework fills them in is one of the sharper differences:

  • NOOA — the return annotation is the contract. async def assign(...) -> Assignment with a ... body and @strategy(PredictStrategy()) is the entire implementation.
  • LangChain — self.llm.with_structured_output(Assignment) appended to the chain.
  • Microsoft Agent Framework — response_format=TaskAssignmentResponse.model_json_schema() in the agent's default_options, then reading response.value.
  • CrewAI — the shape is described in expected_output prose plus a "JSON only" instruction, and the raw text is run through CrewAI's own convert_to_model. The obvious route, Task(output_pydantic=...), is avoided on purpose: for LiteLLM-backed models CrewAI routes it through instructor in tool-calling mode, and models that reply with plain JSON instead of a tool call make it raise rather than fall back.

How each framework expresses the same pipeline

The round-robin panel is where the four implementations diverge most:

Script Panel implementation
nooa_demo.py A plain Python for loop inside ReviewPanel.review(), appending to a transcript list. Ordinary Python is the orchestration language.
lang_chain_demo.py The same Python loop, over prompt | model chains.
agent_framework_demo.py SequentialBuilder(participants=reviewers, output_from="all").build() — the framework owns the ordering, and every reviewer is a participant in one orchestration.
crewai_demo.py One sequential Crew. Each reviewer's Task lists the earlier Tasks in its context, so an empty context means "you are the first to speak".

Persona definition differs similarly: NOOA and LangChain read the class docstring as the system prompt, Microsoft Agent Framework takes an instructions string, and CrewAI wants the persona split into role / goal / backstory (held in this repo as AgentSpec objects). The shared PANEL_BRIEF follows the same split — it is attached to each reviewer's system prompt in the NOOA and LangChain demos, merged into the backstory in CrewAI, and passed inside the review prompt in the Microsoft Agent Framework demo.

agent_framework_demo.py is the least elaborated of the four. Its secretary is simply the last participant in the sequential orchestration, the "directives" are whatever text that participant produced (the last message of the run), and the revision step feeds that text back to the writer as prose. There is no ReviewDirectives model, no WorkbookEntry, and no separate draft/revise method pair — just writer.run(question) followed by rewrite_with_feedback(...).


RUN_CODEACT_DEMO: letting the model write the workflow

RUN_CODEACT_DEMO is a flag at the top of main() in nooa_demo.py. It is False by default. When True, the script instantiates AutoCurriculumDesk and runs the pipeline a second time — except that this time nobody wrote the pipeline.

RUN_CODEACT_DEMO = False  # executes model-generated Python—enable deliberately

...

if RUN_CODEACT_DEMO:
    auto_desk = AutoCurriculumDesk()
    print(await auto_desk.write_content_on_topic(question=HISTORY_QUESTION))
else:
    print("CodeAct demo is disabled. Set RUN_CODEACT_DEMO = True to run it.")

What CodeAct is

NOOA methods with a ... body are generation methods: the framework, not you, supplies the implementation, and a strategy decides how. The two used here:

Strategy Behavior Used for
PredictStrategy() Single-shot structured output. One call, no code execution. Classification and extraction — assign, draft, revise, comment, summarize
CodeActStrategy() Code as action: the model writes Python into a Jupyter-style REPL, the framework executes it, feeds the result back, and lets the model iterate. Multi-step orchestration — AutoCurriculumDesk.write_content_on_topic

The important property is that swapping strategies does not change the method's signature. The strategy is an execution detail, not part of the contract, so callers are unaffected.

Under CodeAct, the agent's own attributes and methods are what the generated code reaches for. The model does not emit JSON tool calls — it writes ordinary Python like draft = await self.history_writer.draft(question=question), and the REPL runs it.

AutoCurriculumDesk in detail

class AutoCurriculumDesk(Agent, llm=llm):
    """Curriculum desk whose workflow is decided by the model itself.

    You own a task assigner, two writers, and a review panel. Use them to produce
    workbook content: route the question, draft an answer, collect panel feedback,
    and have the same writer revise the draft.
    """

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.assigner = TaskAssigner(llm=router_llm)
        self.history_writer = HistoryWriter()
        self.phys_writer = PhysicsWriter()
        self.panel = ReviewPanel()

    @strategy(CodeActStrategy(config=CodeActConfig(max_iterations=12)))
    async def write_content_on_topic(self, question: str) -> str:
        """Produce the final, panel-reviewed workbook content for this question.

        Decide which of your writers should handle it, get a draft, run the review
        panel over that draft, and return the writer's revised version.
        """
        ...

Compare it with CurriculumDesk, which has the same four attributes and a hand-written write_content_on_topic that calls them in a fixed order. The class bodies are nearly identical; the difference is who authors the sequencing:

CurriculumDesk AutoCurriculumDesk
Sequencing Written by you, in Python Written by the model, at run time, in Python
Failure mode A bug in your code The model calls a sub-agent wrongly, or never converges
Cost 9 calls, predictable the same 9 plus one reasoning call per REPL iteration
Return WorkbookEntry with full provenance Just the final str

The moving parts:

  • The class docstring is the system prompt. "You own a task assigner, two writers, and a review panel" is how the model learns what self contains.
  • The method docstring is the task. It states the goal and the intended sequence, but not the code — the model translates it into calls.
  • Sub-agents are attributes. self.assigner, self.history_writer, self.phys_writer, self.panel are ordinary Python objects, so the generated code awaits their methods directly. Note that AutoCurriculumDesk exposes the two writers as separate attributes rather than the dict that CurriculumDesk uses — a flat attribute is easier for the model to reach than a dictionary lookup keyed by a routing literal.
  • max_iterations=12 caps the REPL loop. Each iteration is: the model writes a code cell, the cell runs, the output comes back. Twelve is generous for a five-step pipeline and exists so a confused model stops instead of looping forever.
  • The return annotation -> str tells the strategy when it is finished: the loop ends when the model produces a value of the declared type.

A typical run produces something like four cells — route, draft, review, revise — with the model inspecting each intermediate value before writing the next cell.

Why the flag defaults to False

CodeAct executes model-generated Python in your process. That is the whole mechanism, not a side effect. NOOA applies defense-in-depth before execution (AST checks, module deny-lists), but upstream is explicit that these are not a containment boundary — built-ins such as open() and importlib can get around in-process validation. The documented containment boundary is OS-level isolation: run agents that execute generated code inside a container, a VM, or a tool like NVIDIA OpenShell.

So the flag is an informed-consent switch. Flipping it means:

  1. You accept that arbitrary Python written by an LLM will run with your user's privileges, your filesystem, and your API keys in the environment.
  2. You accept a variable number of extra LLM calls (up to max_iterations reasoning steps on top of the pipeline's own calls).

The recommended way to try it is inside a container or VM, not on the machine where keys.env lives.

Equivalent flags in the other demos

Each of the other scripts has the same "let the model drive" section behind a RUN_AUTO_DEMO flag, implemented with whatever that framework offers instead of CodeAct:

Script Flag Mechanism
nooa_demo.py RUN_CODEACT_DEMO CodeActStrategy — the model writes and executes Python
lang_chain_demo.py RUN_AUTO_DEMO (line 415) create_agent with four @tool functions (assign_writer, write_draft, review_draft, revise_draft) — the model emits JSON tool calls
crewai_demo.py RUN_AUTO_DEMO (line 525) Process.hierarchical with a manager agent that delegates to the crew until the goal is met
agent_framework_demo.py — No auto variant; the pipeline is always the hand-written one

The LangChain and CrewAI variants are safer in the narrow sense that the model can only choose which pre-written function to call, never what code to run. They are also less expressive: the CodeAct agent can compute, branch, and combine results inside a single cell, while a tool-calling agent has to round-trip through the model for every step.


Known gaps

  • requirements.txt covers the Microsoft Agent Framework demo only. nooa, crewai and the LangChain packages have to be installed separately (see Installation).
  • keys.env is committed with real-looking keys in it and also carries HF_TOKEN and KIMI_K2, which no script reads any more. Treat any key in that file as compromised and rotate it.
  • The demos are not deterministic. Routing is (temperature 0.0), but drafts, reviews and revisions will differ between runs.

About

One multi-agent pipeline, four frameworks: NOOA, Microsoft Agent Framework, LangChain and CrewAI side by side.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages