Skip to content

Conversation

@KevinZhao
Copy link
Contributor

@KevinZhao KevinZhao commented Jul 6, 2025

  1. Add ModelConfigCache class for model config caching strategy\n2. Remove deprecated legacy model definitions\n3. Optimize cross-region inference and custom ARN handling\n4. Add comprehensive test suite for cache functionality

Related GitHub Issue

Closes: #5419, #5420

Roo Code Task Context (Optional)

Description

Creating simple caching for model configuration to avoid multi invocation of getModel()
Remove some legacy models or embedding models.

Test Procedure

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Introduces caching for model configurations in AwsBedrockHandler, removes deprecated models, and adds tests for cache functionality.

  • Caching:
    • Introduces ModelConfigCache class in bedrock.ts for caching model configurations.
    • AwsBedrockHandler uses ModelConfigCache to cache results of getModel().
    • Cache key generated based on ProviderSettings.
    • Cache invalidated when configuration changes.
  • Model Definitions:
    • Removes deprecated model definitions from bedrockModels in bedrock.ts.
  • Testing:
    • Adds bedrock-cache-strategy.spec.ts to test caching functionality.
    • Tests cover cache retrieval, cache key generation, cache invalidation, and performance benefits.
  • Misc:
    • Optimizes cross-region inference and custom ARN handling in AwsBedrockHandler.

This description was created by Ellipsis for e81ff4d. You can customize this summary. It will automatically update as commits are pushed.

1. Add ModelConfigCache class for model config caching strategy\n2. Remove deprecated legacy model definitions\n3. Optimize cross-region inference and custom ARN handling\n4. Add comprehensive test suite for cache functionality
@KevinZhao KevinZhao requested review from cte, jr and mrubens as code owners July 6, 2025 15:01
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 6, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 6, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 6, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 6, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Hey @KevinZhao I reviewed your PR and left a couple of suggestions.

Let me know if you have any questions!

logger.debug("Computed and cached new model config", {
ctx: "bedrock",
modelId: config.id,
})
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering about memory management for long-running applications. Since cache entries are never evicted, could this potentially lead to memory issues if many different model configurations are used over time? Would it make sense to implement a cache size limit or TTL (time-to-live) for entries?

return config
}

private computeModelConfig(): ModelConfigResult {
Copy link
Member

Choose a reason for hiding this comment

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

Should we add error handling for the cache operations? While Map operations are generally safe, if we extend this cache in the future or if there are edge cases, having try-catch blocks could prevent unexpected failures from affecting the main flow.

ConverseCommand: vi.fn(),
}
})

Copy link
Member

Choose a reason for hiding this comment

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

Instead of using as any to access private properties, would it be cleaner to either make these properties protected for testing purposes or use a testing utility that provides type-safe access to private members? This would improve type safety in the tests.

expect(getModelByIdSpy).toHaveBeenCalledWith("anthropic.claude-3-5-sonnet-20241022-v2:0", "inference-profile")

// Verify that getModel returns the updated model info
// 在这里模拟 invokedModelId 后模型的 inputPrice 被更新为 8
Copy link
Member

Choose a reason for hiding this comment

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

Could we translate these Chinese comments to English for consistency? The comments explain that this simulates the model's inputPrice being updated to 8 after invokedModelId, which is a key part of the test verification.

Copy link
Member

Choose a reason for hiding this comment

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

The PR description mentions performance optimization, but I don't see any benchmarks or performance metrics. Would it be helpful to add performance tests that demonstrate the actual improvement? This would validate the optimization claims and help prevent performance regressions in the future.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jul 10, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Changes Requested size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Use proper AWS Bedrock model

3 participants