Automationscribe.com
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automation Scribe
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automationscribe.com
No Result
View All Result

The right way to Construct a Multi-Agent Analysis Assistant in Python

admin by admin
June 5, 2026
in Artificial Intelligence
0
The right way to Construct a Multi-Agent Analysis Assistant in Python
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter


On this article, you’ll discover ways to construct a multi-agent AI analysis assistant utilizing the OpenAI Brokers SDK, the GPT-5.4 mini mannequin, and the Olostep Internet API, together with learn how to wire collectively a supervisor agent, specialist sub-agents, and dwell net instruments to supply structured, source-grounded analysis experiences.

Matters we are going to cowl embrace:

  • The right way to outline a supervisor agent that orchestrates a choose agent and an analyst agent to progressively collect and consider proof.
  • The right way to combine Olostep’s Reply, Search, Search-with-Scrape, and Scrape APIs as callable instruments contained in the OpenAI Brokers SDK workflow.
  • The right way to expose the completed analysis assistant as an interactive net utility constructed with Reflex, full with PDF export.
How to Build a Multi-Agent Research Assistant in Python

The right way to Construct a Multi-Agent Analysis Assistant in Python

Introduction

I’ve been experimenting with the OpenAI Brokers SDK, and it has rapidly turn out to be one among my favourite methods to construct agentic AI functions. What stood out to me is how easy it’s to create a multi-agent workflow: you outline a supervisor agent, join it with specialist sub-agents and instruments, and let it resolve learn how to full the duty.

The supervisor agent can delegate work to different brokers, name instruments immediately, and coordinate the general analysis course of. This makes it attainable to construct AI functions that do greater than generate textual content — they will search the online, collect info, arrange findings, and produce grounded outputs.

On this information, we are going to construct a multi-agent AI analysis assistant utilizing the OpenAI Brokers SDK, the GPT-5.4 mini mannequin, and the Olostep Internet API. The assistant will generate a structured analysis report that’s grounded in net information, straightforward to learn, and produced in only a few seconds.

The information additionally contains the complete code, an internet app, and a hyperlink to the deployed model so you may check the system your self. By the tip, you’ll perceive how a number of brokers can work collectively to create a sensible analysis assistant from scratch.

1. Set Up the Setting

Earlier than constructing the multi-agent analysis assistant, we have to arrange the Python surroundings and configure the required API keys.

We’ll use 4 primary packages:

  • openai-agents for constructing and working the multi-agent workflow
  • olostep for accessing dwell net information
  • pydantic for outlining structured outputs
  • python-dotenv for loading API keys from a .env file

Run the next command to put in the required packages:

pip set up –q –U openai–brokers olostep python–dotenv pydantic

Subsequent, create a .env file in your undertaking listing. This file will retailer your API keys securely, so you don’t want to hardcode them inside your pocket book or utility.

OPENAI_API_KEY=your_openai_api_key

OLOSTEP_API_KEY=your_olostep_api_key

You’ll be able to create your OpenAI API key from the OpenAI Platform. Sign up to your OpenAI account, go to the API keys part, and generate a brand new key for this undertaking. Be certain that your OpenAI API account has billing enabled and at the least $5 in credit obtainable earlier than working the examples. You may additionally want to finish account verification to entry the newest fashions.

For Olostep, create a free account from the Olostep web site and generate an API key out of your dashboard. The free plan contains 500 profitable requests with no bank card required, which is sufficient to check the analysis assistant on this information.

As soon as your keys are prepared, we are going to begin in a Jupyter Pocket book by importing the required libraries and loading the surroundings variables. This setup prepares the pocket book to work with OpenAI, Olostep, structured outputs, and tracing.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

import json

import os

from datetime import datetime

from typing import Any

 

from dotenv import load_dotenv

from IPython.show import Markdown, show

from olostep import Olostep

from pydantic import BaseModel, Discipline

 

from brokers import (

    Agent,

    Runner,

    custom_span,

    flush_traces,

    function_tool,

    gen_trace_id,

    hint,

)

 

load_dotenv()

 

OPENAI_API_KEY = os.getenv(“OPENAI_API_KEY”)

OLOSTEP_API_KEY = os.getenv(“OLOSTEP_API_KEY”)

2. Take a look at Olostep Search with Scraping

Earlier than constructing the complete multi-agent workflow, it’s helpful to check whether or not Olostep can search the online and scrape the returned pages efficiently. This step confirms that your API key’s working and that the search outcomes embrace sufficient web page content material for downstream evaluation.

The Olostep Search API is very helpful as a result of it might probably return search outcomes with a built-in scraping choice. As an alternative of solely receiving web page titles, snippets, and hyperlinks, you may ask Olostep to scrape the returned URLs and supply the extracted content material in codecs equivalent to Markdown.

This implies the agent can work with high-quality web page content material immediately, relatively than relying solely on search snippets. It additionally saves time as a result of you don’t want to construct a separate search-and-scrape pipeline your self.

consumer = Olostep(api_key=OLOSTEP_API_KEY)

 

search = consumer.searches.create(

    question=“What are a very powerful current developments in AI brokers for enterprise analysis?”,

    restrict=5,

    scrape_options={“codecs”: [“markdown”], “timeout”: 25},

)

 

for hyperlink in search.hyperlinks:

    print(hyperlink[“url”], “-“, len(hyperlink.get(“markdown_content”) or “”), “chars”)

This tells Olostep to scrape every returned web page and supply the extracted content material in Markdown format. Markdown is beneficial as a result of it retains the content material readable whereas eradicating pointless web page litter. The timeout worth provides Olostep sufficient time to fetch and course of every web page.

After the search is full, we loop via the returned hyperlinks and print every URL together with the variety of characters extracted from the web page.

3. Add Helper Features

Earlier than creating the brokers and instruments, we have to add a number of helper features. These utilities preserve the remainder of the code cleaner and make the workflow simpler to debug.

The helper features will deal with six issues:

  • Test whether or not the Olostep API key’s obtainable
  • Create a reusable Olostep consumer
  • Convert SDK responses into customary Python dictionaries
  • Compress massive JSON outputs so they’re simpler to examine
  • Add the present date and yr as context for the brokers
  • Normalize search outcomes into an easier format for the brokers

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

class OlostepError(RuntimeError):

    “”“Raised when an Olostep SDK request fails.”“”

 

def require_olostep_key() -> str:

    if not OLOSTEP_API_KEY:

        increase OlostepError(

            “OLOSTEP_API_KEY shouldn’t be set. Add it to .env and rerun the setup cell.”

        )

    return OLOSTEP_API_KEY

 

def get_olostep_client() -> Olostep:

    return Olostep(api_key=require_olostep_key())

 

def sdk_result_to_dict(outcome: Any) -> dict[str, Any]:

    if hasattr(outcome, “model_dump”):

        return outcome.model_dump()

    if hasattr(outcome, “__dict__”):

        return {

            key: worth for key, worth in vars(outcome).gadgets() if not key.startswith(“_”)

        }

    return {“worth”: str(outcome)}

 

def compact_json(information: Any, max_chars: int = 8000) -> str:

    textual content = json.dumps(information, ensure_ascii=False, indent=2, default=str)

    if len(textual content) <= max_chars:

        return textual content

    return textual content[:max_chars] + “n… [truncated]”

 

def current_date_context() -> str:

    return datetime.now().strftime(“%B %d, %Y”)

 

def current_year_context() -> str:

    return str(datetime.now().yr)

 

def normalize_search_links(

    hyperlinks: listing[dict[str, Any]], restrict: int = 8

) -> listing[dict[str, Any]]:

    rows = []

    for hyperlink in hyperlinks[:limit]:

        markdown = hyperlink.get(“markdown_content”) or “”

        rows.append(

            {

                “title”: hyperlink.get(“title”) or “Untitled”,

                “url”: hyperlink.get(“url”) or “”,

                “description”: hyperlink.get(“description”) or “”,

                “markdown_chars”: len(markdown),

                “markdown_preview”: markdown[:1500] if markdown else “”,

            }

        )

    return rows

4. Outline Structured Output Fashions

Subsequent, outline the structured outputs that the brokers will return. These fashions make the workflow extra dependable as a result of every agent should return info in a constant format.

The choose agent makes use of the Judgment mannequin to resolve whether or not the gathered proof is powerful sufficient. The analyst agent makes use of the MarkdownResearchReport mannequin to return the ultimate report as polished Markdown.

class Judgment(BaseModel):

    is_good_enough: bool = Discipline(

        description=“Whether or not the reply is enough for the person question, that means rating >= 0.85.”

    )

    rating: float = Discipline(ge=0, le=1, description=“High quality rating from 0 to 1.”)

    motive: str = Discipline(description=“Brief rationalization of the choice.”)

    missing_information: listing[str] = Discipline(

        default_factory=listing, description=“Essential gaps to repair.”

    )

 

class MarkdownResearchReport(BaseModel):

    markdown_report: str = Discipline(

        description=“Full Markdown report with polished headings, clear evaluation, reader-friendly construction, and citations.”

    )

Judgment works because the quality-control schema. It helps the choose agent resolve whether or not the gathered proof is powerful sufficient or whether or not the supervisor agent ought to proceed looking.

MarkdownResearchReport defines the ultimate analysis output. For the reason that last app solely wants the finished report, this mannequin retains a single markdown_report area as a substitute of additional metadata fields. This makes the output easier and simpler to show within the pocket book, net app, and PDF export.

5. Create Olostep Instrument Features

Now create the instruments that the supervisor agent can name in the course of the analysis course of. These instruments wrap Olostep’s Reply API, Search API, Search with Scrape, and Scrape API.

Every software contains tracing spans so you may examine what occurred throughout execution within the OpenAI hint viewer. That is helpful for debugging as a result of you may see which software was known as, what enter it acquired, and the way the supervisor agent moved via the workflow.

Reply Question Instrument

This software asks Olostep for a fast reply to the person’s analysis query. It’s used as step one within the workflow earlier than deciding whether or not extra analysis is required.

@function_tool

async def answer_query(question: str) -> str:

    “”“Reply a natural-language analysis question utilizing Olostep Reply API.”“”

    strive:

        with custom_span(“olostep.answer_query”, {“question”: question}):

            outcome = get_olostep_client().solutions.create(job=question)

            return compact_json(sdk_result_to_dict(outcome))

 

    besides Exception as exc:

        increase OlostepError(f“Olostep Reply API failed: {exc}”) from exc

Search Internet Instrument

This software runs a typical net search and returns normalized outcomes. It’s helpful when the assistant wants to find further sources earlier than scraping particular pages.

The output is deliberately compact. As an alternative of returning the complete uncooked API response, the software returns the question and a cleaned listing of search outcomes. This makes the response simpler for the supervisor agent to learn and reduces pointless context.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

@function_tool

async def search_web(question: str, restrict: int = 8) -> str:

    “”“Search the online utilizing Olostep Search and return normalized outcomes.”“”

    strive:

        with custom_span(“olostep.search_web”, {“question”: question, “restrict”: restrict}):

            search = get_olostep_client().searches.create(

                question=question,

                restrict=restrict,

            )

 

            information = sdk_result_to_dict(search)

 

            return compact_json(

                {

                    “question”: question,

                    “outcomes”: normalize_search_links(

                        information.get(“hyperlinks”, []),

                        restrict=restrict,

                    ),

                }

            )

 

    besides Exception as exc:

        increase OlostepError(f“Olostep Search API failed: {exc}”) from exc

Search with Scrape Instrument

This software searches the online and scrapes the returned pages in a single step. It provides the analysis assistant richer proof than search snippets alone.

This is likely one of the most necessary instruments within the undertaking as a result of it lets the agent retrieve each hyperlinks and web page content material from a single name. As an alternative of first looking the online, deciding on URLs, after which scraping each individually, the software can return usable Markdown content material immediately from the found pages.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

@function_tool

async def search_with_scrape(question: str, restrict: int = 5) -> str:

    “”“Search the online and scrape every returned hyperlink utilizing Olostep Search with Scrape.”“”

    scrape_options = {

        “codecs”: [“markdown”],

        “timeout”: 25,

    }

 

    strive:

        with custom_span(

            “olostep.search_with_scrape”,

            {

                “question”: question,

                “restrict”: restrict,

                “scrape_options”: scrape_options,

            },

        ):

            search = get_olostep_client().searches.create(

                question=question,

                restrict=restrict,

                scrape_options=scrape_options,

            )

 

            information = sdk_result_to_dict(search)

 

            return compact_json(

                {

                    “question”: question,

                    “outcomes”: normalize_search_links(

                        information.get(“hyperlinks”, []),

                        restrict=restrict,

                    ),

                },

                max_chars=12000,

            )

 

    besides Exception as exc:

        increase OlostepError(f“Olostep Search with Scrape failed: {exc}”) from exc

Scrape URL Instrument

This software scrapes a single URL and returns compact web page content material. The supervisor agent makes use of it when it wants deeper proof from chosen sources.

For instance, the supervisor might first use search_web to search out related pages, then use scrape_url to retrieve the complete content material from probably the most helpful hyperlinks.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

@function_tool

async def scrape_url(url: str) -> str:

    “”“Scrape one URL with Olostep and return compact web page content material.”“”

    strive:

        with custom_span(

            “olostep.scrape_url”,

            {

                “url”: url,

                “codecs”: [“markdown”],

            },

        ):

            scrape = get_olostep_client().scrapes.create(

                url=url,

                codecs=[“markdown”],

            )

 

            return compact_json(

                {

                    “url”: url,

                    “scrape”: sdk_result_to_dict(scrape),

                },

                max_chars=10000,

            )

 

    besides Exception as exc:

        increase OlostepError(f“Olostep Scrape API failed: {exc}”) from exc

These instruments give the supervisor agent alternative ways to assemble proof. It could begin with a fast reply, seek for extra sources, use Search with Scrape for richer context, or scrape a selected URL when it wants extra element.

6. Construct the Specialist Brokers

The workflow makes use of two specialist brokers: a choose agent and an analyst agent.

The choose agent checks whether or not the gathered proof is powerful sufficient to reply the person’s query. The analyst agent then turns the authorised proof into a sophisticated Markdown analysis report.

First, outline the mannequin that each specialist brokers will use:

Choose Agent

The choose agent evaluates reply high quality. It checks whether or not the reply is particular, present, source-backed, and full sufficient to cease the analysis course of.

That is necessary as a result of the supervisor agent shouldn’t produce a last report from weak proof. If the reply is obscure, outdated, unsupported, or lacking key particulars, the choose agent will reject it and the supervisor agent can proceed looking.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

judge_agent = Agent(

    title=“Choose agent”,

    mannequin=MODEL,

    directions=(

        “You choose whether or not the offered reply is nice sufficient for the unique analysis query. “

        “Reward direct, particular, source-backed solutions. Reject obscure, stale, or unsupported solutions. “

        “Be strict: is_good_enough have to be true solely when rating >= 0.85 and the proof immediately solutions “

        “the query with concrete supply content material, topic-specific element, and acceptable recency. “

        “For present occasions, product standing, insurance policies, pricing, or factual claims that will change, require current “

        “main or extremely respected sources. Don’t mark proof enough if any important hole stays. “

        “Calibrate scores this manner: 0.85-1.0 means enough to cease with sturdy supply assist and no important gaps; “

        “0.75-0.84 means sturdy however nonetheless lacking one necessary supply, element, recency test, or protection space; “

        “0.50-0.74 means related partial proof that wants extra analysis; 0.25-0.49 means skinny, obscure, stale, “

        “or weakly associated proof; beneath 0.25 is just for empty, unusable, or largely unrelated proof. “

        “Don’t mark proof enough simply because it’s believable or directionally right. “

        “Return solely the structured judgment.”

    ),

    output_type=Judgment,

)

The choose agent returns a Judgment object. This contains whether or not the proof is nice sufficient, a top quality rating, a brief motive, and any lacking info that also must be addressed.

Analyst Agent

The analyst agent writes the ultimate Markdown report. It turns the gathered proof right into a readable analysis temporary with clear sections, supply notes, and references.

This agent is chargeable for making the output helpful for an expert reader. As an alternative of merely summarizing uncooked software outputs, it organizes the findings into an entire report that explains the subject, highlights a very powerful proof, and cites the sources used.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

analyst_agent = Agent(

    title=“Analyst agent”,

    mannequin=MODEL,

    directions=(

        “You write a correct Markdown analysis report from the proof. “

        “Write for an expert reader who desires a transparent, polished analysis temporary on any matter. “

        “Adapt the report back to the person’s query. The markdown_report have to be substantial, straightforward to scan, and use these basic sections solely: “

        “Govt Abstract, Key Findings, Context, Proof Evaluation, Detailed Evaluation, Implications, Supply Notes, and References. “

        “If the subject is event-driven, embrace timeline particulars inside Context or Detailed Evaluation as a substitute of including a separate Timeline part. “

        “If the subject is comparative, embrace a compact comparability desk inside Detailed Evaluation. “

        “Don’t embrace sections titled Limitations, Subsequent Steps, Suggestions, or Motion Objects. “

        “Keep away from naked caveats like ‘I relied on…’. As an alternative, combine supply high quality naturally in Supply Notes. “

        “Use quick paragraphs, bullets the place useful, and citations as Markdown hyperlinks or URL bullets. “

        “Add sufficient context {that a} non-expert reader understands the difficulty, why it issues, and what proof helps it. “

        “Don’t use emoji, return-arrow symbols, backlink icons, or ornamental icons wherever within the report. “

        “In References, listing solely plain Markdown bullets or numbered gadgets with the supply title and URL. “

        “Return solely the structured report.”

    ),

    output_type=MarkdownResearchReport,

)

The analyst agent returns a MarkdownResearchReport object with one area: markdown_report. This retains the ultimate output easy as a result of the entire title, abstract, findings, evaluation, supply notes, and references are all included contained in the Markdown report itself.

7. Create the Supervisor Agent

The supervisor agent is the orchestrator. It controls the complete analysis workflow and decides which software or specialist agent ought to run subsequent.

The workflow follows this sample:

  1. Begin with a fast reply utilizing the Olostep Reply API
  2. Ask the choose agent whether or not the reply is nice sufficient
  3. If not, run Search with Scrape for stronger proof
  4. Ask the choose agent once more
  5. If the proof continues to be weak, run focused searches and scrape probably the most related pages
  6. Ask the analyst agent to put in writing the ultimate report

First, convert the choose and analyst brokers into instruments. This enables the supervisor agent to name them in the course of the workflow.

judge_tool = judge_agent.as_tool(

    tool_name=“judge_answer_quality”,

    tool_description=“Choose whether or not a solution or proof is nice sufficient for the unique analysis query.”,

)

 

analyst_tool = analyst_agent.as_tool(

    tool_name=“write_markdown_research_report”,

    tool_description=“Write the ultimate structured Markdown analysis report from the gathered proof.”,

)

Now outline the supervisor agent. This agent doesn’t reply from reminiscence. As an alternative, it follows a transparent analysis course of: reply, choose, search, choose once more, scrape if wanted, after which write the ultimate report.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

manager_agent = Agent(

    title=“Supervisor analysis agent”,

    mannequin=MODEL,

    directions=(

        f“Present date: {current_date_context()}n”

        f“Present yr: {current_year_context()}nn”

        “You’re the orchestrator for a multi-agent analysis assistant. You will need to handle the workflow, “

        “not reply from your individual reminiscence. Comply with this coverage precisely:n”

        “1. All the time name answer_query first to get a easy preliminary reply for the person’s query.n”

        “2. Instantly name judge_answer_quality on the unique query plus the answer_query outcome. “

        “If the choose returns is_good_enough=true and rating >= 0.85, cease researching and name “

        “write_markdown_research_report with the query, reply outcome, and judgment.n”

        “3. If the primary judgment is weak, name search_with_scrape for the unique query. “

        “Instantly name judge_answer_quality once more on the unique query plus the answer_query outcome, “

        “first judgment, and search_with_scrape outcome. If this second choose returns is_good_enough=true “

        “and rating >= 0.85, cease researching and name write_markdown_research_report with all proof.n”

        “4. If the second judgment continues to be weak, don’t name the choose once more. Run a number of focused “

        “search_web calls first, utilizing the choose’s missing_information to type the searches. Examine the “

        “search outcomes, select at the least the highest 3 related supply URLs most definitely to reply the lacking “

        “factors, then name scrape_url on every of these high 3 pages. Scrape greater than 3 provided that clearly wanted.n”

        “5. Name write_markdown_research_report precisely as soon as on the finish, utilizing each reply, judgment, “

        “search outcome, and scraped web page. The analyst should produce the ultimate MarkdownResearchReport.n”

        “6. Return solely the ultimate MarkdownResearchReport. Don’t return an off-the-cuff chat reply, software transcript, or plan.”

    ),

    instruments=[

        answer_query,

        judge_tool,

        search_with_scrape,

        search_web,

        scrape_url,

        analyst_tool,

    ],

    output_type=MarkdownResearchReport,

)

The supervisor agent is the core of the system. It decides when the primary reply is sufficient, when extra proof is required, and when to name the analyst agent to supply the ultimate report.

The important thing concept is that the supervisor doesn’t depend on a single software name. It begins with a quick reply, checks high quality, and solely does deeper analysis when wanted. This retains the workflow environment friendly whereas nonetheless permitting the assistant to assemble stronger proof for extra advanced questions.

8. Run the Analysis Assistant with Tracing

The ultimate perform runs the supervisor agent and returns a structured analysis report. It additionally creates an OpenAI hint ID so you may examine the complete workflow, together with supervisor selections, specialist agent calls, software utilization, and Olostep spans.

Tracing is very helpful when debugging multi-agent programs as a result of it reveals precisely what occurred at every step. You’ll be able to see whether or not the supervisor adopted the required workflow, which instruments had been known as, what proof was gathered, how the choose evaluated the reply, and when the analyst produced the ultimate report.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

def openai_trace_url(trace_id: str) -> str:

    return f“https://platform.openai.com/logs/hint?trace_id={trace_id}”

 

 

async def run_research_assistant(question: str) -> MarkdownResearchReport:

    if not OPENAI_API_KEY:

        increase RuntimeError(

            “OPENAI_API_KEY shouldn’t be set. Add it to .env and rerun the setup cell.”

        )

    require_olostep_key()

 

    trace_id = gen_trace_id()

    print(“OpenAI hint ID:”, trace_id)

    print(“OpenAI hint URL:”, openai_trace_url(trace_id))

 

    current_date = current_date_context()

    current_year = current_year_context()

    immediate = f“”“

Present date:

{current_date}

 

Present yr:

{current_year}

 

Analysis query:

{question}

 

Return a sophisticated, reader-friendly Markdown analysis report with substantial element for the person’s particular query. Comply with the required workflow precisely:

– Use answer_query first for a easy preliminary reply.

– Use the choose agent instantly after the straightforward reply to resolve whether or not to cease or proceed.

– If the primary choose says the reply shouldn’t be enough, run search_with_scrape.

– Use the choose agent instantly after search_with_scrape to resolve whether or not to cease or proceed.

– If the second choose nonetheless says the proof is weak, don’t choose once more. Run a number of focused search_web calls, select at the least the highest 3 related supply URLs from the search outcomes, and scrape these high 3 pages for context.

– Analyst agent writes the ultimate Markdown report from all reply, choose, search, and scrape proof. Don’t embrace Limitations or Subsequent Steps sections.

““”

    with hint(

        workflow_name=“multi_agent_research_assistant_olostep”,

        trace_id=trace_id,

        metadata={

            “question”: question,

            “pocket book”: “multi_agent_research_assistant_openai_agents_olostep”,

        },

    ):

        with custom_span(“supervisor.run”, {“question”: question}):

            outcome = await Runner.run(manager_agent, immediate, max_turns=30)

 

    flush_traces()

    print(

        “Hint flushed. Open the URL above to examine supervisor, specialist brokers, instruments, and Olostep spans.”

    )

    return outcome.final_output

The perform first checks that each API keys can be found. It then creates a hint ID and prints a hint URL so you may examine the complete run within the OpenAI hint viewer.

The hint() block teams the complete workflow, whereas custom_span() marks the manager-agent run. For the reason that Olostep instruments additionally use customized spans, you may see each agent selections and API calls in a single place.

Lastly, flush_traces() sends the hint information to OpenAI so the run is offered for assessment.

9. Take a look at the Multi-Agent Analysis Assistant

Now check the complete workflow with a pattern analysis query. The assistant will run the supervisor agent, collect proof, choose the standard of that proof, and return a structured Markdown report.

example_query = “What is going on on with OpenAI’s Sora shutting down?”

 

report = await run_research_assistant(example_query)

show(Markdown(report.markdown_report))

While you run this cell, the pocket book prints an OpenAI hint ID and hint URL:

OpenAI hint ID: trace_45f3333363da420dbcefc8bb8819224c

OpenAI hint URL: https://platform.openai.com/logs/hint?trace_id=trace_45f3333363da420dbcefc8bb8819224c

Click on the hint URL to open the run within the OpenAI hint viewer. This allows you to examine the complete execution path throughout the supervisor agent, choose agent, analyst agent, Olostep instruments, and scraping calls.

The hint is beneficial as a result of it reveals the precise orchestration course of. You’ll be able to see when the supervisor agent begins with answer_query, when it sends the outcome to the choose agent, and the way the choose decides whether or not the proof is powerful sufficient. If the primary reply shouldn’t be sufficient, the hint additionally reveals when the supervisor makes use of search_with_scrape or focused scraping to assemble higher proof.

Building a Multi-Agent Research Assistant with OpenAI Agents SDK and Olostep

After the supervisor completes the analysis course of, the pocket book shows the ultimate Markdown report:

Building a Multi-Agent Research Assistant with OpenAI Agents SDK and Olostep

The ultimate report is written in a clear, reader-friendly format with an govt abstract, key findings, context, evaluation, supply notes, and references.

If you happen to face any points working the pocket book or reproducing the outcomes above, you may assessment the complete Jupyter Pocket book on GitHub. It contains the entire setup, helper features, agent definitions, software calls, tracing workflow, and instance output: multi_agent_research_assistant_openai_agents_olostep.ipynb

10. Construct a Internet UI with Reflex

After testing the code within the pocket book, you may flip the analysis assistant right into a easy net app utilizing Reflex, a Python net framework for constructing interactive person interfaces.

The net app focuses on making a clear interface the place customers can:

  • Enter a analysis query
  • Run the multi-agent workflow
  • View the agent exercise logs
  • Learn the ultimate analysis report
  • Obtain the report as a PDF

You’ll find the app code within the undertaking repository: Multi-Agent-Analysis-Assistant/app

First, clone the undertaking repository:

git clone https://github.com/kingabzpro/Multi-Agent-Analysis-Assistant.git

Transfer into the undertaking folder and set up the required dependencies:

cd Multi–Agent–Analysis–Assistant

pip set up –r necessities.txt

Subsequent, create a .env file from the offered template and add your API keys:

OPENAI_API_KEY=your_openai_api_key

OLOSTEP_API_KEY=your_olostep_api_key

OPENAI_MODEL=gpt–5.4–mini

Then run the Reflex app:

As soon as the app begins, open the native URL printed in your terminal. It’s normally:

You now have a working net interface to your multi-agent analysis assistant.

The UI is designed to be easy, quick, and sensible. While you enter a query and click on the search button, the app reveals the workflow logs so you may observe what the assistant is doing.

Building a Multi-Agent Research Assistant with OpenAI Agents SDK and Olostep

The assistant begins by calling the Olostep Reply API to get an preliminary reply. It then sends that proof to the choose agent to test whether or not the reply is powerful sufficient. If the choose decides extra proof is required, the supervisor agent continues with net search, scraping, and extra supply gathering earlier than sending the whole lot to the analyst agent for the ultimate report.

Building a Multi-Agent Research Assistant with OpenAI Agents SDK and Olostep

The ultimate report is displayed in a clear, skilled format that’s straightforward to learn. You may as well obtain the generated analysis report as a PDF file, making it simpler to avoid wasting, share, or assessment later.

Building a Multi-Agent Research Assistant with OpenAI Agents SDK and Olostep

If you don’t want to construct the app domestically and solely wish to strive it rapidly, you need to use the deployed Hugging Face House: Multi-Agent Analysis Assistant – a Hugging Face House by kingabzpro

Ultimate Ideas

Constructing this multi-agent analysis assistant confirmed how straightforward it’s to create a sensible agentic workflow utilizing specialist brokers and a number of instruments. As an alternative of counting on one massive, costly analysis run each time, the system makes use of a supervisor agent to decide on the precise path based mostly on the standard of the proof.

The workflow is designed to stability velocity, value, and accuracy. It begins with the Olostep Reply API for a quick first response. If the choose agent provides that reply a powerful rating, the analyst agent instantly turns it right into a last report. This retains easy analysis duties quick and cost-effective.

If the choose decides the primary reply shouldn’t be sturdy sufficient, the supervisor agent strikes to Search with Scrape. This provides the system richer proof with out leaping straight right into a deeper and dearer analysis course of. The choose then checks the proof once more. Whether it is adequate, the analyst writes the report.

Solely when the proof continues to be weak does the supervisor agent run focused searches and scrape chosen pages. This implies the system can nonetheless produce a extra correct report when the query is advanced, present, or lacking necessary context.

The very best half is that each question doesn’t value the identical or take the identical period of time. Easy questions can end rapidly, whereas more durable questions get extra analysis depth when wanted. This makes the assistant extra environment friendly, extra dependable, and higher suited to real-world analysis workflows.

Tags: AssistantBuildMultiAgentPythonResearch
Previous Post

The Elementary Alternative in Reinforcement Studying: On‑Coverage vs. Off‑Coverage

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular News

  • Greatest practices for Amazon SageMaker HyperPod activity governance

    Greatest practices for Amazon SageMaker HyperPod activity governance

    405 shares
    Share 162 Tweet 101
  • How Cursor Really Indexes Your Codebase

    404 shares
    Share 162 Tweet 101
  • Construct a serverless audio summarization resolution with Amazon Bedrock and Whisper

    403 shares
    Share 161 Tweet 101
  • Speed up edge AI improvement with SiMa.ai Edgematic with a seamless AWS integration

    403 shares
    Share 161 Tweet 101
  • Optimizing Mixtral 8x7B on Amazon SageMaker with AWS Inferentia2

    403 shares
    Share 161 Tweet 101

About Us

Automation Scribe is your go-to site for easy-to-understand Artificial Intelligence (AI) articles. Discover insights on AI tools, AI Scribe, and more. Stay updated with the latest advancements in AI technology. Dive into the world of automation with simplified explanations and informative content. Visit us today!

Category

  • AI Scribe
  • AI Tools
  • Artificial Intelligence

Recent Posts

  • The right way to Construct a Multi-Agent Analysis Assistant in Python
  • The Elementary Alternative in Reinforcement Studying: On‑Coverage vs. Off‑Coverage
  • NVIDIA Nemotron 3 Extremely now accessible on Amazon SageMaker JumpStart
  • Home
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

© 2024 automationscribe.com. All rights reserved.

No Result
View All Result
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us

© 2024 automationscribe.com. All rights reserved.