Back to Prompt Library
implementation

Implement AutoGen Agents with Claude Opus 4.1 & Tools

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Multi-Agent System for Commercial Real Estate Analysis

Format
Code-aware
Lines
38
Sections
8
Linked challenge
Multi-Agent System for Commercial Real Estate Analysis

Prompt source

Original prompt text with formatting preserved for inspection.

38 lines
8 sections
No variables
1 code block
Write the Python code to initialize your AutoGen agents (e.g., UserProxyAgent, AssistantAgent with Claude Opus 4.1). Implement two custom AutoGen tools: one for fetching simulated CRE market data (e.g., `get_market_data(location, property_type)`) and another for performing basic financial calculations (e.g., `calculate_roi(cost, revenue)`). Ensure Claude Opus 4.1 is properly configured for the AssistantAgent and that tools are callable within the agent's context. 

```python
import autogen

# Configure Claude Opus 4.1
config_list_claude = [
    {
        "model": "claude-3-opus-20240229", # or equivalent API name for Claude Opus 4.1 via Azure/Anthropic
        "api_key": "YOUR_CLAUDE_API_KEY"
    }
]

# Define custom tools
def get_market_data(location: str, property_type: str) -> str:
    # Simulate API call
    if location == "Austin, TX" and property_type == "retail":
        return "Simulated Austin retail data: avg_yield=0.05, growth_potential=0.03"
    return "No data found for specified parameters."

def calculate_roi(cost: float, revenue: float) -> float:
    return (revenue - cost) / cost

# Create agents
# analyst_agent = autogen.AssistantAgent(
#    name="Analyst",
#    llm_config={"config_list": config_list_claude},
#    system_message="You are a commercial real estate analyst. Use tools to gather data and perform calculations."
# )
# user_proxy = autogen.UserProxyAgent(
#    name="User_Proxy",
#    human_input_mode="NEVER",
#    max_consecutive_auto_reply=10,
#    is_termination_msg=lambda x: "FINISH" in x.get("content", ""),
#    code_execution_config={"work_dir": "coding", "use_docker": False},
#    tool_code_extraction_config={"tool_code_block_tag": "tool_code"}
# )

# user_proxy.register_for_execution(get_market_data)
# user_proxy.register_for_llm(get_market_data)
# user_proxy.register_for_execution(calculate_roi)
# user_proxy.register_for_llm(calculate_roi)

# (Initialize GroupChat and run conversation)
```

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.