{"record":{"id":"a22e7118f6076e51","repo":"tracel-ai/burn","slug":"autobatcher-should-be-able-to-send-resulting-actio","errorCode":null,"errorMessage":"Autobatcher should be able to send resulting actions.","messagePattern":"Autobatcher should be able to send resulting actions\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-rl/src/policy/async_policy.rs","lineNumber":96,"sourceCode":"        let input: Vec<_> = self\n            .batch_action\n            .iter()\n            .map(|m| m.inference_state.clone())\n            .collect();\n        // Only deterministic if all actions are requested as deterministic.\n        let deterministic = self.batch_action.iter().all(|item| item.deterministic);\n        let (actions, context) = self\n            .inner_policy\n            .action(P::Observation::batch(input), deterministic);\n        let actions: Vec<_> = actions.unbatch();\n\n        for (i, item) in self.batch_action.iter().enumerate() {\n            item.sender\n                .send(ActionContext {\n                    context: vec![context[i].clone()],\n                    action: actions[i].clone(),\n                })\n                .expect(\"Autobatcher should be able to send resulting actions.\");\n        }\n        self.batch_action.clear();\n    }\n\n    pub fn flush_logits(&mut self) {\n        if self.len_logits() == 0 {\n            return;\n        }\n        let input: Vec<_> = self\n            .batch_logits\n            .iter()\n            .map(|m| m.inference_state.clone())\n            .collect();\n        let output = self.inner_policy.forward(P::Observation::batch(input));\n        let logits: Vec<_> = output.unbatch();\n        for (i, item) in self.batch_logits.iter().enumerate() {\n            item.sender\n                .send(logits[i].clone())","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-rl/src/policy/async_policy.rs#L78-L114","documentation":"flush_actions sends each batched action back to its waiting agent via a oneshot sender and expects delivery to succeed. Panic means a receiver was already dropped — the agent went away before the policy flushed the batch.","triggerScenarios":"An agent thread/context is dropped (decremented/aborted) after push_action queued its sender but before update_policy's flush_actions runs; then send() fails on the dead receiver.","commonSituations":"Aborting agent tasks mid-episode; panics in agent code dropping its receiver; calling decrement_agents while batched actions are still pending; race between policy update and agent teardown.","solutions":["Ensure agents stay alive until flush_actions completes — don't drop their receivers mid-batch","Drain/flush pending actions before decrementing agents or updating the policy","Make agent shutdown cooperative: let it consume its action before terminating","Replace expect with error handling to skip dead receivers instead of panicking"],"exampleFix":"// before\nitem.sender.send(ActionContext { ... })\n    .expect(\"Autobatcher should be able to send resulting actions.\");\n// after\nif item.sender.send(ActionContext { ... }).is_err() {\n    // receiver dropped; skip this agent\n}","handlingStrategy":"try-catch","validationCode":"// Before update_policy, confirm all batched agents still hold receivers\nassert_eq!(self.batch_action.iter().filter(|i| i.sender.is_closed()).count(), 0,\n    \"some agents dropped before flush_actions\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = item.sender.send(ActionContext { context: vec![context[i].clone()], action: actions[i].clone() }) {\n    log::warn!(\"agent receiver dropped, skipping: {e}\");\n    continue;\n}","preventionTips":["Don't drop agent receivers mid-batch; use cooperative shutdown","Flush pending actions before decrement_agents or policy updates","Treat send errors as agent-loss, not a panic condition"],"tags":["rust","channels","concurrency","reinforcement-learning"],"backgroundTag":"channel-send-failed","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}