fix: improve type safety in legacy config migration#375
Open
hobostay wants to merge 1 commit intobytedance:mainfrom
Open
fix: improve type safety in legacy config migration#375hobostay wants to merge 1 commit intobytedance:mainfrom
hobostay wants to merge 1 commit intobytedance:mainfrom
Conversation
- Add None check for top_k with default value fallback - Extract provider_config variable to reduce code duplication - Improve code readability and maintainability This prevents potential type errors when migrating from legacy JSON configs and makes the code more defensive against edge cases. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
maharab549
pushed a commit
to maharab549/trae-agent
that referenced
this pull request
Mar 1, 2026
This workflow creates two offical container images: * `ghcr.io/codingjoe/deer-flow:main` * `ghcr.io/codingjoe/deer-flow-web:main`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves type safety in the legacy configuration migration code by adding defensive checks for
top_kparameter.Changes
provider_configvariable to eliminate code duplicationProblem
When migrating from legacy JSON configs, the
top_kfield could theoretically be None, which would cause type mismatches sinceModelConfig.top_kexpects anint.Solution
Added defensive check:
top_k=provider_config.top_k if provider_config.top_k is not None else 0This ensures we always pass a valid int value to ModelConfig, maintaining backward compatibility while improving type safety.
Testing
🤖 Generated with Claude Code