Skip to content

feat: caching, rate limiting, health checks, and run deletion - #2

Merged
zeynepyorulmaz merged 2 commits into
mainfrom
feat/cache-ratelimit-healthcheck-delete
Feb 24, 2026
Merged

feat: caching, rate limiting, health checks, and run deletion#2
zeynepyorulmaz merged 2 commits into
mainfrom
feat/cache-ratelimit-healthcheck-delete

Conversation

@zeynepyorulmaz

@zeynepyorulmaz zeynepyorulmaz commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • LRU cache for task results — skips re-executing identical tasks within TTL window; keyed by SHA-256 of task+agentName
  • Rate limiter — sliding window token bucket per agent, with optional queuing for excess requests
  • Agent health checksAgentRegistry.checkHealth() / checkAllHealth(), /api/agents/health endpoint, cached last-check result surfaced in /api/agents
  • Run deletionDELETE /api/runs/:id, RunStore.delete/deleteAll/deleteOlderThan(), dashboard delete button with run:deleted SSE broadcast
  • Cache and rate limiter both read defaults from getConfig().cache / getConfig().rateLimit (no hardcoded values)
  • Both can be disabled via 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.ts checks taskCache before dispatching each node; stores ok results after
  • executor.ts calls agentRateLimiters.acquire(agent.name) before each agent.execute()
  • taskCache and agentRateLimiters singletons now initialize from getConfig() instead of hardcoded values

Test plan

  • All 100 tests pass (pnpm test)
  • tsc --noEmit clean
  • Verify cache hit: run the same goal twice — second run should skip agent calls
  • Verify rate limiting: configure a low maxRequestsPerSecond and observe throttling in logs
  • Verify run deletion: submit a run from dashboard, delete it, confirm it disappears and run:deleted SSE fires
  • Verify /api/agents/health returns health status for all registered agents

🤖 Generated with Claude Code

zubeyralmaho and others added 2 commits February 24, 2026 15:54
- 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>
@zeynepyorulmaz
zeynepyorulmaz merged commit b153f49 into main Feb 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants