Skip to content

Prashant lib#48

Merged
Iamsdt merged 6 commits into10xHub:mainfrom
prashant4654:prashant-lib
Feb 18, 2026
Merged

Prashant lib#48
Iamsdt merged 6 commits into10xHub:mainfrom
prashant4654:prashant-lib

Conversation

@prashant4654
Copy link
Contributor

This pull request introduces several improvements and fixes related to Google GenAI integration, especially around handling "reasoning" (thought) content in LLM responses, configuration, and example usage. The most significant changes are the improved extraction and processing of reasoning content, updates to model/provider handling, and enhancements to example scripts for better developer experience.

Reasoning Content Extraction & Processing:

  • Improved extraction of reasoning tokens by using thoughts_token_count from the response metadata instead of hardcoding to zero.
  • Refined the logic for processing parts in LLM responses: reasoning parts are now handled before text parts, ensuring that reasoning content is not duplicated or missed. [1] [2] [3]

Model/Provider Handling & Configuration:

  • Fixed model/provider splitting logic in Agent initialization to properly assign the model name.
  • When building the Google config, added a thinking_config with include_thoughts=True for text output, enabling the model to return reasoning content in its response.
  • Simplified Google GenAI client creation by removing unnecessary keyword arguments.

Example Script Improvements:

  • Updated the example in graph.py to load environment variables using dotenv and ensure GEMINI_API_KEY is set correctly.
  • Changed the model string from gemini/gemini-2.5-flash to google/gemini-2.5-flash for consistency with provider/model conventions.
  • Modified the example input message to ask about the weather in London, making the example more relevant.

Copilot AI review requested due to automatic review settings February 13, 2026 13:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request improves Google GenAI integration in the Agentflow framework, focusing on proper handling of reasoning (thought) content in LLM responses, fixing model/provider splitting logic, and updating configuration. The changes enable the framework to correctly extract and process reasoning tokens from Google's Gemini models that support thinking/reasoning capabilities.

Changes:

  • Fixed critical bug in Agent model/provider splitting logic that prevented proper model name extraction
  • Enhanced reasoning content extraction to handle Google GenAI's thought parts where part.thought=True with content in part.text
  • Added ThinkingConfig to Google GenAI requests to enable reasoning content in responses
  • Updated example to use correct google/ provider prefix and improved dotenv handling

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
examples/agent-class/graph.py Updated model prefix from gemini/ to google/ for Agent class consistency; improved environment variable loading (with redundant logic); changed example query to weather-related
agentflow/graph/agent.py Fixed model name assignment after provider/model split; removed invalid llm_kwargs from Google client initialization; added ThinkingConfig to enable reasoning content extraction
agentflow/adapters/llm/google_genai_converter.py Enhanced reasoning token extraction from metadata; refactored part processing order to prevent content duplication; updated reasoning part handling to correctly extract content from part.text when part.thought is True

- Added new linting rules for specific files in `pyproject.toml`.
- Updated tests for Google GenAI converter to handle reasoning extraction correctly.
- Enhanced OpenAI converter tests with reasoning extraction and token usage details.
- Introduced new tests for OpenAI Responses API converter, covering various response formats.
- Added reasoning tag extraction utilities tests to ensure proper parsing.
- Implemented agent API routing tests to verify fallback mechanisms between responses and chat completions.
- Updated Google Gemini integration tests to use the latest model version and improved message handling.
- Modified base converter tests to include new converter types and ensure enum consistency.
@codecov
Copy link

codecov bot commented Feb 18, 2026

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

agentflow/adapters/llm/openai_converter.py:144

  • The order of content blocks appears inconsistent with the Google converter. In the Google converter, ReasoningBlocks are added before TextBlocks (see google_genai_converter.py lines 141-146), but here TextBlocks are added before ReasoningBlocks. For consistency with the PR's stated goal of "processing reasoning parts before text parts", consider reordering these blocks to add ReasoningBlock first, then TextBlock.
        blocks = []
        if content:
            blocks.append(TextBlock(text=content))
        if reasoning_content:
            blocks.append(ReasoningBlock(summary=reasoning_content))

@prashant4654 prashant4654 marked this pull request as draft February 18, 2026 07:15
@prashant4654 prashant4654 marked this pull request as ready for review February 18, 2026 07:40
@Iamsdt Iamsdt merged commit 896b2ff into 10xHub:main Feb 18, 2026
1 of 2 checks passed
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.

3 participants