[fix][aop docs server example]

pull/1117/head
Kye Gomez 6 days ago
parent 0122731b31
commit c90d628712

@ -410,10 +410,10 @@ nav:
- Hiearchical Marketing Team: "examples/marketing_team.md"
- Gold ETF Research with HeavySwarm: "examples/gold_etf_research.md"
- Hiring Swarm: "examples/hiring_swarm.md"
- Advanced Research: "examples/av.md"
- Tools & Integrations:
- Web Search with Exa: "examples/exa_search.md"
- Advanced Research: "examples/av.md"
- Browser Use: "examples/browser_use.md"
- Yahoo Finance: "swarms/examples/yahoo_finance.md"
- Firecrawl: "developer_guides/firecrawl.md"

@ -0,0 +1,164 @@
# AOP Server Setup Example
This example demonstrates how to set up an Agent Orchestration Protocol (AOP) server with multiple specialized agents.
## Overview
The AOP server allows you to deploy multiple agents that can be discovered and called by other agents or clients in the network. This example shows how to create a server with specialized agents for different tasks.
## Code Example
```python
from swarms import Agent
from swarms.structs.aop import (
AOP,
)
# Create specialized agents
research_agent = Agent(
agent_name="Research-Agent",
agent_description="Expert in research, data collection, and information gathering",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
top_p=None,
dynamic_temperature_enabled=True,
system_prompt="""You are a research specialist. Your role is to:
1. Gather comprehensive information on any given topic
2. Analyze data from multiple sources
3. Provide well-structured research findings
4. Cite sources and maintain accuracy
5. Present findings in a clear, organized manner
Always provide detailed, factual information with proper context.""",
)
analysis_agent = Agent(
agent_name="Analysis-Agent",
agent_description="Expert in data analysis, pattern recognition, and generating insights",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
top_p=None,
dynamic_temperature_enabled=True,
system_prompt="""You are an analysis specialist. Your role is to:
1. Analyze data and identify patterns
2. Generate actionable insights
3. Create visualizations and summaries
4. Provide statistical analysis
5. Make data-driven recommendations
Focus on extracting meaningful insights from information.""",
)
writing_agent = Agent(
agent_name="Writing-Agent",
agent_description="Expert in content creation, editing, and communication",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
top_p=None,
dynamic_temperature_enabled=True,
system_prompt="""You are a writing specialist. Your role is to:
1. Create engaging, well-structured content
2. Edit and improve existing text
3. Adapt tone and style for different audiences
4. Ensure clarity and coherence
5. Follow best practices in writing
Always produce high-quality, professional content.""",
)
code_agent = Agent(
agent_name="Code-Agent",
agent_description="Expert in programming, code review, and software development",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
top_p=None,
dynamic_temperature_enabled=True,
system_prompt="""You are a coding specialist. Your role is to:
1. Write clean, efficient code
2. Debug and fix issues
3. Review and optimize code
4. Explain programming concepts
5. Follow best practices and standards
Always provide working, well-documented code.""",
)
financial_agent = Agent(
agent_name="Financial-Agent",
agent_description="Expert in financial analysis, market research, and investment insights",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
top_p=None,
dynamic_temperature_enabled=True,
system_prompt="""You are a financial specialist. Your role is to:
1. Analyze financial data and markets
2. Provide investment insights
3. Assess risk and opportunities
4. Create financial reports
5. Explain complex financial concepts
Always provide accurate, well-reasoned financial analysis.""",
)
# Basic usage - individual agent addition
deployer = AOP("MyAgentServer", verbose=True, port=5932)
agents = [
research_agent,
analysis_agent,
writing_agent,
code_agent,
financial_agent,
]
deployer.add_agents_batch(agents)
deployer.run()
```
## Key Components
### 1. Agent Creation
Each agent is created with:
- **agent_name**: Unique identifier for the agent
- **agent_description**: Brief description of the agent's capabilities
- **model_name**: The language model to use
- **system_prompt**: Detailed instructions defining the agent's role and behavior
### 2. AOP Server Setup
- **Server Name**: "MyAgentServer" - identifies your server
- **Port**: 5932 - the port where the server will run
- **Verbose**: True - enables detailed logging
### 3. Agent Registration
- **add_agents_batch()**: Registers multiple agents at once
- Agents become available for discovery and remote calls
## Usage
1. **Start the Server**: Run the script to start the AOP server
2. **Agent Discovery**: Other agents or clients can discover available agents
3. **Remote Calls**: Agents can be called remotely by their names
## Server Features
- **Agent Discovery**: Automatically registers agents for network discovery
- **Remote Execution**: Agents can be called from other network nodes
- **Load Balancing**: Distributes requests across available agents
- **Health Monitoring**: Tracks agent status and availability
## Configuration Options
- **Port**: Change the port number as needed
- **Verbose**: Set to False for reduced logging
- **Server Name**: Use a descriptive name for your server
## Next Steps
- See [AOP Cluster Example](aop_cluster_example.md) for multi-server setups
- Check [AOP Reference](../structs/aop.md) for advanced configuration options
- Explore agent communication patterns in the examples directory

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "swarms"
version = "8.4.0"
version = "8.4.1"
description = "Swarms - TGSC"
license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"]

@ -1,6 +1,7 @@
from swarms.structs.agent import Agent
from swarms.structs.agent_loader import AgentLoader
from swarms.structs.agent_rearrange import AgentRearrange, rearrange
from swarms.structs.aop import AOP
from swarms.structs.auto_swarm_builder import AutoSwarmBuilder
from swarms.structs.base_structure import BaseStructure
from swarms.structs.base_swarm import BaseSwarm
@ -100,7 +101,6 @@ from swarms.structs.swarming_architectures import (
staircase_swarm,
star_swarm,
)
from swarms.structs.aop import AOP
__all__ = [
"Agent",

@ -34,15 +34,18 @@ Instructions:
- Use evidence hierarchy: peer-reviewed > industry reports > news > social media. Weight by recency and authority.
- For each claim, assess: source reliability, data quality, potential bias, methodology validity.
- If insufficient evidence, quantify gaps: "Missing: [specific data type] from [timeframe] for [scope]."
Output (400 tokens):
1. Findings (8 bullets, 1 sentence each, [Ref N])
2. Evidence Quality Matrix (Source | Reliability | Recency | Bias Risk | Weight)
3. Confidence (High/Medium/Low + statistical rationale)
4. Data Gaps (3 bullets, specific and actionable)
5. References (numbered, titles + URLs + access date)
Constraints: Systematic verification only. No speculation or analysis.
- Conduct comprehensive literature review and fact-checking protocols.
- Validate information through multiple independent sources when possible.
Output Structure:
1. Key Findings (comprehensive list with supporting evidence and reference numbers)
2. Evidence Quality Matrix (Source | Reliability | Recency | Bias Risk | Weight | Validation Status)
3. Confidence Assessment (High/Medium/Low with detailed statistical rationale and sample size)
4. Data Gaps Analysis (specific missing information with actionable recommendations for filling gaps)
5. Source Verification (detailed assessment of each source's credibility and methodology)
6. References (comprehensive numbered list with titles, URLs, access dates, and quality scores)
Constraints: Systematic verification only. No speculation or analysis. Focus on factual accuracy and evidence quality.
"""
@ -54,15 +57,19 @@ Instructions:
- Use quantitative methods: regression analysis, time series analysis, variance analysis, confidence intervals.
- For each insight, calculate: correlation coefficient, statistical significance (p-value), confidence interval, effect size.
- State assumptions explicitly and test for validity. Identify confounding variables and control for bias.
Output (400 tokens):
1. Analytical Methods (statistical approach + assumptions + limitations)
2. Quantitative Insights (6 items: finding + statistical measure + confidence interval)
3. Statistical Assumptions (3 bullets: assumption + validity test + impact if violated)
4. Uncertainty Analysis (3 bullets: uncertainty type + magnitude + mitigation)
5. Confidence (High/Medium/Low + statistical rationale + sample size)
Constraints: Statistical rigor only. No alternatives or implementation.
- Perform robust statistical testing with appropriate corrections for multiple comparisons.
- Conduct sensitivity analysis to test the robustness of findings.
Output Structure:
1. Analytical Methods (detailed statistical approach, assumptions, limitations, and rationale for method selection)
2. Quantitative Insights (comprehensive findings with statistical measures, confidence intervals, and effect sizes)
3. Statistical Assumptions (detailed assessment of each assumption, validity tests, and impact analysis if violated)
4. Uncertainty Analysis (comprehensive assessment of uncertainty types, magnitudes, and mitigation strategies)
5. Model Validation (goodness-of-fit measures, residual analysis, and model diagnostics)
6. Sensitivity Analysis (robustness testing results and alternative model specifications)
7. Confidence Assessment (High/Medium/Low with detailed statistical rationale, sample size, and power analysis)
Constraints: Statistical rigor only. No alternatives or implementation. Focus on methodological soundness and analytical depth.
"""
ALTERNATIVES_AGENT_PROMPT = """
@ -73,18 +80,24 @@ Instructions:
- Use multi-criteria decision analysis (MCDA): weighted scoring, pairwise comparison, sensitivity analysis.
- For each option, calculate: NPV/ROI, implementation complexity, resource requirements, timeline, success probability.
- Apply scenario analysis: best-case, most-likely, worst-case outcomes with probability distributions.
- Consider stakeholder perspectives and value trade-offs in option evaluation.
- Assess interdependencies and potential synergies between options.
Output (500 tokens):
- Options:
Output Structure:
- Strategic Options:
- Option Name
- Summary (1 sentence)
- Quantitative Scores: Impact X/5, Effort Y/5, Risk Z/5, ROI %, Timeline (months)
- Pros (2), Cons (2), Preconditions (2)
- Scenario Analysis: Best (probability), Most-likely (probability), Worst (probability)
- Decision Matrix: Option | Impact | Effort | Risk | ROI | Timeline | Weighted Score
- Selection Criteria (3 bullets: decision rule + threshold + tie-breaking)
Constraints: Systematic analysis only. No feasibility verification.
- Executive Summary (comprehensive overview of the option)
- Quantitative Analysis: Impact X/5, Effort Y/5, Risk Z/5, ROI %, Timeline (months), Resource Requirements
- Detailed Pros and Cons (comprehensive advantages and disadvantages)
- Implementation Preconditions (detailed requirements and dependencies)
- Scenario Analysis: Best-case (probability), Most-likely (probability), Worst-case (probability)
- Stakeholder Impact Assessment (who benefits/loses and to what degree)
- Comprehensive Decision Matrix: Option | Impact | Effort | Risk | ROI | Timeline | Resource Efficiency | Weighted Score
- Selection Criteria (detailed decision rules, thresholds, and tie-breaking mechanisms)
- Sensitivity Analysis (how changes in weights or criteria affect rankings)
- Risk-Adjusted Recommendations (options ranked by risk-adjusted value)
Constraints: Systematic analysis only. No feasibility verification. Focus on comprehensive option evaluation and strategic thinking.
"""
@ -96,14 +109,19 @@ Instructions:
- Use risk assessment frameworks: probability × impact matrix, failure mode analysis, sensitivity analysis.
- For each claim, assess: evidence quality, source credibility, logical consistency, empirical validity.
- Identify logical fallacies, cognitive biases, and methodological errors. Flag contradictions with statistical confidence.
Output (400 tokens):
1. Verification Matrix (Claim | Status | Evidence Quality | Source Credibility | Confidence | P-value)
2. Risk Assessment (Risk | Probability | Impact | Mitigation | Residual Risk)
3. Logical Consistency Check (Contradiction | Severity | Resolution | Confidence)
4. Feasibility Analysis (Constraint | Impact | Workaround | Probability of Success)
Constraints: Systematic validation only. Objective and evidence-based.
- Conduct comprehensive fact-checking using multiple independent verification sources.
- Apply rigorous quality assurance protocols to ensure accuracy and reliability.
Output Structure:
1. Comprehensive Verification Matrix (Claim | Status | Evidence Quality | Source Credibility | Confidence | P-value | Validation Method)
2. Detailed Risk Assessment (Risk | Probability | Impact | Mitigation Strategy | Residual Risk | Monitoring Requirements)
3. Logical Consistency Analysis (Contradiction | Severity | Resolution Strategy | Confidence Level | Evidence Supporting Resolution)
4. Feasibility Analysis (Constraint | Impact | Workaround Options | Probability of Success | Resource Requirements)
5. Quality Assurance Report (Validation Methods Used | Quality Metrics | Areas of Concern | Recommendations for Improvement)
6. Bias Detection Analysis (Potential Biases | Impact Assessment | Mitigation Strategies | Monitoring Protocols)
7. Evidence Chain Validation (Source Verification | Chain of Custody | Reliability Assessment | Confidence Intervals)
Constraints: Systematic validation only. Objective and evidence-based. Focus on accuracy, reliability, and comprehensive verification.
"""
SYNTHESIS_AGENT_PROMPT = """
@ -114,16 +132,22 @@ Instructions:
- Use decision frameworks: multi-criteria decision analysis (MCDA), analytic hierarchy process (AHP), Pareto optimization.
- For each recommendation, calculate: expected value, risk-adjusted return, implementation probability, resource efficiency.
- Reconcile conflicts using evidence hierarchy: statistical significance > source credibility > recency > sample size.
Output (600 tokens):
1. Executive Summary (6 bullets: key findings + confidence + action items)
2. Integrated Analysis (8 bullets: insight + statistical measure + agent attribution + confidence)
3. Conflict Resolution Matrix (Contradiction | Evidence Weight | Resolution | Confidence)
4. Optimized Recommendations (table: Recommendation | Expected Value | Risk Score | Implementation Probability | Resource Efficiency | Priority)
5. Risk-Optimized Portfolio (Risk | Probability | Impact | Mitigation | Residual Risk | Cost)
6. Implementation Roadmap (Step | Owner | Timeline | Dependencies | Success Metrics | Probability)
Constraints: Systematic optimization only. Evidence-based decision support.
- Integrate insights from all agent perspectives into coherent strategic recommendations.
- Apply advanced optimization techniques to maximize value while minimizing risk and resource requirements.
Output Structure:
1. Executive Summary (comprehensive key findings with confidence levels and prioritized action items)
2. Integrated Analysis (detailed insights with statistical measures, agent attribution, and confidence assessments)
3. Conflict Resolution Matrix (Contradiction | Evidence Weight | Resolution Strategy | Confidence Level | Implementation Plan)
4. Optimized Recommendations (comprehensive table: Recommendation | Expected Value | Risk Score | Implementation Probability | Resource Efficiency | Priority | Timeline)
5. Risk-Optimized Portfolio (Risk | Probability | Impact | Mitigation Strategy | Residual Risk | Cost | Monitoring Requirements)
6. Implementation Roadmap (Step | Owner | Timeline | Dependencies | Success Metrics | Probability | Resource Requirements)
7. Value Optimization Analysis (ROI projections, cost-benefit analysis, and value maximization strategies)
8. Stakeholder Impact Assessment (comprehensive analysis of how recommendations affect different stakeholder groups)
9. Success Metrics and KPIs (detailed measurement framework for tracking implementation success)
10. Contingency Planning (alternative approaches and fallback strategies for high-risk scenarios)
Constraints: Systematic optimization only. Evidence-based decision support. Focus on practical implementation and measurable outcomes.
"""
schema = {

Loading…
Cancel
Save