Watch
0
0
Fork
You've already forked hyperhive
0

an archetype's prompt prefills the new agent's agents.md in the create form

This commit is contained in:
atlas 2026-11-11 00:40:40 +01:00 • committed by mara
commit a5470d82ae

View file

@ -21,6 +21,10 @@ pub const BUCKET: &str = "agent-archetypes";
/// there is so far.
pub const BUILTIN_SOURCE: &str = "hyperhive";
/// The most bytes an archetype's `meta.prompt` may hold: the limit of an
/// agent's initial `AGENTS.md`, which the prompt prefills.
pub const MAX_PROMPT_BYTES: usize = crate::agents_md_initial::MAX_BYTES;
/// One source's archetypes: the value under `BUCKET`/`<source>`.
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct SourceRecord {
@ -46,6 +50,10 @@ pub struct ArchetypeMeta {
pub limits: Option<AgentCaps>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub inference: Option<AgentInference>,
/// The text the create form prefills an agent's initial `AGENTS.md` with,
/// at most [`MAX_PROMPT_BYTES`]. Absent prefills nothing.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub prompt: Option<String>,
}
/// Open the archetype bucket for writing, creating it if nothing has yet.
@ -114,4 +122,18 @@ mod tests {
r#"{"source":"/nix/store/h","archetypes":{"reviewer":{"description":"reads","permissions":["messaging"]}}}"#
);
}
/// A record stored before `prompt` existed still parses, with no prompt;
/// one with a prompt round-trips it.
#[test]
fn prompt_is_optional_on_the_wire() {
let old = r#"{"source":"s","archetypes":{"reviewer":{"description":"reads"}}}"#;
let mut record: SourceRecord = serde_json::from_str(old).unwrap();
assert_eq!(record.archetypes["reviewer"].prompt, None);
record.archetypes.get_mut("reviewer").unwrap().prompt = Some("be brief".to_owned());
let wire = serde_json::to_string(&record).unwrap();
assert!(wire.contains(r#""prompt":"be brief""#), "{wire}");
assert_eq!(serde_json::from_str::<SourceRecord>(&wire).unwrap(), record);
}
}