Token导航 LogoToken导航TokenDH.com
待分类需要联网github未标认证来源可访问许可证需确认审计通过

tenacitytenacity 命令行

Agent Skill

tenacity 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

218

周安装

9

GitHub Stars

公开资料未说明

下载量

71
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:tenacity(tenacity 命令行)
来源仓库:https://github.com/davidcastagnetoa/skills
仓库路径:skills/tenacity
安装命令:
npx skills add https://github.com/davidcastagnetoa/skills --skill tenacity
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/davidcastagnetoa/skills --skill tenacity

简介

tenacity 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需结合原始 README 核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 当前分类为待分类,暂无更多功能细节可参考。

SKILL.md

tenacity

Skill para implementar patrones de resiliencia en las comunicaciones entre microservicios del pipeline de verificacion de identidad usando la libreria Tenacity de Python. Cubre reintentos con backoff exponencial, jitter aleatorio y circuit breaker para manejar fallos transitorios sin saturar servicios degradados. Especialmente critico para las llamadas entre el orquestador y los servicios de inferencia ML (liveness, face matching, OCR) que pueden experimentar picos de latencia.

When to use

Utilizar esta skill cuando el health_monitor_agent necesite configurar o mejorar la resiliencia de las llamadas HTTP/gRPC entre los microservicios del pipeline KYC. Aplica especialmente cuando se detectan fallos transitorios frecuentes, timeouts en servicios de inferencia ML, o cuando se requiere implementar circuit breaker para evitar cascadas de fallos.

Instructions

  1. Instalar la libreria tenacity y agregarla a los requirements del proyecto:
pip install tenacity
# requirements.txt
tenacity>=8.2.0
  1. Configurar el decorador de retry basico con backoff exponencial y jitter para llamadas entre microservicios:
from tenacity import (
    retry, stop_after_attempt, wait_exponential_jitter,
    retry_if_exception_type, before_sleep_log
)
import logging

logger = logging.getLogger(__name__)

@retry(
    stop=stop_after_attempt(3),
    wait=wait_exponential_jitter(initial=0.5, max=10, jitter=2),
    retry=retry_if_exception_type((ConnectionError, TimeoutError, httpx.HTTPStatusError)),
    before_sleep=before_sleep_log(logger, logging.WARNING),
)
async def call_face_match_service(selfie_data: bytes, doc_face_data: bytes) -> dict:
    async with httpx.AsyncClient(timeout=15.0) as client:
        response = await client.post(
            f"{FACE_MATCH_URL}/api/v1/compare",
            files={"selfie": selfie_data, "document_face": doc_face_data},
        )
        response.raise_for_status()
        return response.json()
  1. Implementar un circuit breaker usando tenacity para proteger servicios de inferencia ML sobrecargados:
from tenacity import retry, stop_after_attempt, wait_fixed, CircuitBreaker

face_match_breaker = CircuitBreaker(
    fail_max=5,
    reset_timeout=30,
)

@retry(
    stop=stop_after_attempt(3),
    wait=wait_exponential_jitter(initial=1, max=15),
    retry=retry_if_exception_type((ConnectionError, TimeoutError)),
)
async def call_with_circuit_breaker(service_url: str, payload: dict) -> dict:
    if face_match_breaker.current_state == "open":
        raise ServiceUnavailableError(f"Circuit breaker open for {service_url}")
    try:
        result = await make_request(service_url, payload)
        face_match_breaker.success()
        return result
    except Exception as e:
        face_match_breaker.failure()
        raise
  1. Crear configuraciones de retry diferenciadas por tipo de servicio del pipeline KYC:
# Servicios ML (GPU-bound): mas reintentos, waits mas largos
ML_RETRY_CONFIG = {
    "stop": stop_after_attempt(4),
    "wait": wait_exponential_jitter(initial=1.0, max=20, jitter=3),
    "retry": retry_if_exception_type((ConnectionError, TimeoutError)),
}

# Servicios ligeros (Redis, DB): menos reintentos, waits cortos
FAST_RETRY_CONFIG = {
    "stop": stop_after_attempt(2),
    "wait": wait_exponential_jitter(initial=0.2, max=2, jitter=0.5),
    "retry": retry_if_exception_type((ConnectionError, TimeoutError)),
}

# OCR (CPU-bound): reintentos moderados
OCR_RETRY_CONFIG = {
    "stop": stop_after_attempt(3),
    "wait": wait_exponential_jitter(initial=0.5, max=10, jitter=1),
    "retry": retry_if_exception_type((ConnectionError, TimeoutError)),
}
  1. Implementar callbacks para registrar metricas de reintentos en Prometheus:
from tenacity import after_log, before_sleep_log
from prometheus_client import Counter, Histogram

retry_counter = Counter("kyc_retry_total", "Total retries", ["service", "attempt"])
retry_latency = Histogram("kyc_retry_duration_seconds", "Retry duration", ["service"])

def on_retry(retry_state):
    service = retry_state.fn.__name__
    retry_counter.labels(service=service, attempt=str(retry_state.attempt_number)).inc()

@retry(
    **ML_RETRY_CONFIG,
    after=on_retry,
)
async def call_liveness_service(frames: list[bytes]) -> dict:
    return await make_request(LIVENESS_URL, {"frames": frames})
  1. Configurar excepciones especificas que NO deben reintentar (errores de negocio vs errores transitorios):
from tenacity import retry_if_not_exception_type

@retry(
    stop=stop_after_attempt(3),
    wait=wait_exponential_jitter(initial=0.5, max=10),
    retry=(
        retry_if_exception_type((ConnectionError, TimeoutError))
        & retry_if_not_exception_type(ValidationError)
    ),
)
async def call_ocr_service(document_image: bytes) -> dict:
    # ValidationError (documento ilegible) no debe reintentar
    # ConnectionError/TimeoutError si deben reintentar
    result = await make_request(OCR_URL, {"image": document_image})
    if result.get("error_type") == "validation":
        raise ValidationError(result["message"])
    return result
  1. Implementar un wrapper reutilizable con circuit breaker integrado para todos los servicios del pipeline:
class ResilientServiceClient:
    def __init__(self, service_name: str, base_url: str, retry_config: dict):
        self.service_name = service_name
        self.base_url = base_url
        self.retry_config = retry_config
        self.breaker = CircuitBreaker(fail_max=5, reset_timeout=30)

    @retry(**ML_RETRY_CONFIG)
    async def call(self, endpoint: str, payload: dict) -> dict:
        if self.breaker.current_state == "open":
            raise CircuitOpenError(self.service_name)
        try:
            result = await httpx.AsyncClient().post(
                f"{self.base_url}{endpoint}", json=payload, timeout=15.0
            )
            self.breaker.success()
            return result.json()
        except Exception as e:
            self.breaker.failure()
            raise

face_client = ResilientServiceClient("face_match", FACE_MATCH_URL, ML_RETRY_CONFIG)
ocr_client = ResilientServiceClient("ocr", OCR_URL, OCR_RETRY_CONFIG)

Notes

  • Nunca reintentar errores de validacion o errores 4xx del negocio (documento invalido, rostro no detectado); solo reintentar errores de infraestructura (5xx, timeouts, connection refused) para evitar trabajo redundante y latencia innecesaria.
  • El tiempo total de reintentos para una verificacion KYC completa no debe superar los 8 segundos segun los SLOs del sistema; configurar los timeouts y max_attempts en consecuencia.
  • Monitorizar la tasa de reintentos como metrica clave; un aumento sostenido indica degradacion del servicio destino y debe disparar alertas del health_monitor_agent antes de que el circuit breaker se abra.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.8%
按下载量换算24

Claude

32.2%
按下载量换算23

Cursor

18.94%
按下载量换算13

Gemini CLI

9.58%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills