[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ESGXQSECQRKJRG5D3SPFTG":3,"skill-same:01M6ESGXQSECQRKJRG5D3SPFTG":139},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":96,"commitSha":97,"skillDirectory":98,"forksCount":99,"repositoryHtmlUrl":100,"repositoryHomepageUrl":101,"ownerHtmlUrl":102,"ownerBlogUrl":6,"ownerDescription":103,"updatedAt":104,"install":105,"resources":118},"01M6ESGXQSECQRKJRG5D3SPFTG","agentdb-reinforcement-learning-training",null,"Train AI agents using AgentDB's 9 reinforcement learning algorithms including Q-Learning, DQN, PPO, and Actor-Critic. Build self-learning agents, implement RL training loops with experience replay, and deploy optimized models to production.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000011","运维与部署","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"agentdb reinforcement learning training","training","reinforcement learning","learning","reinforcement","consensus","2025","loops","neural network","chain","decomposition","self","modules","ai agents","knowledge","critic","pipeline","verification","tasks","performance","2026-11-10 10:12:30",false,"---\nskill_id: when-training-rl-agents-use-agentdb-learning\nname: agentdb-reinforcement-learning-training\ndescription: \"Train AI agents using AgentDB's 9 reinforcement learning algorithms including Q-Learning, DQN, PPO, and Actor-Critic. Build self-learning agents, implement RL training loops with experience replay, and deploy optimized models to production.\"\nversion: 1.0.0\ncategory: agentdb\nsubcategory: machine-learning\ntrigger_pattern: \"when-training-rl-agents\"\nagents:\n  - ml-developer\n  - safla-neural\n  - performance-benchmarker\ncomplexity: advanced\nestimated_duration: 6-10 hours\nprerequisites:\n  - AgentDB basics\n  - Reinforcement learning fundamentals\n  - Neural network knowledge\n  - Python\u002FTypeScript proficiency\noutputs:\n  - Trained RL agents\n  - Learning plugin modules\n  - Performance benchmarks\n  - Deployment pipeline\nvalidation_criteria:\n  - Training converges successfully\n  - Reward curve shows improvement\n  - Agent passes validation tasks\n  - Benchmarks meet targets\nevidence_based_techniques:\n  - Self-consistency validation\n  - Program-of-thought decomposition\n  - Chain-of-verification\n  - Multi-agent consensus\nmetadata:\n  author: claude-flow\n  created: 2025-10-30\n  updated: 2025-10-30\n  tags:\n    - agentdb\n    - reinforcement-learning\n    - neural-networks\n    - ai-training\n    - q-learning\n---\n\n# AgentDB Reinforcement Learning Training\n\n## Overview\n\nTrain AI learning plugins with AgentDB's 9 reinforcement learning algorithms including Decision Transformer, Q-Learning, SARSA, Actor-Critic, PPO, and more. Build self-learning agents, implement RL, and optimize agent behavior through experience.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n- Train autonomous agents that learn from experience\n- Implement reinforcement learning systems\n- Optimize agent behavior through trial and error\n- Build self-improving AI systems\n- Deploy RL agents in production environments\n- Benchmark and compare RL algorithms\n\n## Available RL Algorithms\n\n1. **Q-Learning** - Value-based, off-policy\n2. **SARSA** - Value-based, on-policy\n3. **Deep Q-Network (DQN)** - Deep RL with experience replay\n4. **Actor-Critic** - Policy gradient with value baseline\n5. **Proximal Policy Optimization (PPO)** - Trust region policy optimization\n6. **Decision Transformer** - Offline RL with transformers\n7. **Advantage Actor-Critic (A2C)** - Synchronous advantage estimation\n8. **Twin Delayed DDPG (TD3)** - Continuous control\n9. **Soft Actor-Critic (SAC)** - Maximum entropy RL\n\n## SOP Framework: 5-Phase RL Training Deployment\n\n### Phase 1: Initialize Learning Environment (1-2 hours)\n\n**Objective:** Setup AgentDB learning infrastructure with environment configuration\n\n**Agent:** ml-developer\n\n**Steps:**\n\n1. **Install AgentDB Learning Module**\n```bash\nnpm install agentdb-learning@latest\nnpm install @agentdb\u002Frl-algorithms @agentdb\u002Fenvironments\n```\n\n2. **Initialize learning database**\n```typescript\nimport { AgentDB, LearningPlugin } from 'agentdb-learning';\n\nconst learningDB = new AgentDB({\n  name: 'rl-training-db',\n  dimensions: 512, \u002F\u002F State embedding dimension\n  learning: {\n    enabled: true,\n    persistExperience: true,\n    replayBufferSize: 100000\n  }\n});\n\nawait learningDB.initialize();\n\n\u002F\u002F Create learning plugin\nconst learningPlugin = new LearningPlugin({\n  database: learningDB,\n  algorithms: ['q-learning', 'dqn', 'ppo', 'actor-critic'],\n  config: {\n    batchSize: 64,\n    learningRate: 0.001,\n    discountFactor: 0.99,\n    explorationRate: 1.0,\n    explorationDecay: 0.995\n  }\n});\n\nawait learningPlugin.initialize();\n```\n\n3. **Define environment**\n```typescript\nimport { Environment } from '@agentdb\u002Fenvironments';\n\nconst environment = new Environment({\n  name: 'grid-world',\n  stateSpace: {\n    type: 'continuous',\n    shape: [10, 10],\n    bounds: [[0, 10], [0, 10]]\n  },\n  actionSpace: {\n    type: 'discrete',\n    actions: ['up', 'down', 'left', 'right']\n  },\n  rewardFunction: (state, action, nextState) => {\n    \u002F\u002F Distance to goal reward\n    const goalDistance = Math.sqrt(\n      Math.pow(nextState[0] - 9, 2) +\n      Math.pow(nextState[1] - 9, 2)\n    );\n    return -goalDistance + (goalDistance === 0 ? 100 : 0);\n  },\n  terminalCondition: (state) => {\n    return state[0] === 9 && state[1] === 9; \u002F\u002F Reached goal\n  }\n});\n\nawait environment.initialize();\n```\n\n4. **Setup monitoring**\n```typescript\nconst monitor = learningPlugin.createMonitor({\n  metrics: ['reward', 'loss', 'exploration-rate', 'episode-length'],\n  logInterval: 100, \u002F\u002F Log every 100 episodes\n  saveCheckpoints: true,\n  checkpointInterval: 1000\n});\n\nmonitor.on('episode-complete', (episode) => {\n  console.log('Episode:', episode.number, 'Reward:', episode.totalReward);\n});\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fenvironment', {\n  name: environment.name,\n  stateSpace: environment.stateSpace,\n  actionSpace: environment.actionSpace,\n  initialized: Date.now()\n});\n```\n\n**Validation:**\n- Learning database initialized\n- Environment configured and tested\n- Monitor capturing metrics\n- Configuration stored in memory\n\n### Phase 2: Configure RL Algorithm (1-2 hours)\n\n**Objective:** Select and configure RL algorithm for the learning task\n\n**Agent:** ml-developer\n\n**Steps:**\n\n1. **Select algorithm**\n```typescript\n\u002F\u002F Example: Deep Q-Network (DQN)\nconst dqnAgent = learningPlugin.createAgent({\n  algorithm: 'dqn',\n  config: {\n    networkArchitecture: {\n      layers: [\n        { type: 'dense', units: 128, activation: 'relu' },\n        { type: 'dense', units: 128, activation: 'relu' },\n        { type: 'dense', units: environment.actionSpace.size, activation: 'linear' }\n      ]\n    },\n    learningRate: 0.001,\n    batchSize: 64,\n    replayBuffer: {\n      size: 100000,\n      prioritized: true,\n      alpha: 0.6,\n      beta: 0.4\n    },\n    targetNetwork: {\n      updateFrequency: 1000,\n      tauSync: 0.001 \u002F\u002F Soft update\n    },\n    exploration: {\n      initial: 1.0,\n      final: 0.01,\n      decay: 0.995\n    },\n    training: {\n      startAfter: 1000, \u002F\u002F Start training after 1000 experiences\n      updateFrequency: 4\n    }\n  }\n});\n\nawait dqnAgent.initialize();\n```\n\n2. **Configure hyperparameters**\n```typescript\nconst hyperparameters = {\n  \u002F\u002F Learning parameters\n  learningRate: 0.001,\n  discountFactor: 0.99, \u002F\u002F Gamma\n  batchSize: 64,\n\n  \u002F\u002F Exploration\n  epsilonStart: 1.0,\n  epsilonEnd: 0.01,\n  epsilonDecay: 0.995,\n\n  \u002F\u002F Experience replay\n  replayBufferSize: 100000,\n  minReplaySize: 1000,\n  prioritizedReplay: true,\n\n  \u002F\u002F Training\n  maxEpisodes: 10000,\n  maxStepsPerEpisode: 1000,\n  targetUpdateFrequency: 1000,\n\n  \u002F\u002F Evaluation\n  evalFrequency: 100,\n  evalEpisodes: 10\n};\n\ndqnAgent.setHyperparameters(hyperparameters);\n```\n\n3. **Setup experience replay**\n```typescript\nimport { PrioritizedReplayBuffer } from '@agentdb\u002Frl-algorithms';\n\nconst replayBuffer = new PrioritizedReplayBuffer({\n  capacity: 100000,\n  alpha: 0.6, \u002F\u002F Prioritization exponent\n  beta: 0.4, \u002F\u002F Importance sampling\n  betaIncrement: 0.001,\n  epsilon: 0.01 \u002F\u002F Small constant for stability\n});\n\ndqnAgent.setReplayBuffer(replayBuffer);\n```\n\n4. **Configure training loop**\n```typescript\nconst trainingConfig = {\n  episodes: 10000,\n  stepsPerEpisode: 1000,\n  warmupSteps: 1000,\n  trainFrequency: 4,\n  targetUpdateFrequency: 1000,\n  saveFrequency: 1000,\n  evalFrequency: 100,\n  earlyStoppingPatience: 500,\n  earlyStoppingThreshold: 0.01\n};\n\ndqnAgent.setTrainingConfig(trainingConfig);\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Falgorithm-config', {\n  algorithm: 'dqn',\n  hyperparameters: hyperparameters,\n  trainingConfig: trainingConfig,\n  configured: Date.now()\n});\n```\n\n**Validation:**\n- Algorithm selected and configured\n- Hyperparameters validated\n- Replay buffer initialized\n- Training config set\n\n### Phase 3: Train Agents (3-4 hours)\n\n**Objective:** Execute training iterations and optimize agent behavior\n\n**Agent:** safla-neural\n\n**Steps:**\n\n1. **Start training loop**\n```typescript\nasync function trainAgent() {\n  console.log('Starting RL training...');\n\n  const trainingStats = {\n    episodes: [],\n    totalReward: [],\n    episodeLength: [],\n    loss: [],\n    explorationRate: []\n  };\n\n  for (let episode = 0; episode \u003C trainingConfig.episodes; episode++) {\n    let state = await environment.reset();\n    let episodeReward = 0;\n    let episodeLength = 0;\n    let episodeLoss = 0;\n\n    for (let step = 0; step \u003C trainingConfig.stepsPerEpisode; step++) {\n      \u002F\u002F Select action\n      const action = await dqnAgent.selectAction(state, {\n        explore: true\n      });\n\n      \u002F\u002F Execute action\n      const { nextState, reward, done } = await environment.step(action);\n\n      \u002F\u002F Store experience\n      await dqnAgent.storeExperience({\n        state,\n        action,\n        reward,\n        nextState,\n        done\n      });\n\n      \u002F\u002F Train if enough experiences\n      if (dqnAgent.canTrain()) {\n        const loss = await dqnAgent.train();\n        episodeLoss += loss;\n      }\n\n      episodeReward += reward;\n      episodeLength += 1;\n      state = nextState;\n\n      if (done) break;\n    }\n\n    \u002F\u002F Update target network\n    if (episode % trainingConfig.targetUpdateFrequency === 0) {\n      await dqnAgent.updateTargetNetwork();\n    }\n\n    \u002F\u002F Decay exploration\n    dqnAgent.decayExploration();\n\n    \u002F\u002F Log progress\n    trainingStats.episodes.push(episode);\n    trainingStats.totalReward.push(episodeReward);\n    trainingStats.episodeLength.push(episodeLength);\n    trainingStats.loss.push(episodeLoss \u002F episodeLength);\n    trainingStats.explorationRate.push(dqnAgent.getExplorationRate());\n\n    if (episode % 100 === 0) {\n      console.log(`Episode ${episode}:`, {\n        reward: episodeReward.toFixed(2),\n        length: episodeLength,\n        loss: (episodeLoss \u002F episodeLength).toFixed(4),\n        epsilon: dqnAgent.getExplorationRate().toFixed(3)\n      });\n    }\n\n    \u002F\u002F Save checkpoint\n    if (episode % trainingConfig.saveFrequency === 0) {\n      await dqnAgent.save(`checkpoint-${episode}`);\n    }\n\n    \u002F\u002F Evaluate\n    if (episode % trainingConfig.evalFrequency === 0) {\n      const evalReward = await evaluateAgent(dqnAgent, environment);\n      console.log(`Evaluation at episode ${episode}: ${evalReward.toFixed(2)}`);\n    }\n\n    \u002F\u002F Early stopping\n    if (checkEarlyStopping(trainingStats, episode)) {\n      console.log('Early stopping triggered');\n      break;\n    }\n  }\n\n  return trainingStats;\n}\n\nconst trainingStats = await trainAgent();\n```\n\n2. **Monitor training progress**\n```typescript\nmonitor.on('training-update', (stats) => {\n  \u002F\u002F Calculate moving averages\n  const window = 100;\n  const recentRewards = stats.totalReward.slice(-window);\n  const avgReward = recentRewards.reduce((a, b) => a + b, 0) \u002F recentRewards.length;\n\n  \u002F\u002F Store metrics\n  agentDB.memory.store('agentdb\u002Flearning\u002Ftraining-progress', {\n    episode: stats.episodes[stats.episodes.length - 1],\n    avgReward: avgReward,\n    explorationRate: stats.explorationRate[stats.explorationRate.length - 1],\n    timestamp: Date.now()\n  });\n\n  \u002F\u002F Plot learning curve (if visualization enabled)\n  if (monitor.visualization) {\n    monitor.plot('reward-curve', stats.episodes, stats.totalReward);\n    monitor.plot('loss-curve', stats.episodes, stats.loss);\n  }\n});\n```\n\n3. **Handle convergence**\n```typescript\nfunction checkConvergence(stats, windowSize = 100, threshold = 0.01) {\n  if (stats.totalReward.length \u003C windowSize * 2) {\n    return false;\n  }\n\n  const recent = stats.totalReward.slice(-windowSize);\n  const previous = stats.totalReward.slice(-windowSize * 2, -windowSize);\n\n  const recentAvg = recent.reduce((a, b) => a + b, 0) \u002F recent.length;\n  const previousAvg = previous.reduce((a, b) => a + b, 0) \u002F previous.length;\n\n  const improvement = (recentAvg - previousAvg) \u002F Math.abs(previousAvg);\n\n  return improvement \u003C threshold;\n}\n```\n\n4. **Save trained model**\n```typescript\nawait dqnAgent.save('trained-agent-final', {\n  includeReplayBuffer: false,\n  includeOptimizer: false,\n  metadata: {\n    trainingStats: trainingStats,\n    hyperparameters: hyperparameters,\n    finalReward: trainingStats.totalReward[trainingStats.totalReward.length - 1]\n  }\n});\n\nconsole.log('Training complete. Model saved.');\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Ftraining-results', {\n  algorithm: 'dqn',\n  episodes: trainingStats.episodes.length,\n  finalReward: trainingStats.totalReward[trainingStats.totalReward.length - 1],\n  converged: checkConvergence(trainingStats),\n  modelPath: 'trained-agent-final',\n  timestamp: Date.now()\n});\n```\n\n**Validation:**\n- Training completed or converged\n- Reward curve shows improvement\n- Model saved successfully\n- Training stats stored\n\n### Phase 4: Validate Performance (1-2 hours)\n\n**Objective:** Benchmark trained agent and validate performance\n\n**Agent:** performance-benchmarker\n\n**Steps:**\n\n1. **Load trained agent**\n```typescript\nconst trainedAgent = await learningPlugin.loadAgent('trained-agent-final');\n```\n\n2. **Run evaluation episodes**\n```typescript\nasync function evaluateAgent(agent, env, numEpisodes = 100) {\n  const results = {\n    rewards: [],\n    episodeLengths: [],\n    successRate: 0\n  };\n\n  for (let i = 0; i \u003C numEpisodes; i++) {\n    let state = await env.reset();\n    let episodeReward = 0;\n    let episodeLength = 0;\n    let success = false;\n\n    for (let step = 0; step \u003C 1000; step++) {\n      const action = await agent.selectAction(state, { explore: false });\n      const { nextState, reward, done } = await env.step(action);\n\n      episodeReward += reward;\n      episodeLength += 1;\n      state = nextState;\n\n      if (done) {\n        success = env.isSuccessful(state);\n        break;\n      }\n    }\n\n    results.rewards.push(episodeReward);\n    results.episodeLengths.push(episodeLength);\n    if (success) results.successRate += 1;\n  }\n\n  results.successRate \u002F= numEpisodes;\n\n  return {\n    meanReward: results.rewards.reduce((a, b) => a + b, 0) \u002F results.rewards.length,\n    stdReward: calculateStd(results.rewards),\n    meanLength: results.episodeLengths.reduce((a, b) => a + b, 0) \u002F results.episodeLengths.length,\n    successRate: results.successRate,\n    results: results\n  };\n}\n\nconst evalResults = await evaluateAgent(trainedAgent, environment, 100);\nconsole.log('Evaluation results:', evalResults);\n```\n\n3. **Compare with baseline**\n```typescript\n\u002F\u002F Random policy baseline\nconst randomAgent = learningPlugin.createAgent({ algorithm: 'random' });\nconst randomResults = await evaluateAgent(randomAgent, environment, 100);\n\n\u002F\u002F Calculate improvement\nconst improvement = {\n  rewardImprovement: (evalResults.meanReward - randomResults.meanReward) \u002F Math.abs(randomResults.meanReward),\n  lengthImprovement: (randomResults.meanLength - evalResults.meanLength) \u002F randomResults.meanLength,\n  successImprovement: evalResults.successRate - randomResults.successRate\n};\n\nconsole.log('Improvement over random:', improvement);\n```\n\n4. **Run comprehensive benchmarks**\n```typescript\nconst benchmarks = {\n  performanceMetrics: {\n    meanReward: evalResults.meanReward,\n    stdReward: evalResults.stdReward,\n    successRate: evalResults.successRate,\n    meanEpisodeLength: evalResults.meanLength\n  },\n  algorithmComparison: {\n    dqn: evalResults,\n    random: randomResults,\n    improvement: improvement\n  },\n  inferenceTiming: {\n    actionSelection: 0,\n    totalEpisode: 0\n  }\n};\n\n\u002F\u002F Measure inference speed\nconst timingTrials = 1000;\nconst startTime = performance.now();\nfor (let i = 0; i \u003C timingTrials; i++) {\n  const state = await environment.randomState();\n  await trainedAgent.selectAction(state, { explore: false });\n}\nconst endTime = performance.now();\nbenchmarks.inferenceTiming.actionSelection = (endTime - startTime) \u002F timingTrials;\n\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fbenchmarks', benchmarks);\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fvalidation', {\n  evaluated: true,\n  meanReward: evalResults.meanReward,\n  successRate: evalResults.successRate,\n  improvement: improvement,\n  timestamp: Date.now()\n});\n```\n\n**Validation:**\n- Evaluation completed (100 episodes)\n- Mean reward exceeds threshold\n- Success rate acceptable\n- Improvement over baseline demonstrated\n\n### Phase 5: Deploy Trained Agents (1-2 hours)\n\n**Objective:** Deploy trained agents to production environment\n\n**Agent:** ml-developer\n\n**Steps:**\n\n1. **Export production model**\n```typescript\nawait trainedAgent.export('production-agent', {\n  format: 'onnx', \u002F\u002F or 'tensorflowjs', 'pytorch'\n  optimize: true,\n  quantize: 'int8', \u002F\u002F Quantization for faster inference\n  includeMetadata: true\n});\n```\n\n2. **Create inference API**\n```typescript\nimport express from 'express';\n\nconst app = express();\napp.use(express.json());\n\n\u002F\u002F Load production agent\nconst productionAgent = await learningPlugin.loadAgent('production-agent');\n\napp.post('\u002Fapi\u002Fpredict', async (req, res) => {\n  try {\n    const { state } = req.body;\n\n    const action = await productionAgent.selectAction(state, {\n      explore: false,\n      returnProbabilities: true\n    });\n\n    res.json({\n      action: action.action,\n      probabilities: action.probabilities,\n      confidence: action.confidence\n    });\n  } catch (error) {\n    res.status(500).json({ error: error.message });\n  }\n});\n\napp.listen(3000, () => {\n  console.log('RL agent API running on port 3000');\n});\n```\n\n3. **Setup monitoring**\n```typescript\nimport { ProductionMonitor } from '@agentdb\u002Fmonitoring';\n\nconst prodMonitor = new ProductionMonitor({\n  agent: productionAgent,\n  metrics: ['inference-latency', 'action-distribution', 'reward-feedback'],\n  alerting: {\n    latencyThreshold: 100, \u002F\u002F ms\n    anomalyDetection: true\n  }\n});\n\nawait prodMonitor.start();\n```\n\n4. **Create deployment pipeline**\n```typescript\nconst deploymentPipeline = {\n  stages: [\n    {\n      name: 'validation',\n      steps: [\n        'Load trained model',\n        'Run validation suite',\n        'Check performance metrics',\n        'Verify inference speed'\n      ]\n    },\n    {\n      name: 'export',\n      steps: [\n        'Export to production format',\n        'Optimize model',\n        'Quantize weights',\n        'Package artifacts'\n      ]\n    },\n    {\n      name: 'deployment',\n      steps: [\n        'Deploy to staging',\n        'Run smoke tests',\n        'Deploy to production',\n        'Monitor performance'\n      ]\n    }\n  ]\n};\n\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fdeployment-pipeline', deploymentPipeline);\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fproduction', {\n  deployed: true,\n  modelPath: 'production-agent',\n  apiEndpoint: 'http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fpredict',\n  monitoring: true,\n  timestamp: Date.now()\n});\n```\n\n**Validation:**\n- Model exported successfully\n- API running and responding\n- Monitoring active\n- Deployment pipeline documented\n\n## Integration Scripts\n\n### Complete Training Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# train-rl-agent.sh\n\nset -e\n\necho \"AgentDB RL Training Script\"\necho \"==========================\"\n\n# Phase 1: Initialize\necho \"Phase 1: Initializing learning environment...\"\nnpm install agentdb-learning @agentdb\u002Frl-algorithms\n\n# Phase 2: Configure\necho \"Phase 2: Configuring algorithm...\"\nnode -e \"require('.\u002Fconfig-algorithm.js')\"\n\n# Phase 3: Train\necho \"Phase 3: Training agent...\"\nnode -e \"require('.\u002Ftrain-agent.js')\"\n\n# Phase 4: Validate\necho \"Phase 4: Validating performance...\"\nnode -e \"require('.\u002Fevaluate-agent.js')\"\n\n# Phase 5: Deploy\necho \"Phase 5: Deploying to production...\"\nnode -e \"require('.\u002Fdeploy-agent.js')\"\n\necho \"Training complete!\"\n```\n\n### Quick Start Script\n\n```typescript\n\u002F\u002F quickstart-rl.ts\nimport { setupRLTraining } from '.\u002Fsetup';\n\nasync function quickStart() {\n  console.log('Starting RL training quick setup...');\n\n  \u002F\u002F Setup\n  const { learningDB, environment, agent } = await setupRLTraining({\n    algorithm: 'dqn',\n    environment: 'grid-world',\n    episodes: 1000\n  });\n\n  \u002F\u002F Train\n  console.log('Training agent...');\n  const stats = await agent.train(environment, {\n    episodes: 1000,\n    logInterval: 100\n  });\n\n  \u002F\u002F Evaluate\n  console.log('Evaluating agent...');\n  const results = await agent.evaluate(environment, {\n    episodes: 100\n  });\n  console.log('Results:', results);\n\n  \u002F\u002F Save\n  await agent.save('quickstart-agent');\n  console.log('Quick start complete!');\n}\n\nquickStart().catch(console.error);\n```\n\n## Evidence-Based Success Criteria\n\n1. **Training Convergence (Self-Consistency)**\n   - Reward curve stabilizes\n   - Moving average improvement \u003C 1%\n   - Agent achieves consistent performance\n\n2. **Performance Benchmarks (Quantitative)**\n   - Mean reward exceeds baseline by 50%\n   - Success rate > 80%\n   - Inference time \u003C 10ms per action\n\n3. **Algorithm Validation (Chain-of-Verification)**\n   - Hyperparameters validated\n   - Exploration-exploitation balanced\n   - Experience replay functioning\n\n4. **Production Readiness (Multi-Agent Consensus)**\n   - Model exported successfully\n   - API responds within latency threshold\n   - Monitoring active and alerting\n   - Deployment pipeline documented\n\n## Additional Resources\n\n- AgentDB Learning Documentation: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Flearning\n- RL Algorithms Guide: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Frl-algorithms\n- Training Best Practices: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Ftraining\n- Production Deployment: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Fdeployment\n","# AgentDB Reinforcement Learning Training\n\n## Overview\n\nTrain AI learning plugins with AgentDB's 9 reinforcement learning algorithms including Decision Transformer, Q-Learning, SARSA, Actor-Critic, PPO, and more. Build self-learning agents, implement RL, and optimize agent behavior through experience.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n- Train autonomous agents that learn from experience\n- Implement reinforcement learning systems\n- Optimize agent behavior through trial and error\n- Build self-improving AI systems\n- Deploy RL agents in production environments\n- Benchmark and compare RL algorithms\n\n## Available RL Algorithms\n\n1. **Q-Learning** - Value-based, off-policy\n2. **SARSA** - Value-based, on-policy\n3. **Deep Q-Network (DQN)** - Deep RL with experience replay\n4. **Actor-Critic** - Policy gradient with value baseline\n5. **Proximal Policy Optimization (PPO)** - Trust region policy optimization\n6. **Decision Transformer** - Offline RL with transformers\n7. **Advantage Actor-Critic (A2C)** - Synchronous advantage estimation\n8. **Twin Delayed DDPG (TD3)** - Continuous control\n9. **Soft Actor-Critic (SAC)** - Maximum entropy RL\n\n## SOP Framework: 5-Phase RL Training Deployment\n\n### Phase 1: Initialize Learning Environment (1-2 hours)\n\n**Objective:** Setup AgentDB learning infrastructure with environment configuration\n\n**Agent:** ml-developer\n\n**Steps:**\n\n1. **Install AgentDB Learning Module**\n```bash\nnpm install agentdb-learning@latest\nnpm install @agentdb\u002Frl-algorithms @agentdb\u002Fenvironments\n```\n\n2. **Initialize learning database**\n```typescript\nimport { AgentDB, LearningPlugin } from 'agentdb-learning';\n\nconst learningDB = new AgentDB({\n  name: 'rl-training-db',\n  dimensions: 512, \u002F\u002F State embedding dimension\n  learning: {\n    enabled: true,\n    persistExperience: true,\n    replayBufferSize: 100000\n  }\n});\n\nawait learningDB.initialize();\n\n\u002F\u002F Create learning plugin\nconst learningPlugin = new LearningPlugin({\n  database: learningDB,\n  algorithms: ['q-learning', 'dqn', 'ppo', 'actor-critic'],\n  config: {\n    batchSize: 64,\n    learningRate: 0.001,\n    discountFactor: 0.99,\n    explorationRate: 1.0,\n    explorationDecay: 0.995\n  }\n});\n\nawait learningPlugin.initialize();\n```\n\n3. **Define environment**\n```typescript\nimport { Environment } from '@agentdb\u002Fenvironments';\n\nconst environment = new Environment({\n  name: 'grid-world',\n  stateSpace: {\n    type: 'continuous',\n    shape: [10, 10],\n    bounds: [[0, 10], [0, 10]]\n  },\n  actionSpace: {\n    type: 'discrete',\n    actions: ['up', 'down', 'left', 'right']\n  },\n  rewardFunction: (state, action, nextState) => {\n    \u002F\u002F Distance to goal reward\n    const goalDistance = Math.sqrt(\n      Math.pow(nextState[0] - 9, 2) +\n      Math.pow(nextState[1] - 9, 2)\n    );\n    return -goalDistance + (goalDistance === 0 ? 100 : 0);\n  },\n  terminalCondition: (state) => {\n    return state[0] === 9 && state[1] === 9; \u002F\u002F Reached goal\n  }\n});\n\nawait environment.initialize();\n```\n\n4. **Setup monitoring**\n```typescript\nconst monitor = learningPlugin.createMonitor({\n  metrics: ['reward', 'loss', 'exploration-rate', 'episode-length'],\n  logInterval: 100, \u002F\u002F Log every 100 episodes\n  saveCheckpoints: true,\n  checkpointInterval: 1000\n});\n\nmonitor.on('episode-complete', (episode) => {\n  console.log('Episode:', episode.number, 'Reward:', episode.totalReward);\n});\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fenvironment', {\n  name: environment.name,\n  stateSpace: environment.stateSpace,\n  actionSpace: environment.actionSpace,\n  initialized: Date.now()\n});\n```\n\n**Validation:**\n- Learning database initialized\n- Environment configured and tested\n- Monitor capturing metrics\n- Configuration stored in memory\n\n### Phase 2: Configure RL Algorithm (1-2 hours)\n\n**Objective:** Select and configure RL algorithm for the learning task\n\n**Agent:** ml-developer\n\n**Steps:**\n\n1. **Select algorithm**\n```typescript\n\u002F\u002F Example: Deep Q-Network (DQN)\nconst dqnAgent = learningPlugin.createAgent({\n  algorithm: 'dqn',\n  config: {\n    networkArchitecture: {\n      layers: [\n        { type: 'dense', units: 128, activation: 'relu' },\n        { type: 'dense', units: 128, activation: 'relu' },\n        { type: 'dense', units: environment.actionSpace.size, activation: 'linear' }\n      ]\n    },\n    learningRate: 0.001,\n    batchSize: 64,\n    replayBuffer: {\n      size: 100000,\n      prioritized: true,\n      alpha: 0.6,\n      beta: 0.4\n    },\n    targetNetwork: {\n      updateFrequency: 1000,\n      tauSync: 0.001 \u002F\u002F Soft update\n    },\n    exploration: {\n      initial: 1.0,\n      final: 0.01,\n      decay: 0.995\n    },\n    training: {\n      startAfter: 1000, \u002F\u002F Start training after 1000 experiences\n      updateFrequency: 4\n    }\n  }\n});\n\nawait dqnAgent.initialize();\n```\n\n2. **Configure hyperparameters**\n```typescript\nconst hyperparameters = {\n  \u002F\u002F Learning parameters\n  learningRate: 0.001,\n  discountFactor: 0.99, \u002F\u002F Gamma\n  batchSize: 64,\n\n  \u002F\u002F Exploration\n  epsilonStart: 1.0,\n  epsilonEnd: 0.01,\n  epsilonDecay: 0.995,\n\n  \u002F\u002F Experience replay\n  replayBufferSize: 100000,\n  minReplaySize: 1000,\n  prioritizedReplay: true,\n\n  \u002F\u002F Training\n  maxEpisodes: 10000,\n  maxStepsPerEpisode: 1000,\n  targetUpdateFrequency: 1000,\n\n  \u002F\u002F Evaluation\n  evalFrequency: 100,\n  evalEpisodes: 10\n};\n\ndqnAgent.setHyperparameters(hyperparameters);\n```\n\n3. **Setup experience replay**\n```typescript\nimport { PrioritizedReplayBuffer } from '@agentdb\u002Frl-algorithms';\n\nconst replayBuffer = new PrioritizedReplayBuffer({\n  capacity: 100000,\n  alpha: 0.6, \u002F\u002F Prioritization exponent\n  beta: 0.4, \u002F\u002F Importance sampling\n  betaIncrement: 0.001,\n  epsilon: 0.01 \u002F\u002F Small constant for stability\n});\n\ndqnAgent.setReplayBuffer(replayBuffer);\n```\n\n4. **Configure training loop**\n```typescript\nconst trainingConfig = {\n  episodes: 10000,\n  stepsPerEpisode: 1000,\n  warmupSteps: 1000,\n  trainFrequency: 4,\n  targetUpdateFrequency: 1000,\n  saveFrequency: 1000,\n  evalFrequency: 100,\n  earlyStoppingPatience: 500,\n  earlyStoppingThreshold: 0.01\n};\n\ndqnAgent.setTrainingConfig(trainingConfig);\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Falgorithm-config', {\n  algorithm: 'dqn',\n  hyperparameters: hyperparameters,\n  trainingConfig: trainingConfig,\n  configured: Date.now()\n});\n```\n\n**Validation:**\n- Algorithm selected and configured\n- Hyperparameters validated\n- Replay buffer initialized\n- Training config set\n\n### Phase 3: Train Agents (3-4 hours)\n\n**Objective:** Execute training iterations and optimize agent behavior\n\n**Agent:** safla-neural\n\n**Steps:**\n\n1. **Start training loop**\n```typescript\nasync function trainAgent() {\n  console.log('Starting RL training...');\n\n  const trainingStats = {\n    episodes: [],\n    totalReward: [],\n    episodeLength: [],\n    loss: [],\n    explorationRate: []\n  };\n\n  for (let episode = 0; episode \u003C trainingConfig.episodes; episode++) {\n    let state = await environment.reset();\n    let episodeReward = 0;\n    let episodeLength = 0;\n    let episodeLoss = 0;\n\n    for (let step = 0; step \u003C trainingConfig.stepsPerEpisode; step++) {\n      \u002F\u002F Select action\n      const action = await dqnAgent.selectAction(state, {\n        explore: true\n      });\n\n      \u002F\u002F Execute action\n      const { nextState, reward, done } = await environment.step(action);\n\n      \u002F\u002F Store experience\n      await dqnAgent.storeExperience({\n        state,\n        action,\n        reward,\n        nextState,\n        done\n      });\n\n      \u002F\u002F Train if enough experiences\n      if (dqnAgent.canTrain()) {\n        const loss = await dqnAgent.train();\n        episodeLoss += loss;\n      }\n\n      episodeReward += reward;\n      episodeLength += 1;\n      state = nextState;\n\n      if (done) break;\n    }\n\n    \u002F\u002F Update target network\n    if (episode % trainingConfig.targetUpdateFrequency === 0) {\n      await dqnAgent.updateTargetNetwork();\n    }\n\n    \u002F\u002F Decay exploration\n    dqnAgent.decayExploration();\n\n    \u002F\u002F Log progress\n    trainingStats.episodes.push(episode);\n    trainingStats.totalReward.push(episodeReward);\n    trainingStats.episodeLength.push(episodeLength);\n    trainingStats.loss.push(episodeLoss \u002F episodeLength);\n    trainingStats.explorationRate.push(dqnAgent.getExplorationRate());\n\n    if (episode % 100 === 0) {\n      console.log(`Episode ${episode}:`, {\n        reward: episodeReward.toFixed(2),\n        length: episodeLength,\n        loss: (episodeLoss \u002F episodeLength).toFixed(4),\n        epsilon: dqnAgent.getExplorationRate().toFixed(3)\n      });\n    }\n\n    \u002F\u002F Save checkpoint\n    if (episode % trainingConfig.saveFrequency === 0) {\n      await dqnAgent.save(`checkpoint-${episode}`);\n    }\n\n    \u002F\u002F Evaluate\n    if (episode % trainingConfig.evalFrequency === 0) {\n      const evalReward = await evaluateAgent(dqnAgent, environment);\n      console.log(`Evaluation at episode ${episode}: ${evalReward.toFixed(2)}`);\n    }\n\n    \u002F\u002F Early stopping\n    if (checkEarlyStopping(trainingStats, episode)) {\n      console.log('Early stopping triggered');\n      break;\n    }\n  }\n\n  return trainingStats;\n}\n\nconst trainingStats = await trainAgent();\n```\n\n2. **Monitor training progress**\n```typescript\nmonitor.on('training-update', (stats) => {\n  \u002F\u002F Calculate moving averages\n  const window = 100;\n  const recentRewards = stats.totalReward.slice(-window);\n  const avgReward = recentRewards.reduce((a, b) => a + b, 0) \u002F recentRewards.length;\n\n  \u002F\u002F Store metrics\n  agentDB.memory.store('agentdb\u002Flearning\u002Ftraining-progress', {\n    episode: stats.episodes[stats.episodes.length - 1],\n    avgReward: avgReward,\n    explorationRate: stats.explorationRate[stats.explorationRate.length - 1],\n    timestamp: Date.now()\n  });\n\n  \u002F\u002F Plot learning curve (if visualization enabled)\n  if (monitor.visualization) {\n    monitor.plot('reward-curve', stats.episodes, stats.totalReward);\n    monitor.plot('loss-curve', stats.episodes, stats.loss);\n  }\n});\n```\n\n3. **Handle convergence**\n```typescript\nfunction checkConvergence(stats, windowSize = 100, threshold = 0.01) {\n  if (stats.totalReward.length \u003C windowSize * 2) {\n    return false;\n  }\n\n  const recent = stats.totalReward.slice(-windowSize);\n  const previous = stats.totalReward.slice(-windowSize * 2, -windowSize);\n\n  const recentAvg = recent.reduce((a, b) => a + b, 0) \u002F recent.length;\n  const previousAvg = previous.reduce((a, b) => a + b, 0) \u002F previous.length;\n\n  const improvement = (recentAvg - previousAvg) \u002F Math.abs(previousAvg);\n\n  return improvement \u003C threshold;\n}\n```\n\n4. **Save trained model**\n```typescript\nawait dqnAgent.save('trained-agent-final', {\n  includeReplayBuffer: false,\n  includeOptimizer: false,\n  metadata: {\n    trainingStats: trainingStats,\n    hyperparameters: hyperparameters,\n    finalReward: trainingStats.totalReward[trainingStats.totalReward.length - 1]\n  }\n});\n\nconsole.log('Training complete. Model saved.');\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Ftraining-results', {\n  algorithm: 'dqn',\n  episodes: trainingStats.episodes.length,\n  finalReward: trainingStats.totalReward[trainingStats.totalReward.length - 1],\n  converged: checkConvergence(trainingStats),\n  modelPath: 'trained-agent-final',\n  timestamp: Date.now()\n});\n```\n\n**Validation:**\n- Training completed or converged\n- Reward curve shows improvement\n- Model saved successfully\n- Training stats stored\n\n### Phase 4: Validate Performance (1-2 hours)\n\n**Objective:** Benchmark trained agent and validate performance\n\n**Agent:** performance-benchmarker\n\n**Steps:**\n\n1. **Load trained agent**\n```typescript\nconst trainedAgent = await learningPlugin.loadAgent('trained-agent-final');\n```\n\n2. **Run evaluation episodes**\n```typescript\nasync function evaluateAgent(agent, env, numEpisodes = 100) {\n  const results = {\n    rewards: [],\n    episodeLengths: [],\n    successRate: 0\n  };\n\n  for (let i = 0; i \u003C numEpisodes; i++) {\n    let state = await env.reset();\n    let episodeReward = 0;\n    let episodeLength = 0;\n    let success = false;\n\n    for (let step = 0; step \u003C 1000; step++) {\n      const action = await agent.selectAction(state, { explore: false });\n      const { nextState, reward, done } = await env.step(action);\n\n      episodeReward += reward;\n      episodeLength += 1;\n      state = nextState;\n\n      if (done) {\n        success = env.isSuccessful(state);\n        break;\n      }\n    }\n\n    results.rewards.push(episodeReward);\n    results.episodeLengths.push(episodeLength);\n    if (success) results.successRate += 1;\n  }\n\n  results.successRate \u002F= numEpisodes;\n\n  return {\n    meanReward: results.rewards.reduce((a, b) => a + b, 0) \u002F results.rewards.length,\n    stdReward: calculateStd(results.rewards),\n    meanLength: results.episodeLengths.reduce((a, b) => a + b, 0) \u002F results.episodeLengths.length,\n    successRate: results.successRate,\n    results: results\n  };\n}\n\nconst evalResults = await evaluateAgent(trainedAgent, environment, 100);\nconsole.log('Evaluation results:', evalResults);\n```\n\n3. **Compare with baseline**\n```typescript\n\u002F\u002F Random policy baseline\nconst randomAgent = learningPlugin.createAgent({ algorithm: 'random' });\nconst randomResults = await evaluateAgent(randomAgent, environment, 100);\n\n\u002F\u002F Calculate improvement\nconst improvement = {\n  rewardImprovement: (evalResults.meanReward - randomResults.meanReward) \u002F Math.abs(randomResults.meanReward),\n  lengthImprovement: (randomResults.meanLength - evalResults.meanLength) \u002F randomResults.meanLength,\n  successImprovement: evalResults.successRate - randomResults.successRate\n};\n\nconsole.log('Improvement over random:', improvement);\n```\n\n4. **Run comprehensive benchmarks**\n```typescript\nconst benchmarks = {\n  performanceMetrics: {\n    meanReward: evalResults.meanReward,\n    stdReward: evalResults.stdReward,\n    successRate: evalResults.successRate,\n    meanEpisodeLength: evalResults.meanLength\n  },\n  algorithmComparison: {\n    dqn: evalResults,\n    random: randomResults,\n    improvement: improvement\n  },\n  inferenceTiming: {\n    actionSelection: 0,\n    totalEpisode: 0\n  }\n};\n\n\u002F\u002F Measure inference speed\nconst timingTrials = 1000;\nconst startTime = performance.now();\nfor (let i = 0; i \u003C timingTrials; i++) {\n  const state = await environment.randomState();\n  await trainedAgent.selectAction(state, { explore: false });\n}\nconst endTime = performance.now();\nbenchmarks.inferenceTiming.actionSelection = (endTime - startTime) \u002F timingTrials;\n\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fbenchmarks', benchmarks);\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fvalidation', {\n  evaluated: true,\n  meanReward: evalResults.meanReward,\n  successRate: evalResults.successRate,\n  improvement: improvement,\n  timestamp: Date.now()\n});\n```\n\n**Validation:**\n- Evaluation completed (100 episodes)\n- Mean reward exceeds threshold\n- Success rate acceptable\n- Improvement over baseline demonstrated\n\n### Phase 5: Deploy Trained Agents (1-2 hours)\n\n**Objective:** Deploy trained agents to production environment\n\n**Agent:** ml-developer\n\n**Steps:**\n\n1. **Export production model**\n```typescript\nawait trainedAgent.export('production-agent', {\n  format: 'onnx', \u002F\u002F or 'tensorflowjs', 'pytorch'\n  optimize: true,\n  quantize: 'int8', \u002F\u002F Quantization for faster inference\n  includeMetadata: true\n});\n```\n\n2. **Create inference API**\n```typescript\nimport express from 'express';\n\nconst app = express();\napp.use(express.json());\n\n\u002F\u002F Load production agent\nconst productionAgent = await learningPlugin.loadAgent('production-agent');\n\napp.post('\u002Fapi\u002Fpredict', async (req, res) => {\n  try {\n    const { state } = req.body;\n\n    const action = await productionAgent.selectAction(state, {\n      explore: false,\n      returnProbabilities: true\n    });\n\n    res.json({\n      action: action.action,\n      probabilities: action.probabilities,\n      confidence: action.confidence\n    });\n  } catch (error) {\n    res.status(500).json({ error: error.message });\n  }\n});\n\napp.listen(3000, () => {\n  console.log('RL agent API running on port 3000');\n});\n```\n\n3. **Setup monitoring**\n```typescript\nimport { ProductionMonitor } from '@agentdb\u002Fmonitoring';\n\nconst prodMonitor = new ProductionMonitor({\n  agent: productionAgent,\n  metrics: ['inference-latency', 'action-distribution', 'reward-feedback'],\n  alerting: {\n    latencyThreshold: 100, \u002F\u002F ms\n    anomalyDetection: true\n  }\n});\n\nawait prodMonitor.start();\n```\n\n4. **Create deployment pipeline**\n```typescript\nconst deploymentPipeline = {\n  stages: [\n    {\n      name: 'validation',\n      steps: [\n        'Load trained model',\n        'Run validation suite',\n        'Check performance metrics',\n        'Verify inference speed'\n      ]\n    },\n    {\n      name: 'export',\n      steps: [\n        'Export to production format',\n        'Optimize model',\n        'Quantize weights',\n        'Package artifacts'\n      ]\n    },\n    {\n      name: 'deployment',\n      steps: [\n        'Deploy to staging',\n        'Run smoke tests',\n        'Deploy to production',\n        'Monitor performance'\n      ]\n    }\n  ]\n};\n\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fdeployment-pipeline', deploymentPipeline);\n```\n\n**Memory Pattern:**\n```typescript\nawait agentDB.memory.store('agentdb\u002Flearning\u002Fproduction', {\n  deployed: true,\n  modelPath: 'production-agent',\n  apiEndpoint: 'http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fpredict',\n  monitoring: true,\n  timestamp: Date.now()\n});\n```\n\n**Validation:**\n- Model exported successfully\n- API running and responding\n- Monitoring active\n- Deployment pipeline documented\n\n## Integration Scripts\n\n### Complete Training Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# train-rl-agent.sh\n\nset -e\n\necho \"AgentDB RL Training Script\"\necho \"==========================\"\n\n# Phase 1: Initialize\necho \"Phase 1: Initializing learning environment...\"\nnpm install agentdb-learning @agentdb\u002Frl-algorithms\n\n# Phase 2: Configure\necho \"Phase 2: Configuring algorithm...\"\nnode -e \"require('.\u002Fconfig-algorithm.js')\"\n\n# Phase 3: Train\necho \"Phase 3: Training agent...\"\nnode -e \"require('.\u002Ftrain-agent.js')\"\n\n# Phase 4: Validate\necho \"Phase 4: Validating performance...\"\nnode -e \"require('.\u002Fevaluate-agent.js')\"\n\n# Phase 5: Deploy\necho \"Phase 5: Deploying to production...\"\nnode -e \"require('.\u002Fdeploy-agent.js')\"\n\necho \"Training complete!\"\n```\n\n### Quick Start Script\n\n```typescript\n\u002F\u002F quickstart-rl.ts\nimport { setupRLTraining } from '.\u002Fsetup';\n\nasync function quickStart() {\n  console.log('Starting RL training quick setup...');\n\n  \u002F\u002F Setup\n  const { learningDB, environment, agent } = await setupRLTraining({\n    algorithm: 'dqn',\n    environment: 'grid-world',\n    episodes: 1000\n  });\n\n  \u002F\u002F Train\n  console.log('Training agent...');\n  const stats = await agent.train(environment, {\n    episodes: 1000,\n    logInterval: 100\n  });\n\n  \u002F\u002F Evaluate\n  console.log('Evaluating agent...');\n  const results = await agent.evaluate(environment, {\n    episodes: 100\n  });\n  console.log('Results:', results);\n\n  \u002F\u002F Save\n  await agent.save('quickstart-agent');\n  console.log('Quick start complete!');\n}\n\nquickStart().catch(console.error);\n```\n\n## Evidence-Based Success Criteria\n\n1. **Training Convergence (Self-Consistency)**\n   - Reward curve stabilizes\n   - Moving average improvement \u003C 1%\n   - Agent achieves consistent performance\n\n2. **Performance Benchmarks (Quantitative)**\n   - Mean reward exceeds baseline by 50%\n   - Success rate > 80%\n   - Inference time \u003C 10ms per action\n\n3. **Algorithm Validation (Chain-of-Verification)**\n   - Hyperparameters validated\n   - Exploration-exploitation balanced\n   - Experience replay functioning\n\n4. **Production Readiness (Multi-Agent Consensus)**\n   - Model exported successfully\n   - API responds within latency threshold\n   - Monitoring active and alerting\n   - Deployment pipeline documented\n\n## Additional Resources\n\n- AgentDB Learning Documentation: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Flearning\n- RL Algorithms Guide: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Frl-algorithms\n- Training Best Practices: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Ftraining\n- Production Deployment: https:\u002F\u002Fagentdb.dev\u002Fdocs\u002Fdeployment\n",{"name":5,"agents":57,"outputs":61,"version":66,"category":67,"metadata":68,"skill_id":76,"complexity":77,"description":7,"subcategory":78,"prerequisites":79,"trigger_pattern":84,"estimated_duration":85,"validation_criteria":86,"evidence_based_techniques":91},[58,59,60],"ml-developer","safla-neural","performance-benchmarker",[62,63,64,65],"Trained RL agents","Learning plugin modules","Performance benchmarks","Deployment pipeline","1.0.0","agentdb",{"tags":69,"author":74,"created":75,"updated":75},[67,70,71,72,73],"reinforcement-learning","neural-networks","ai-training","q-learning","claude-flow",1761782400000,"when-training-rl-agents-use-agentdb-learning","advanced","machine-learning",[80,81,82,83],"AgentDB basics","Reinforcement learning fundamentals","Neural network knowledge","Python\u002FTypeScript proficiency","when-training-rl-agents","6-10 hours",[87,88,89,90],"Training converges successfully","Reward curve shows improvement","Agent passes validation tasks","Benchmarks meet targets",[92,93,94,95],"Self-consistency validation","Program-of-thought decomposition","Chain-of-verification","Multi-agent consensus","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":106,"prompt":116,"zipAvailable":117},[107,110,113],{"tool":108,"command":109},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill agentdb-reinforcement-learning-training",{"tool":111,"command":112},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill agentdb-reinforcement-learning-training",{"tool":114,"command":115},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill agentdb-reinforcement-learning-training","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training\u002FSKILL.md",true,[119,125,131,135],{"path":120,"resourceType":121,"resourceTypeDesc":122,"sizeBytes":123,"sourceHtmlUrl":124},"process-diagram.gv","OTHER","其他",4349,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training\u002Fprocess-diagram.gv",{"path":126,"resourceType":127,"resourceTypeDesc":128,"sizeBytes":129,"sourceHtmlUrl":130},"PROCESS.md","REFERENCE","参考文档",3638,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training\u002FPROCESS.md",{"path":132,"resourceType":127,"resourceTypeDesc":128,"sizeBytes":133,"sourceHtmlUrl":134},"README.md",1613,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training\u002FREADME.md",{"path":136,"resourceType":127,"resourceTypeDesc":128,"sizeBytes":137,"sourceHtmlUrl":138},"skill-report.json",18692,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fdnyoussef\u002Fagentdb-reinforcement-learning-training\u002Fskill-report.json",[140,150,160,169,175,182],{"skillNo":141,"name":142,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":146,"publishedAt":52},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[145],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[147,148,149],"model","model hierarchy","model hierarchy skill",{"skillNo":151,"name":152,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":153,"categories":154,"keywords":156,"publishedAt":52},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[155],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[157,158,159],"MCP","zoom","zoom mcp",{"skillNo":161,"name":162,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":52},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[166,167,168,158],"sdk","zoom apps sdk","apps",{"skillNo":170,"name":171,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":174,"publishedAt":52},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[171],{"skillNo":176,"name":177,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":181,"publishedAt":52},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[180],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[177],{"skillNo":183,"name":184,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":52},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[184]]