Skip to content

fix(py): fix structlog config blowaway, DeepSeek reasoning, and double JSON encoding#4625

Merged
yesudeep merged 1 commit intomainfrom
yesudeep/fix/poised-banana
Feb 12, 2026
Merged

fix(py): fix structlog config blowaway, DeepSeek reasoning, and double JSON encoding#4625
yesudeep merged 1 commit intomainfrom
yesudeep/fix/poised-banana

Conversation

@yesudeep
Copy link
Contributor

structlog config preservation (5 plugins):

  • Changed structlog.configure(processors=...) to preserve existing
    config (wrapper_class, logger_factory, cache_logger_on_first_use)
    by merging via structlog.get_config() before overwriting.
  • Affected: amazon-bedrock, cloudflare-workers-ai, google-cloud,
    microsoft-foundry, observability

DeepSeek multi-round reasoning (compat-oai):

  • Skip ReasoningPart in MessageConverter.to_openai() so
    reasoning_content is not sent back in multi-turn context.
    DeepSeek's API rejects it, and the JS canonical impl naturally
    excludes it by using msg.text for assistant messages.
  • Added 3 tests in compat_oai_utils_test.py.

Double JSON encoding (provider-compat-oai-hello):

  • get_weather_flow and get_weather_flow_stream returned response.text
    (raw JSON string) with output=Output(schema=WeatherResponse), causing
    double encoding. Changed to return WeatherResponse.model_validate(
    response.output).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yesudeep, 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 addresses three key issues: preserving structlog configurations across multiple plugins, ensuring compatibility with DeepSeek's API by handling multi-round reasoning correctly, and fixing double JSON encoding in specific flows. These changes improve the reliability and compatibility of the Genkit framework with various services and models.

Highlights

  • Structlog Configuration Preservation: Ensured that existing structlog configurations are preserved when new processors are added in multiple plugins by merging with existing configurations.
  • DeepSeek Multi-Round Reasoning Compatibility: Modified the MessageConverter to skip ReasoningPart in to_openai() to prevent reasoning_content from being sent back in multi-turn contexts, aligning with DeepSeek's API requirements and the JS canonical implementation. Added corresponding tests.
  • Double JSON Encoding Fix: Corrected double JSON encoding in get_weather_flow and get_weather_flow_stream by returning WeatherResponse objects instead of raw JSON strings.

🧠 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.

Changelog
  • amazon-bedrock
    • Ensured structlog configurations are preserved when injecting X-Ray trace context.
  • cloudflare-workers-ai
    • Ensured structlog configurations are preserved when injecting trace context.
  • compat-oai
    • Modified MessageConverter to skip ReasoningPart in to_openai() for DeepSeek compatibility.
    • Added tests for ReasoningPart stripping in compat_oai_utils_test.py.
  • google-cloud
    • Ensured structlog configurations are preserved when injecting GCP trace context.
  • microsoft-foundry
    • Ensured structlog configurations are preserved when injecting Azure trace context.
  • observability
    • Ensured structlog configurations are preserved when injecting observability trace context.
  • provider-compat-oai-hello
    • Corrected double JSON encoding in get_weather_flow and get_weather_flow_stream.
Activity
  • Addressed structlog configuration blowaway issue.
  • Improved DeepSeek reasoning compatibility.
  • Fixed double JSON encoding problem.
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.

…e JSON encoding

structlog config preservation (5 plugins):
- Changed structlog.configure(processors=...) to preserve existing
  config (wrapper_class, logger_factory, cache_logger_on_first_use)
  by merging via structlog.get_config() before overwriting.
- Affected: amazon-bedrock, cloudflare-workers-ai, google-cloud,
  microsoft-foundry, observability

DeepSeek multi-round reasoning (compat-oai):
- Skip ReasoningPart in MessageConverter.to_openai() so
  reasoning_content is not sent back in multi-turn context.
  DeepSeek's API rejects it, and the JS canonical impl naturally
  excludes it by using msg.text for assistant messages.
- Added 3 tests in compat_oai_utils_test.py.

Double JSON encoding (provider-compat-oai-hello):
- get_weather_flow and get_weather_flow_stream returned response.text
  (raw JSON string) with output=Output(schema=WeatherResponse), causing
  double encoding. Changed to return WeatherResponse.model_validate(
  response.output).
@yesudeep yesudeep force-pushed the yesudeep/fix/poised-banana branch from cfed952 to f84c69c Compare February 12, 2026 21:14
@yesudeep yesudeep enabled auto-merge (squash) February 12, 2026 21:15
Copy link
Contributor

@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 pull request delivers three valuable fixes. First, it correctly preserves existing structlog configurations across five plugins by merging new processors instead of overwriting the entire configuration. This enhances the robustness of logging initialization. Second, it addresses a compatibility issue with DeepSeek models by stripping ReasoningPart from multi-turn conversation history, a change that is well-supported by new tests. Finally, it resolves a double JSON encoding bug in a sample application by correctly validating structured output from model generation calls. The changes are well-implemented and improve the codebase's correctness and maintainability. I have one minor stylistic suggestion to improve code readability.

@yesudeep yesudeep disabled auto-merge February 12, 2026 21:16
@yesudeep yesudeep enabled auto-merge (squash) February 12, 2026 21:16
@yesudeep yesudeep merged commit ea0223b into main Feb 12, 2026
21 checks passed
@yesudeep yesudeep deleted the yesudeep/fix/poised-banana branch February 12, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants