collet 0.1.1

Relentless agentic coding orchestrator with zero-drop agent loops
Documentation
use crate::agent::context::ConversationContext;
use crate::api::models::Message;

/// Apply a worker instruction by injecting a system message into the context.
pub(super) fn apply_worker_instruction(
    instr: crate::agent::swarm::knowledge::WorkerInstruction,
    context: &mut ConversationContext,
) {
    use crate::agent::swarm::knowledge::WorkerInstruction;
    let msg = match instr {
        WorkerInstruction::Redirect { new_focus } => format!(
            "[SYSTEM] Your task focus has been redirected by the user. \
             New focus: {new_focus}\n\
             Adjust your approach accordingly. Do not continue the previous direction."
        ),
        WorkerInstruction::Hint { text } => format!("[SYSTEM] Hint from user: {text}"),
        WorkerInstruction::Resume => {
            // Already handled in the pause loop; no-op if received outside pause.
            return;
        }
        WorkerInstruction::Pause => {
            // Handled by the caller setting the paused flag.
            return;
        }
    };
    context.push(Message {
        role: "user".to_string(),
        content: Some(crate::api::Content::text(msg)),
        reasoning_content: None,
        tool_calls: None,
        tool_call_id: None,
    });
}