oxicode_agent/agent_loop/
queues.rs1const STEERING_QUEUE_CAPACITY: usize = 256;
8
9const FOLLOW_UP_QUEUE_CAPACITY: usize = 64;
11
12pub(crate) fn clear_steering_queue(loop_ref: &super::AgentLoop) {
14 loop_ref.steering_queue.write().clear();
15}
16
17pub(crate) fn clear_follow_up_queue(loop_ref: &super::AgentLoop) {
19 loop_ref.follow_up_queue.write().clear();
20}
21
22pub(crate) fn clear_all_queues(loop_ref: &super::AgentLoop) {
24 clear_steering_queue(loop_ref);
25 clear_follow_up_queue(loop_ref);
26}
27
28pub(crate) fn drain_steering_queue(loop_ref: &super::AgentLoop) -> Vec<oxicode_ai::Message> {
30 let mut queue = loop_ref.steering_queue.write();
31 queue.drain(..).collect()
32}
33
34pub(crate) fn drain_follow_up_queue(loop_ref: &super::AgentLoop) -> Vec<oxicode_ai::Message> {
36 let mut queue = loop_ref.follow_up_queue.write();
37 queue.drain(..).collect()
38}
39
40pub(crate) fn try_push_steering(loop_ref: &super::AgentLoop, message: oxicode_ai::Message) -> bool {
45 let mut queue = loop_ref.steering_queue.write();
46 if queue.len() >= STEERING_QUEUE_CAPACITY {
47 tracing::warn!(
48 capacity = STEERING_QUEUE_CAPACITY,
49 "Steering queue at capacity — dropping message"
50 );
51 return false;
52 }
53 queue.push(message);
54 true
55}
56
57pub(crate) fn try_push_follow_up(
62 loop_ref: &super::AgentLoop,
63 message: oxicode_ai::Message,
64) -> bool {
65 let mut queue = loop_ref.follow_up_queue.write();
66 if queue.len() >= FOLLOW_UP_QUEUE_CAPACITY {
67 tracing::warn!(
68 capacity = FOLLOW_UP_QUEUE_CAPACITY,
69 "Follow-up queue at capacity — dropping message"
70 );
71 return false;
72 }
73 queue.push(message);
74 true
75}
76
77#[allow(dead_code)]
79pub(crate) fn steering_queue_len(loop_ref: &super::AgentLoop) -> usize {
80 loop_ref.steering_queue.read().len()
81}
82
83#[allow(dead_code)]
85pub(crate) fn follow_up_queue_len(loop_ref: &super::AgentLoop) -> usize {
86 loop_ref.follow_up_queue.read().len()
87}