MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / insert_reminders

Function insert_reminders

crates/opencode-session/src/prompt.rs:3027–3071  ·  view source on GitHub ↗
(
    messages: &[SessionMessage],
    agent_name: &str,
    was_plan: bool,
)

Source from the content-addressed store, hash-verified

3025- Report progress to the user"#;
3026
3027pub fn insert_reminders(
3028 messages: &[SessionMessage],
3029 agent_name: &str,
3030 was_plan: bool,
3031) -> Vec<SessionMessage> {
3032 let last_user_idx = messages
3033 .iter()
3034 .rposition(|m| matches!(m.role, MessageRole::User));
3035
3036 if let Some(idx) = last_user_idx {
3037 let mut messages = messages.to_vec();
3038
3039 if agent_name == "plan" {
3040 let reminder_text = PROMPT_PLAN.to_string();
3041 messages[idx].parts.push(crate::MessagePart {
3042 id: format!("prt_{}", uuid::Uuid::new_v4()),
3043 part_type: PartType::Text {
3044 text: reminder_text,
3045 synthetic: None,
3046 ignored: None,
3047 },
3048 created_at: chrono::Utc::now(),
3049 message_id: None,
3050 });
3051 }
3052
3053 if was_plan && agent_name == "build" {
3054 let reminder_text = BUILD_SWITCH.to_string();
3055 messages[idx].parts.push(crate::MessagePart {
3056 id: format!("prt_{}", uuid::Uuid::new_v4()),
3057 part_type: PartType::Text {
3058 text: reminder_text,
3059 synthetic: None,
3060 ignored: None,
3061 },
3062 created_at: chrono::Utc::now(),
3063 message_id: None,
3064 });
3065 }
3066
3067 messages
3068 } else {
3069 messages.to_vec()
3070 }
3071}
3072
3073pub fn was_plan_agent(messages: &[SessionMessage]) -> bool {
3074 messages.iter().any(|m| {

Calls

no outgoing calls