rho-coding-agent 3.12.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use pretty_assertions::assert_eq;

use super::{of, section};
use crate::prompt::{HostPrompt, HostPromptMode};

/// A text a session's launch adds after its agent's instructions.
const SUFFIX: &str = "# Child contract\n\nReport to your parent.";

// Covers: the agent instructions a rendered prompt holds read back as they
// were rendered: alone at its end, before the host's appended section,
// before a launch's suffix, and not at all from a prompt without the
// section. A miss gives a reopened
// session the wrong instructions, or someone else's text as its own.
// Owner: system prompt agent section.
#[test]
fn agent_instructions_read_back_as_rendered() {
    let host = HostPrompt {
        mode: HostPromptMode::Append,
        text: "Answer as a pirate.".into(),
    }
    .appended_section()
    .expect("an appended section");
    let lead = "You lead.\n\n## Rules\n\nBe brief.";
    let cases = [
        ("alone", format!("Base.{}", section(lead)), Some(lead)),
        (
            "before the host's section",
            format!("Base.{}{host}", section(lead)),
            Some(lead),
        ),
        (
            "before a suffix",
            format!("Base.{}\n\n{SUFFIX}{host}", section(lead)),
            Some(lead),
        ),
        ("without the section", format!("Base.{host}"), None),
    ];
    for (name, system, expected) in cases {
        assert_eq!(of(&system, &[SUFFIX]), expected, "{name}");
    }
}