fix(cache): cache all system messages and stabilize task tool descriptions#3091
Merged
tusharmath merged 4 commits intomainfrom Apr 20, 2026
Merged
fix(cache): cache all system messages and stabilize task tool descriptions#3091tusharmath merged 4 commits intomainfrom
tusharmath merged 4 commits intomainfrom
Conversation
…tions The main changes in this PR: 1. **Anthropic cache strategy fix**: Previously only the first system message was cached, now all system messages are cached. This ensures the static system prefix remains reusable. The logic also falls back to caching the first conversation message when there's no system prompt. 2. **Stabilize task tool descriptions**: Added sorting of agents by ID before generating task tool descriptions to ensure deterministic output regardless of agent order. 3. **Stabilize skill loading**: Added sorting of skills by name (and resources by path) to ensure deterministic skill loading order. Key implementation details: - Modified `SetCache` transformer to cache all system messages instead of just the first - Added `agents.sort_by(|left, right| left.id.as_str().cmp(right.id.as_str()))` in tool_registry.rs - Added `sort_skills()` and `sort_paths()` functions in skill.rs with comprehensive tests - Updated tests to verify stable ordering behavior Breaking changes: None Testing: - Updated existing tests in set_cache.rs to reflect new caching behavior - Added `test_task_tool_description_is_stable_across_agent_order` test - Added `test_sort_skills_orders_names_and_resources` test - Updated snapshot tests for tool descriptions
Collaborator
|
Related to #3076 |
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.
The main changes in this PR:
Anthropic cache strategy fix: Previously only the first system message was cached, now all system messages are cached. This ensures the static system prefix remains reusable. The logic also falls back to caching the first conversation message when there's no system prompt.
Stabilize task tool descriptions: Added sorting of agents by ID before generating task tool descriptions to ensure deterministic output regardless of agent order.
Stabilize skill loading: Added sorting of skills by name (and resources by path) to ensure deterministic skill loading order.
Key implementation details:
SetCachetransformer to cache all system messages instead of just the firstagents.sort_by(|left, right| left.id.as_str().cmp(right.id.as_str()))in tool_registry.rssort_skills()andsort_paths()functions in skill.rs with comprehensive testsBreaking changes: None
Testing:
test_task_tool_description_is_stable_across_agent_ordertesttest_sort_skills_orders_names_and_resourcestest