diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py index 2eca78b5519..d1e65dad252 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py @@ -18,6 +18,7 @@ from litellm._logging import verbose_logger from litellm._uuid import uuid from litellm.types.llms.anthropic import ( AppliedEdit, + CompactionBlock, ContextManagementResponse, UsageDelta, UsageIteration, @@ -62,7 +63,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): model: str, tool_name_mapping: Optional[Dict[str, str]] = None, applied_edits: Optional[List[AppliedEdit]] = None, - compaction_block: Optional[Dict[str, Any]] = None, + compaction_block: Optional[CompactionBlock] = None, iterations_usage: Optional[List[UsageIteration]] = None, ): super().__init__(completion_stream) diff --git a/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py b/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py index ab3a905c64c..0c2a13869e8 100644 --- a/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py +++ b/litellm/llms/anthropic/experimental_pass_through/context_management/dispatcher.py @@ -4,6 +4,7 @@ import inspect from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union, cast from litellm._logging import verbose_logger +from litellm.types.llms.anthropic import AppliedEdit from .constants import CLEAR_TOOL_USES_EDIT_TYPE, COMPACT_EDIT_TYPE from .editors import apply_clear_tool_uses_20250919, apply_compact_20260112 @@ -75,7 +76,7 @@ async def apply_context_management( current_messages = messages current_system = system - aggregated_applied: List[Dict[str, Any]] = [] + aggregated_applied: List[AppliedEdit] = [] aggregated_compaction_block = None aggregated_iterations_usage = None @@ -118,7 +119,7 @@ async def apply_context_management( return PolyfillResult( messages=current_messages, system=current_system, - applied_edits=cast(List[Any], aggregated_applied), + applied_edits=aggregated_applied, compaction_block=aggregated_compaction_block, iterations_usage=aggregated_iterations_usage, )