Skip to content

Commit ca9b9f5

Browse files
committed
Fix: Stop after all primary vendors in multi-vendor config
When multiple primary vendors are configured (e.g., 'reddit,alpha_vantage'), the system now correctly stops after attempting all primary vendors instead of continuing through all fallback vendors. Changes: - Track which primary vendors have been attempted in a list - Add stopping condition when all primary vendors are attempted - Preserve existing single-vendor behavior (stop after first success) This prevents unnecessary API calls and ensures predictable behavior.
1 parent 13b826a commit ca9b9f5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tradingagents/dataflows/interface.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def route_to_vendor(method: str, *args, **kwargs):
166166
# Track results and execution state
167167
results = []
168168
vendor_attempt_count = 0
169-
any_primary_vendor_attempted = False
169+
primary_vendors_attempted = []
170170
successful_vendor = None
171171

172172
for vendor in fallback_vendors:
@@ -179,10 +179,6 @@ def route_to_vendor(method: str, *args, **kwargs):
179179
is_primary_vendor = vendor in primary_vendors
180180
vendor_attempt_count += 1
181181

182-
# Track if we attempted any primary vendor
183-
if is_primary_vendor:
184-
any_primary_vendor_attempted = True
185-
186182
# Debug: Print current attempt
187183
vendor_type = "PRIMARY" if is_primary_vendor else "FALLBACK"
188184
print(f"DEBUG: Attempting {vendor_type} vendor '{vendor}' for {method} (attempt #{vendor_attempt_count})")
@@ -214,18 +210,26 @@ def route_to_vendor(method: str, *args, **kwargs):
214210
print(f"FAILED: {impl_func.__name__} from vendor '{vendor_name}' failed: {e}")
215211
continue
216212

213+
# Track which primary vendors we've attempted
214+
if is_primary_vendor:
215+
primary_vendors_attempted.append(vendor)
216+
217217
# Add this vendor's results
218218
if vendor_results:
219219
results.extend(vendor_results)
220220
successful_vendor = vendor
221221
result_summary = f"Got {len(vendor_results)} result(s)"
222222
print(f"SUCCESS: Vendor '{vendor}' succeeded - {result_summary}")
223223

224-
# Stopping logic: Stop after first successful vendor for single-vendor configs
225-
# Multiple vendor configs (comma-separated) may want to collect from multiple sources
224+
# Stopping logic:
225+
# - Single vendor config: Stop after first success
226+
# - Multi-vendor config: Stop after all primary vendors attempted
226227
if len(primary_vendors) == 1:
227228
print(f"DEBUG: Stopping after successful vendor '{vendor}' (single-vendor config)")
228229
break
230+
elif set(primary_vendors_attempted) == set(primary_vendors):
231+
print(f"DEBUG: All primary vendors attempted ({', '.join(primary_vendors_attempted)}), stopping")
232+
break
229233
else:
230234
print(f"FAILED: Vendor '{vendor}' produced no results")
231235

0 commit comments

Comments
 (0)