AutoGen company intelligence

Build a comparative company memo with current evidence.

What you’ll build

An AutoGen AssistantAgent that compares three companies in residential energy-management software. It iterates over live evidence and reflects on tool results before it writes the final intelligence memo.

Default brief: Compare positioning, recent signals, risks, and evidence quality without inventing financial figures. Keep company claims distinct from independent reporting.

How the agent works

  1. Establish company facts. Web search collects product, positioning, and other durable company information.
  2. Track recent moves. News search captures launches, partnerships, and reporting that may change quickly.
  3. Reflect before writing. AutoGen reviews its tool evidence for up to eight iterations and labels the quality of each comparison.

Core agent setup

This excerpt focuses on AutoGen’s reflective tool loop. The full script also creates and closes the model client, validates keys, and saves the final memo.

agent = AssistantAgent(
    "company_researcher",
    model_client=model_client,
    system_message=(
        "Search iteratively, distinguish company claims from independent "
        "reporting, and cite source URLs."
    ),
    tools=[
        web_search(provider="autogen", allowed_engines=["google_light", "bing"]),
        news_search(provider="autogen"),
    ],
    reflect_on_tool_use=True,
    max_tool_iterations=8,
)
result = await agent.run(task=PROMPT)

View the complete main.py

Run the recipe

Set SERPAPI_API_KEY and OPENAI_API_KEY in the repository-root .env, then run:

uv run --isolated --no-project --with 'serpapi-search-tools[autogen]' --with python-dotenv cookbook/autogen/main.py

Optional controls: OPENAI_MODEL, COOKBOOK_PROMPT, and COOKBOOK_OUTPUT_DIR.

Portable environment: --isolated --no-project resolves the published package and AutoGen extra independently from this repository’s project environment.

Inspect the result

The recipe writes cookbook-output/autogen-company-intelligence.md. Expect a sourced comparison of positioning, current moves, risks, and evidence strength across three companies.

Change COOKBOOK_PROMPT to choose another market or comparison set without editing the script.

SerpApi tools used

web_search gathers company, product, and positioning facts, while news_search finds recent launches, partnerships, and reporting. The split helps the agent distinguish company claims from current independent coverage before reflecting on its evidence.

Framework pattern: The reflective research loop is inspired by AutoGen’s company research notebook and uses SerpApi web and news tools.