fix(py): fix structlog config blowaway, DeepSeek reasoning, and double JSON encoding#4625
fix(py): fix structlog config blowaway, DeepSeek reasoning, and double JSON encoding#4625
Conversation
Summary of ChangesHello @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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
…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).
cfed952 to
f84c69c
Compare
There was a problem hiding this comment.
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.
structlog config preservation (5 plugins):
config (wrapper_class, logger_factory, cache_logger_on_first_use)
by merging via structlog.get_config() before overwriting.
microsoft-foundry, observability
DeepSeek multi-round reasoning (compat-oai):
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.
Double JSON encoding (provider-compat-oai-hello):
(raw JSON string) with output=Output(schema=WeatherResponse), causing
double encoding. Changed to return WeatherResponse.model_validate(
response.output).