Debate & Conflict Resolution
In a multi-agent ecosystem where specialized models analyze different market facets (Technical, Sentiment, Fundamental, and Risk), conflicting signals are a mathematical certainty. The system handles these discrepancies through a structured four-phase resolution pipeline designed to move from individual divergence to a unified trading decision.
The Resolution Pipeline
The TradingOrchestrator manages the lifecycle of a trade recommendation by coordinating individual agent outputs and determining if the "Debater" agent is required to intervene.
Phase 1: Individual Analysis
Each agent (Technical, Sentiment, Fundamental, Risk) independently generates an AgentRecommendation. At this stage, agents are unaware of each other's findings to prevent "groupthink" and ensure diverse perspectives.
Phase 2: Conflict Detection
The system performs a conflict check by aggregating the recommendation field from all agents.
- Consensus: If all agents agree on a direction (e.g., all "BUY"), the system proceeds directly to the final decision.
- Conflict: If there is a split (e.g., Technical suggests "BUY" while Risk suggests "HOLD"), the Conflict Check flags the state for Phase 3.
Phase 3: The Debate Agent
When conflicts are detected, the Debater Agent is invoked. This agent receives the full context of the market data and the contradictory reasoning from the specialized agents.
Its role is not to simply pick a winner, but to:
- Evaluate Evidence: Determine which agent's data points are more relevant under current market conditions (e.g., prioritizing Risk over Technical during high-volatility events).
- Synthesize Perspectives: Create a meta-analysis that addresses why the agents disagreed.
- Propose a Resolution: Offer a final recommendation based on the weight of the collective evidence.
Phase 4: Final Decision & Weighted Voting
The final output is determined by a combination of the Debater's synthesis and the statistical majority. The system calculates:
- Vote Count: The distribution of BUY, SELL, and HOLD across the four agents.
- Average Confidence: The mean of the
confidencescores (0-100) provided by the agents. - Dominant Signal: The final recommendation generated after the debate logic is applied.
Using Conflict Resolution
To utilize the debate mechanism, you must enable it via the TradingOrchestrator during the analysis call.
Basic Usage
from orchestrator import TradingOrchestrator
# Initialize the orchestrator
orchestrator = TradingOrchestrator(backend="ollama")
# Market context to analyze
market_data = "Bitcoin is at $65,000. RSI is 75. News is positive but volatility is spiking."
# Run analysis with debate enabled
result = orchestrator.analyze(market_data, enable_debate=True)
# Access the decision metadata
decision = result["phase_4_decision"]
print(f"Final Action: {decision['recommendation']}")
print(f"Confidence: {decision['average_confidence']}%")
print(f"Votes: {decision['vote_count']}")
Interpreting the Output
The system returns a structured dictionary containing the full lineage of the conflict resolution. This is useful for auditing why a specific trade was or was not taken.
| Field | Description |
| :--- | :--- |
| phase_2_conflict_check | Contains the individual_votes mapping (e.g., {'technical': 'BUY', 'risk': 'HOLD'}). |
| phase_3_debate | The text-based synthesis from the Debater agent (if triggered). |
| vote_count | A dictionary tallying the recommendations (e.g., {'BUY': 3, 'HOLD': 1, 'SELL': 0}). |
| average_confidence | The aggregated confidence level across all specialized agents. |
Configuration & Schemas
The conflict resolution logic relies on the AgentRecommendation Pydantic model defined in agents/schemas.py. This ensures that every agent, regardless of its domain, speaks the same "language" for the orchestrator to parse.
class AgentRecommendation(BaseModel):
recommendation: Literal["BUY", "SELL", "HOLD"]
confidence: int # 0 to 100
reasoning: str # Detailed explanation
key_factors: List[str]
Manual Overrides
While the system defaults to the consensus/debate model, you can access individual agent results via result["phase_1_analyses"] if you wish to implement custom threshold logic (e.g., "Only trade if Risk Agent gives a BUY signal, regardless of others").