Skip to content

Fix/gemini thinking mode #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 19, 2025
Merged

Fix/gemini thinking mode #127

merged 8 commits into from
Jul 19, 2025

Conversation

sartorijr92
Copy link
Contributor

@sartorijr92 sartorijr92 commented Jul 19, 2025

This pull request addresses several issues and improvements in the kodustech/kodus-ai repository, specifically targeting the Gemini thinking mode. Key changes include:

  1. Error Handling and Optional Chaining: Introduces optional chaining in generate-issues-from-pr-closed.use-case.ts to prevent null reference errors when accessing organizationId. However, it highlights a potential issue where a cache-clearing function might be called with undefined, suggesting the need for a conditional check.

  2. Custom String Output Parser: Refactors multiple services to replace the standard StringOutputParser with a CustomStringOutputParser. This change is applied across various files, including commentManager.service.ts, crossFileAnalysis.service.ts, llmAnalysis.service.ts, promptRunner.service.ts, kodyIssuesAnalysis.service.ts, kodyRulesAnalysis.service.ts, kodyRulesPrLevelAnalysis.service.ts, and codeASTAnalysis.service.ts. The custom parser aims to enhance compatibility, robustness, and specialized handling of LLM-generated JSON output.

  3. LLM Provider Enhancements: Updates in llmModelProvider.helper.ts and llmProvider.service.ts include replacing ChatGoogleGenerativeAI with ChatGoogle for Gemini models and introducing a maxReasoningTokens parameter. This parameter is integrated into model configurations and error logging metadata, with a fallback to default values.

  4. Logical Flaw in Custom Parser: The newly introduced CustomStringOutputParser in langchainCommon/customStringOutputParser.ts contains a logical flaw, where it incorrectly accesses a property on an array, affecting the filtering of 'reasoning' content blocks.

Overall, this pull request focuses on improving error handling, enhancing parsing logic, and updating LLM provider configurations to support the Gemini thinking mode.

@sartorijr92 sartorijr92 self-assigned this Jul 19, 2025

This comment has been minimized.

Copy link

kodus-ai bot commented Jul 19, 2025

kody code-review Kody Rules critical

Changes were made to the Google Gemini integration in llmModelProvider.helper.ts, which uses the process.env.API_GOOGLE_AI_API_KEY variable. Please check with @wellington to confirm if any updates are required for this environment variable in the self-hosted environment due to these changes. Kody Rule violation: Verificar atualizações de variáveis de ambiente

Comment on lines 64 to 65
maxReasoningTokens:
options.maxReasoningTokens ?? strategy.maxReasoningTokens,
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules critical

maxReasoningTokens: options.maxReasoningTokens,

The code attempts to access strategy.maxReasoningTokens within a block where strategy is known to be undefined. The if (!strategy) condition on line 55 ensures that this code path is only executed when strategy is falsy. Accessing a property on an undefined object will cause a TypeError, crashing the error logging process. The logger should only reference options.maxReasoningTokens since the strategy-based fallback is not available in this context.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Comment on lines +6 to +9
if (content?.type === 'reasoning') {
return '';
}
return super._messageContentComplexToString(content);
Copy link

Choose a reason for hiding this comment

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

kody code-review Potential Issues critical

        const filteredContent = content.filter((item: { type: string }) => item.type !== 'reasoning');
        return super._messageContentComplexToString(filteredContent);

The content parameter is of type MessageContentComplex, which is an array of content blocks (e.g., {type: 'text', ...}). The current code content?.type attempts to access a type property on this array, which will always be undefined. As a result, the condition content?.type === 'reasoning' is never met, and the custom logic has no effect.

To correctly handle 'reasoning' content blocks, you should filter the content array to remove items of that type before passing the array to the parent method for string conversion. This will correctly remove reasoning steps while preserving other useful content.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Copy link

@kodus-ai kodus-ai bot left a comment

Copy link

kodus-ai bot commented Jul 19, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

Copy link

kodus-ai bot commented Jul 19, 2025

kody code-review Kody Rules critical

The introduction of the maxReasoningTokens parameter in llmProvider.service.ts suggests a new configuration may be required. Per our process for environment-related changes, please mention @wellington to verify if this new setting needs to be configured in the self-hosted environment's variables (e.g., in the .env file). Kody Rule violation: Verificar atualizações de variáveis de ambiente

@sartorijr92 sartorijr92 merged commit 335f3d1 into main Jul 19, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants