feat: caching, rate limiting, health checks, and run deletion - #2
Merged
Merged
Conversation
- Add LRU cache with TTL support for task results (cache.ts) - Add token bucket rate limiter with per-agent limits (rate-limiter.ts) - Add agent health check methods to AgentRegistry - Add GET /api/agents/health endpoint - Add DELETE /api/runs/:id endpoint for run deletion - Add delete button to dashboard history items - Add cache and rateLimit config options - Add RunStore.delete(), deleteAll(), deleteOlderThan() methods - Export new utilities from index.ts - Add comprehensive tests for cache and rate limiter (29 new tests)
- taskCache singleton now reads ttlMs and maxEntries from getConfig().cache - agentRateLimiters singleton now reads maxRequestsPerSecond, queueExcess, maxQueueSize from getConfig().rateLimit - executor.ts: check taskCache before dispatch, acquire rate limiter token per agent before execute, store successful results in cache after execute - Cache and rate limiting are skipped when cfg.cache.enabled / cfg.rateLimit.enabled are false All 100 tests pass, tsc clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
task+agentNameAgentRegistry.checkHealth()/checkAllHealth(),/api/agents/healthendpoint, cached last-check result surfaced in/api/agentsDELETE /api/runs/:id,RunStore.delete/deleteAll/deleteOlderThan(), dashboard delete button withrun:deletedSSE broadcastgetConfig().cache/getConfig().rateLimit(no hardcoded values)configure({ cache: { enabled: false }, rateLimit: { enabled: false } })Changes from original PR
The original PR built the cache and rate limiter utilities but left them unwired. This PR adds the missing integration:
executor.tscheckstaskCachebefore dispatching each node; storesokresults afterexecutor.tscallsagentRateLimiters.acquire(agent.name)before eachagent.execute()taskCacheandagentRateLimiterssingletons now initialize fromgetConfig()instead of hardcoded valuesTest plan
pnpm test)tsc --noEmitcleanmaxRequestsPerSecondand observe throttling in logsrun:deletedSSE fires/api/agents/healthreturns health status for all registered agents🤖 Generated with Claude Code