Skip to content

feat: multi-provider support, retry logic, and dynamic model fetching#324

Open
MUmarJ wants to merge 7 commits intoTauricResearch:mainfrom
MUmarJ:umar/dynamic_fetch_web_search
Open

feat: multi-provider support, retry logic, and dynamic model fetching#324
MUmarJ wants to merge 7 commits intoTauricResearch:mainfrom
MUmarJ:umar/dynamic_fetch_web_search

Conversation

@MUmarJ
Copy link

@MUmarJ MUmarJ commented Jan 17, 2026

Summary

This PR adds several improvements to enhance multi-LLM provider support, error handling, and CLI usability.

Changes

1. Content Normalization for Multi-Provider Support

  • Added normalize_content() utility to handle Gemini's list-of-dicts response format alongside OpenAI/Anthropic strings
  • Applied normalization in all analyst modules (market, news, fundamentals, social media)

2. Retry Logic with Exponential Backoff

  • Added retry logic with exponential backoff (1s, 2s, 4s) for transient network errors
  • Smart error categorization: retries for connection/timeout errors, immediate vendor fallback for rate limits
  • Better logging with RETRY/TRANSIENT_ERROR/RATE_LIMIT states

3. OpenAI Responses API Support (GPT-5 Ready)

  • New tradingagents/llm/ module with LangChain-compatible Responses API wrapper
  • Auto-detection of models requiring Responses API (gpt-5*, codex*)
  • Dynamic web_search tool type selection based on FETCH_LATEST env var
  • Robust response text extraction that handles varying output structures

4. Configuration Validation for Local LLM Providers

  • Added validate_config() that warns when using local LLM with OpenAI-only data vendors
  • LM Studio added to supported providers list
  • Actionable recommendations for incompatible configurations

5. Dynamic Model Fetching & CLI Enhancements

  • Dynamic model fetching from OpenAI, Anthropic, Google APIs when FETCH_LATEST=true
  • Provider availability checking with health probes for local providers (Ollama, LM Studio)
  • Updated static model lists with latest models (Gemini 2.5/3, new OpenRouter models)
  • Separate "Quick-Thinking" and "Deep-Thinking" model selection steps
  • Disabled options shown with reasons ("No API key", "Not running")

Issues Addressed

Handle Gemini's list-of-dicts response format alongside OpenAI/Anthropic strings
Retry connection/timeout errors with backoff, skip retry for rate limits
Add ChatOpenAIResponses wrapper, dynamic web_search tool selection, robust response parsing
Warn when using local LLM with OpenAI-only data vendors, suggest alternatives
Fetch latest models from provider APIs, add LM Studio support, improve provider selection UX
@gemini-code-assist
Copy link

Summary of Changes

Hello @MUmarJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the system's flexibility and resilience by expanding support for multiple Large Language Model (LLM) providers, including dynamic model fetching and robust error handling. It refines the user experience through an enhanced command-line interface that intelligently guides model selection and provides clear feedback on provider availability, ensuring smoother operations and broader compatibility with cutting-edge LLMs.

Highlights

  • Enhanced Multi-Provider Support: Implemented content normalization for varied LLM response formats (e.g., Gemini's list-of-dicts vs. OpenAI/Anthropic strings) across all analyst modules to ensure consistent processing.
  • Robust Error Handling: Introduced retry logic with exponential backoff for transient network errors and smart error categorization to handle rate limits by falling back to other vendors, improving system resilience.
  • OpenAI Responses API Integration: Added a new LangChain-compatible module to support OpenAI's Responses API, enabling compatibility with newer models like GPT-5 and dynamic web search tool selection based on feature flags.
  • Improved CLI Usability & Dynamic Model Fetching: The CLI now dynamically fetches the latest models from various LLM providers, includes health probes for local providers (Ollama, LM Studio), and offers separate 'Quick-Thinking' and 'Deep-Thinking' model selection with clear availability reasons.
  • Configuration Validation: Added a validation step to warn users about incompatible configurations when using local LLM providers with OpenAI-only data vendors, providing actionable recommendations.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@MUmarJ
Copy link
Author

MUmarJ commented Jan 17, 2026

Tested thoroughly with the following params:

  • Symbol: ESTC
  • Date: 2026-01-16
  • All agents
  • Shallow: gpt-5.1-codex-mini
  • Deep: gpt-5.2

These are updates I made for my own testing to get better results with new models + lower cost web_search api while mainting backcompat when FETCH_LATEST .env is set to false - which allows you to use old GPT 4o models with web_search_preview tool and old API v1/chat versus the new /v1/response API for gpt-5 onwards

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a substantial pull request that introduces significant enhancements, including multi-provider support, dynamic model fetching, and robust error handling with retry logic. The addition of a wrapper for OpenAI's Responses API is a great forward-looking feature. The code is generally well-structured and the CLI improvements provide a much better user experience. I've identified a few areas for improvement, including more specific exception handling, refactoring duplicated code, and a potential issue in the new ChatOpenAIResponses wrapper that could affect tool usage. Overall, this is a very strong contribution.

Move RateLimitError to break block, use specific exceptions, remove duplicate entry
Adds --date arg to filter reports by date and auto-generate filename with date and symbols
@MUmarJ MUmarJ force-pushed the umar/dynamic_fetch_web_search branch from 798d030 to b950e3a Compare January 20, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant