# Configuring Tool-Level Vendor Overrides for Data Sources in TradingAgents

> Learn to configure tool-level vendor overrides for TradingAgents data sources. Easily set specific vendor preferences for individual tools, giving you granular control.

- Repository: [Tauric Research/TradingAgents](https://github.com/TauricResearch/TradingAgents)
- Tags: how-to-guide
- Published: 2026-03-23

---

**You can override data source vendors for individual tools in TradingAgents by populating the `tool_vendors` dictionary in the configuration, which takes precedence over category-level defaults defined in `data_vendors`.**

TradingAgents implements a flexible vendor-routing layer that enables granular control over data source selection at the tool level. By configuring **tool-level vendor overrides**, you can specify exactly which provider—such as *yfinance* or *alpha_vantage*—powers specific functions like `get_stock_data` without altering the default behavior for entire API categories. The following guide explains the architecture and implementation based on the TauricResearch/TradingAgents source code.

## Understanding the Vendor Routing Architecture

The system uses a two-tier hierarchy: **category-level defaults** and **tool-specific overrides**. This design allows coarse-grained defaults with surgical precision where needed.

### Default Configuration Structure

In [`tradingagents/default_config.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/default_config.py), the base mappings establish which vendor handles each API category. The `data_vendors` dictionary defines defaults for broad categories like `core_stock_apis`, `technical_indicators`, and `fundamentals`, while an empty `tool_vendors` dictionary awaits fine-grained overrides (lines 23–34).

```python

# tradingagents/default_config.py

data_vendors = {
    "core_stock_apis": "yfinance",
    "technical_indicators": "yfinance",
    "fundamentals": "alpha_vantage"
}

# Empty by default; populate this to override specific tools

tool_vendors = {}

```

### Runtime Configuration Management

The [`tradingagents/dataflows/config.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/dataflows/config.py) module provides the runtime interface for manipulating these settings. It exposes `set_config()` to mutate the global configuration and `get_config()` for retrieval by the rest of the codebase (lines 1–30).

```python
from tradingagents.dataflows.config import set_config

# Apply custom vendor mapping globally

set_config({
    "tool_vendors": {
        "get_stock_data": "alpha_vantage"
    }
})

```

## Implementing Tool-Level Vendor Overrides

Once you understand the configuration structure, you can implement overrides either globally for the application session or verify exactly which vendor is active.

### Global Overrides via set_config

To permanently change the vendor for a specific tool across your entire application, populate the `tool_vendors` dictionary before initializing agents.

**Single tool override:**

```python
from tradingagents.dataflows.config import set_config

# Force get_stock_data to use Alpha Vantage instead of yfinance

set_config({
    "tool_vendors": {
        "get_stock_data": "alpha_vantage"
    }
})

```

**Multiple tools via custom configuration file:**

```python

# custom_config.py

CUSTOM_OVERRIDES = {
    "tool_vendors": {
        "get_stock_data": "alpha_vantage",
        "get_news": "alpha_vantage"
    }
}

```

```python

# main.py

from tradingagents.dataflows.config import set_config
from custom_config import CUSTOM_OVERRIDES

set_config(CUSTOM_OVERRIDES)

# Now get_stock_data and get_news use Alpha Vantage;

# other tools continue using category defaults from data_vendors

```

### Verifying Active Vendors

To confirm which vendor implementation is assigned to a specific tool, use the `get_vendor` function from the interface module. This resolves the actual vendor by checking `tool_vendors` first, then falling back to the category default.

```python
from tradingagents.dataflows.interface import get_vendor

vendor = get_vendor("core_stock_apis", "get_stock_data")
print(vendor)  # → "alpha_vantage" if overridden, otherwise "yfinance"

```

### Temporary Runtime Overrides

For one-off requests without global state changes, you can temporarily mutate the configuration. Note that the library currently resolves vendors from global config, so you must save and restore the original state when implementing per-call overrides (lines 19–33 in [`interface.py`](https://github.com/TauricResearch/TradingAgents/blob/main/interface.py)).

```python
from tradingagents.dataflows.config import get_config, set_config
from tradingagents.dataflows.interface import route_to_vendor

def get_stock_data_temp_override(symbol, start, end):
    # Store original state

    original_config = get_config()
    
    # Temporarily force alpha_vantage

    set_config({
        **original_config,
        "tool_vendors": {**original_config.get("tool_vendors", {}), 
                        "get_stock_data": "alpha_vantage"}
    })
    
    try:
        return route_to_vendor("get_stock_data", symbol, start, end)
    finally:
        # Restore original configuration

        set_config(original_config)

```

## How the Routing Logic Works

The [`tradingagents/dataflows/interface.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/dataflows/interface.py) file implements the core resolution logic. The `get_vendor(category, method)` function (lines 19–33) first inspects `tool_vendors` for a method-specific entry; if absent, it falls back to the `category` entry from `data_vendors`.

The `route_to_vendor(method, …)` function (lines 34–62) obtains the vendor list, constructs a fallback chain, and dispatches to concrete implementations like `get_alpha_vantage_stock` or `get_YFin_data_online`. If Alpha Vantage returns a rate-limit error, the router automatically triggers fallback logic to the next available vendor. Individual tools such as `get_stock_data` in [`tradingagents/agents/utils/core_stock_tools.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/agents/utils/core_stock_tools.py) simply delegate to `route_to_vendor`, remaining agnostic to the underlying data source.

## Summary

- **Configuration hierarchy**: [`tradingagents/default_config.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/default_config.py) defines category-level defaults in `data_vendors` and reserves `tool_vendors` for tool-specific overrides.
- **Runtime control**: Use `set_config()` from [`tradingagents/dataflows/config.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/dataflows/config.py) to apply overrides globally without modifying source files.
- **Resolution order**: The `get_vendor()` function checks `tool_vendors` first, then falls back to the category default, ensuring granular overrides take precedence.
- **Automatic fallback**: The `route_to_vendor()` implementation handles rate-limit errors and vendor chaining automatically, providing resilience when primary sources fail.

## Frequently Asked Questions

### What is the priority order for vendor selection?

The system checks the `tool_vendors` dictionary first for an exact method name match. If no entry exists, it falls back to the category-level mapping in `data_vendors`. This ensures that tool-level vendor overrides always take precedence over broader category defaults.

### Can I use multiple fallback vendors for a single tool?

Yes. The `route_to_vendor()` function in [`tradingagents/dataflows/interface.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/dataflows/interface.py) builds a fallback chain from the vendor configuration. If the primary vendor (e.g., Alpha Vantage) returns a rate-limit error, the system automatically attempts the next configured vendor in the chain until successful or the chain is exhausted.

### How do I check which vendor is currently active for a specific tool?

Import `get_vendor` from [`tradingagents/dataflows/interface.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/dataflows/interface.py) and call it with the category name and method name as arguments. This returns the resolved vendor string (e.g., `"alpha_vantage"` or `"yfinance"`) based on the current configuration state, reflecting any active tool-level overrides.

### Does overriding a tool vendor affect all agents in the application?

Yes. Because TradingAgents uses a global configuration object managed by [`tradingagents/dataflows/config.py`](https://github.com/TauricResearch/TradingAgents/blob/main/tradingagents/dataflows/config.py), changes made via `set_config()` apply application-wide. All subsequent calls to the overridden tool—from any agent or module—will use the newly specified vendor until the configuration is modified again or the process restarts.