chore: import upstream snapshot with attribution
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run

This commit is contained in:
wehub-resource-sync
2026-07-13 13:21:23 +08:00
commit b957a53def
5423 changed files with 863745 additions and 0 deletions
@@ -0,0 +1,23 @@
# Copyright (c) Microsoft. All rights reserved.
import logging
from abc import ABC
from pydantic import Field
from typing_extensions import deprecated
from semantic_kernel.kernel_pydantic import KernelBaseModel
from semantic_kernel.reliability.pass_through_without_retry import PassThroughWithoutRetry
from semantic_kernel.reliability.retry_mechanism_base import RetryMechanismBase
logger: logging.Logger = logging.getLogger(__name__)
class KernelReliabilityExtension(KernelBaseModel, ABC):
"""Kernel reliability extension."""
retry_mechanism: RetryMechanismBase = Field(
default_factory=PassThroughWithoutRetry,
exclude=True,
deprecated=deprecated("retry_mechanism is deprecated; This property doesn't have any effect on the kernel."),
)
@@ -0,0 +1,31 @@
# Copyright (c) Microsoft. All rights reserved.
import logging
from collections.abc import Awaitable, Callable
from typing import TypeVar
from semantic_kernel.kernel_pydantic import KernelBaseModel
from semantic_kernel.reliability.retry_mechanism_base import RetryMechanismBase
T = TypeVar("T")
logger: logging.Logger = logging.getLogger(__name__)
class PassThroughWithoutRetry(RetryMechanismBase, KernelBaseModel):
"""A retry mechanism that does not retry."""
async def execute_with_retry(self, action: Callable[[], Awaitable[T]]) -> Awaitable[T]:
"""Executes the given action with retry logic.
Args:
action (Callable[[], Awaitable[T]]): The action to retry on exception.
Returns:
Awaitable[T]: An awaitable that will return the result of the action.
"""
try:
return action()
except Exception as e:
logger.warning(e, "Error executing action, not retrying")
raise e
@@ -0,0 +1,26 @@
# Copyright (c) Microsoft. All rights reserved.
import logging
from abc import ABC, abstractmethod
from collections.abc import Awaitable, Callable
from typing import TypeVar
T = TypeVar("T")
logger: logging.Logger = logging.getLogger(__name__)
class RetryMechanismBase(ABC):
"""Base class for retry mechanisms."""
@abstractmethod
async def execute_with_retry(self, action: Callable[[], Awaitable[T]]) -> Awaitable[T]:
"""Executes the given action with retry logic.
Args:
action (Callable[[], Awaitable[T]]): The action to retry on exception.
Returns:
Awaitable[T]: An awaitable that will return the result of the action.
"""
pass