Skip to main content

okbot_agent/
prompt.rs

1//! Prompt helpers.
2
3/// Combines a system prompt and a user prompt for backends without a separate system prompt.
4///
5/// The system part is fenced so the agent can tell instructions from the conversation.
6pub fn inline_system_prompt(system: &str, prompt: &str) -> String {
7    if system.trim().is_empty() {
8        return prompt.to_string();
9    }
10    format!(
11        "<instructions>\n{}\n</instructions>\n\n{}",
12        system.trim(),
13        prompt
14    )
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20
21    #[test]
22    fn inlines_system() {
23        assert_eq!(inline_system_prompt("", "hi"), "hi");
24        assert_eq!(
25            inline_system_prompt("be nice", "hi"),
26            "<instructions>\nbe nice\n</instructions>\n\nhi"
27        );
28    }
29}