smart-poll-loop
하는 일
이 스킬은 서비스가 계속 실패하면 느려지고 성공하면 다시 빨라지는 폴링 루프를 설명합니다. 외부 서비스를 정기적으로 확인하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓외부 서비스를 주기적으로 확인하는데 가끔 실패할 때.
- ✓실패한 요청이 이미 힘든 서비스에 과부하를 줄 수 있을 때.
- ✓서비스가 회복되는 즉시 확인 속도가 정상으로 돌아가기를 원할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/smart-poll-loop/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“서버 상태를 1분마다 확인하되, 계속 실패하면 확인 간격을 늘려 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
실패할 때마다 대기 시간이 두 배가 되며, 정해진 한도까지 늘어납니다. 성공하면 루프는 정상 간격으로 돌아갑니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Smart Poll Loop Pattern
Overview
The Smart Poll Loop pattern implements resilient, adaptive polling for periodic data refresh operations. It combines exponential backoff on consecutive failures with automatic recovery on success, ensuring system resources are protected during outages while maintaining responsiveness when services are healthy.
This pattern is essential for production applications that need to poll external services or APIs continuously but must gracefully handle intermittent failures, rate limits, or temporary service disruptions without overwhelming the system or degrading user experience.
Key Patterns Identified
Pattern 1: Exponential Backoff on Failure
Purpose: Prevent overwhelming failing services with repeated requests while giving them time to recover.
Implementation: Each consecutive failure doubles the polling interval up to a configurable maximum multiplier. This creates exponentially increasing delays: 1x → 2x → 4x → 8x (default max).
Key Elements:
consecutiveFailures: Counter tracking sequential failurescurrentBackoffMultiplier: Current delay multiplier (starts at 1)maxBackoffMultiplier: Upper bound to prevent infinite delays (typically 4-8x)- Boolean return from callbacks (
true= success,false= failure)
Code Pattern:
// Track failure state per runner
interface RunnerEntry {
consecutiveFailures: number;
currentBackoffMultiplier: number;
intervalMs: number; // base interval
// ... other fields
}
// On failure, increase backoff
if (!success) {
entry.consecutiveFailures++;
const newMultiplier = Math.min(
Math.pow(2, entry.consecutiveFailures),
maxBackoffMultiplier
);
entry.currentBackoffMultiplier = newMultiplier;
// Reschedule with new interval
const effectiveInterval = entry.intervalMs * entry.currentBackoffMultiplier;
scheduleNextRun(effectiveInterval);
}
Pattern 2: Automatic Recovery on Success
Purpose: Immediately restore normal polling frequency when a service recovers, ensuring fresh data flows without unnecessary delay.
Implementation: On any successful callback execution, reset both the failure counter and backoff multiplier to their initial states (0 and 1), then reschedule at the base interval.
Key Elements:
- Reset logic triggered by
success === trueor no error thrown - Immediate rescheduling at base interval (no waiting for current timer)
- Logging state transitions for observability
Code Pattern:
if (success) {
// Auto-recovery: reset backoff and failure count
if (entry.consecutiveFailures > 0 || entry.currentBackoffMultiplier > 1) {
entry.consecutiveFailures = 0;
entry.currentBackoffMultiplier = 1;
// Immediately reschedule at normal interval
if (!paused && entry.timer) {
scheduleNextRun(name, entry); // uses base intervalMs
}
}
}
Pattern 3: Failure Detection via Boolean Return or Exception
Purpose: Provide flexible signaling for success/failure states, supporting both explicit boolean returns and exception-based error handling.
Implementation: Callbacks can return boolean (explicit success/failure), void (success assumed), or throw exceptions (failure). All three mechanisms trigger the same backoff/recovery logic.
Key Elements:
- Type signature:
() => Promise<boolean | void> true= explicit success, triggers recoveryfalse= explicit failure, triggers backoffvoid/undefined= implicit success (no news is good news)- Exception thrown = failure, triggers backoff
Code Pattern:
let success = true;
try {
const result = await entry.fn();
// Boolean return indicates explicit success/failure
if (typeof result === 'boolean') {
success = result;
}
// void/undefined is treated as success
if (success) {
// trigger recovery...
} else {
// trigger backoff...
}
} catch (err) {
// Exception is also treated as failure
success = false;
// trigger backoff...
}
Pattern 4: Visibility-Aware Scheduling
Purpose: Pause or slow down polling when the page is hidden to conserve resources, then resume or refresh immediately when visible.
Implementation: Listen to visibilitychange events. On hide, clear all timers. On show, either flush stale data (if enough time passed) or resume normal polling.
Key Elements:
document.hiddenstate checkpauseWhenHiddenflag (full stop vs slower polling
자주 묻는 질문
대기 시간은 얼마나 길어질 수 있나요?
스킬은 보통 정상 간격의 네 배에서 여덟 배 사이의 최대 배수를 설정합니다.
성공하면 대기 시간이 초기화되나요?
네. 한 번 성공한 확인이 루프를 정상 속도로 되돌립니다.
충분히 실패하면 시도를 멈추나요?
루프는 가장 긴 대기 시간으로 계속 실행되므로, 서비스가 돌아오면 확인을 재개합니다.
상세 정보
작성자의 원본 설명
Adaptive polling pattern with exponential backoff on failure, automatic recovery on success, and visibility-aware scheduling
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #13082
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.