Skip to content

Replace magic numbers: Retry configuration constants (Sessions 9-15) #389

Description

@mrveiss

Parent Issue

Linked to #376 - Code Smell: Replace 537 magic numbers with named constants

Summary

Replaced retry-related magic numbers with RetryConfig and TimingConstants constants across 25 files.

Files Modified

Session 9 (6 files, 9 replacements)

  • backend/services/workflow_automation/executor.py - Step delays
  • backend/api/chat_enhanced.py - Streaming chunk delay
  • backend/api/knowledge_fresh.py - KB init delays
  • backend/api/terminal_handlers.py - PTY polling loops
  • src/protocols/agent_communication.py - Message processing loop
  • src/utils/monitoring_alerts.py - Error recovery delay

Session 10 (5 files, 10 replacements)

  • scripts/monitoring_system.py - Error retry delay
  • scripts/zero_downtime_deploy.py - Monitoring interval, batch wait
  • scripts/deploy_autobot.py - Health check interval, error retry
  • scripts/monitoring/start_monitoring.py - Multiple timing constants
  • scripts/comprehensive_log_aggregator.py - Main loop delay

Session 11 (3 files, 3 replacements)

  • src/agents/interactive_terminal_agent.py - PTY polling loop
  • backend/services/simple_pty.py - Process termination delay
  • scripts/deployment_rollback.py - Service rollback delay

Session 12 (4 files, 5 replacements)

  • backend/services/agent_terminal/command_executor.py - Backoff base delay
  • src/utils/http_client.py - Pool adjustment interval
  • src/utils/distributed_redis_client.py - Max retries
  • src/utils/task_queue.py - Max retries (2 locations)

Session 13 (2 files, 11 replacements)

  • src/utils/redis_client.py - 7 fixes (max_retries, backoff_factor defaults)
  • src/utils/error_boundaries.py - 4 fixes (retry defaults)

Session 14 (4 files, 6 replacements)

  • src/utils/semantic_chunker.py - max_retries, retry_delay
  • src/utils/claude_api_integration.py - max_retries dataclass default
  • backend/services/load_balancer.py - max_retries function parameter
  • backend/api/scheduler.py - max_retries API model default

Session 15 (1 file, 2 replacements)

  • backend/api/knowledge_test.py - KB initialization delays

Constants Used

  • RetryConfig.DEFAULT_RETRIES (3)
  • RetryConfig.MIN_RETRIES (2)
  • RetryConfig.BACKOFF_BASE (2.0)
  • TimingConstants.SERVICE_STARTUP_DELAY (2.0)
  • TimingConstants.POLL_INTERVAL (0.01)
  • TimingConstants.STREAMING_CHUNK_DELAY (0.05)
  • TimingConstants.MICRO_DELAY (0.1)
  • TimingConstants.SHORT_DELAY (0.5)
  • TimingConstants.STANDARD_DELAY (1.0)
  • TimingConstants.MEDIUM_DELAY (5.0)
  • TimingConstants.LONG_DELAY (10.0)
  • TimingConstants.ERROR_RECOVERY_LONG_DELAY (30.0)
  • TimingConstants.KB_INIT_DELAY (3.0)

Totals

  • 25 files modified
  • 46 replacements made
  • All syntax verified ✅

Activity

  1. mrveiss commented on Dec 13, 2025

    @mrveiss
    OwnerAuthor

    Verified complete - RetryConfig and TimingConstants implemented in src/constants/threshold_constants.py and used across 25 files as documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions