Carry dynamic Verse context in worker launches
This commit is contained in:
parent
0fca183873
commit
edd93a11b9
13 changed files with 140 additions and 16 deletions
|
|
@ -452,6 +452,24 @@ pub fn build_epiphany_role_launch_request(
|
|||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
) -> Result<EpiphanyJobLaunchRequest, String> {
|
||||
build_epiphany_role_launch_request_with_dynamic_context(
|
||||
thread_id,
|
||||
role_id,
|
||||
expected_revision,
|
||||
max_runtime_seconds,
|
||||
state,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_role_launch_request_with_dynamic_context(
|
||||
thread_id: &str,
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
dynamic_prompt_context: Option<String>,
|
||||
) -> Result<EpiphanyJobLaunchRequest, String> {
|
||||
let binding_id = epiphany_role_binding_id(role_id)?;
|
||||
let owner_role = epiphany_role_owner(role_id)?;
|
||||
|
|
@ -487,6 +505,7 @@ pub fn build_epiphany_role_launch_request(
|
|||
role_id: epiphany_role_label(role_id).to_string(),
|
||||
state_revision: state.revision,
|
||||
objective: state.objective.clone(),
|
||||
dynamic_prompt_context,
|
||||
active_subgoal_id: state.active_subgoal_id.clone(),
|
||||
active_subgoals: state
|
||||
.subgoals
|
||||
|
|
@ -551,6 +570,26 @@ pub fn build_epiphany_reorient_launch_request(
|
|||
state: &EpiphanyThreadState,
|
||||
checkpoint: &EpiphanyInvestigationCheckpoint,
|
||||
decision: &CoreEpiphanyReorientDecision,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
build_epiphany_reorient_launch_request_with_dynamic_context(
|
||||
thread_id,
|
||||
expected_revision,
|
||||
max_runtime_seconds,
|
||||
state,
|
||||
checkpoint,
|
||||
decision,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_reorient_launch_request_with_dynamic_context(
|
||||
thread_id: &str,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
checkpoint: &EpiphanyInvestigationCheckpoint,
|
||||
decision: &CoreEpiphanyReorientDecision,
|
||||
dynamic_prompt_context: Option<String>,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
let instruction = build_epiphany_reorient_launch_instruction(decision.action);
|
||||
build_reorient_job_launch_request(EpiphanyReorientLaunchRequestInput {
|
||||
|
|
@ -563,6 +602,7 @@ pub fn build_epiphany_reorient_launch_request(
|
|||
state,
|
||||
checkpoint,
|
||||
decision,
|
||||
dynamic_prompt_context,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ use epiphany_core::EpiphanyMemoryNodeKind;
|
|||
use epiphany_core::EpiphanyMemoryProfile;
|
||||
use epiphany_core::EpiphanyMemorySummary;
|
||||
use epiphany_core::EpiphanyPromptContextInput;
|
||||
use epiphany_core::EpiphanyRoleResultRoleId;
|
||||
use epiphany_core::EpiphanyThreadState;
|
||||
use epiphany_core::EpiphanyWorkerLaunchDocument;
|
||||
use epiphany_core::build_epiphany_role_launch_request_with_dynamic_context;
|
||||
use epiphany_core::memory_graph_domain_id;
|
||||
use epiphany_core::memory_graph_node_id;
|
||||
use epiphany_core::plan_memory_graph_context_cut;
|
||||
|
|
@ -65,6 +69,26 @@ fn main() -> Result<()> {
|
|||
anyhow::bail!("prompt context smoke failed rendered packet checks:\n{rendered}");
|
||||
}
|
||||
|
||||
let launch_request = build_epiphany_role_launch_request_with_dynamic_context(
|
||||
"thread-prompt-context-smoke",
|
||||
EpiphanyRoleResultRoleId::Modeling,
|
||||
Some(1),
|
||||
Some(60),
|
||||
&EpiphanyThreadState {
|
||||
revision: 1,
|
||||
objective: Some("Launch a worker with bounded dynamic context.".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
Some(rendered.clone()),
|
||||
)
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let EpiphanyWorkerLaunchDocument::Role(role_document) = &launch_request.launch_document else {
|
||||
anyhow::bail!("prompt context smoke expected a role launch document");
|
||||
};
|
||||
if role_document.dynamic_prompt_context.as_deref() != Some(rendered.as_str()) {
|
||||
anyhow::bail!("prompt context smoke failed to preserve dynamic launch context");
|
||||
}
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
|
|
@ -73,6 +97,7 @@ fn main() -> Result<()> {
|
|||
"renderedBytes": rendered.len(),
|
||||
"containsVerseContext": true,
|
||||
"containsMemoryContext": true,
|
||||
"launchDocumentCarriesContext": true,
|
||||
"omitsUnselectedPrivateText": true,
|
||||
}))?
|
||||
);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ pub use agent_launch::EpiphanySpecialistPromptConfig;
|
|||
pub use agent_launch::build_epiphany_job_launch_request;
|
||||
pub use agent_launch::build_epiphany_reorient_launch_instruction;
|
||||
pub use agent_launch::build_epiphany_reorient_launch_request;
|
||||
pub use agent_launch::build_epiphany_reorient_launch_request_with_dynamic_context;
|
||||
pub use agent_launch::build_epiphany_role_launch_request;
|
||||
pub use agent_launch::build_epiphany_role_launch_request_with_dynamic_context;
|
||||
pub use agent_launch::epiphany_agent_prompt_with_memory;
|
||||
pub use agent_launch::epiphany_reorient_launch_output_schema;
|
||||
pub use agent_launch::epiphany_role_binding_id;
|
||||
|
|
|
|||
|
|
@ -3365,6 +3365,7 @@ mod tests {
|
|||
role_id: "modeling".to_string(),
|
||||
state_revision: 7,
|
||||
objective: Some("Run heartbeat worker.".to_string()),
|
||||
dynamic_prompt_context: None,
|
||||
active_subgoal_id: None,
|
||||
active_subgoals: Vec::new(),
|
||||
active_graph_node_ids: vec!["node-model".to_string()],
|
||||
|
|
@ -3453,6 +3454,7 @@ mod tests {
|
|||
role_id: "modeling".to_string(),
|
||||
state_revision: 7,
|
||||
objective: Some("keep state typed".to_string()),
|
||||
dynamic_prompt_context: None,
|
||||
active_subgoal_id: None,
|
||||
active_subgoals: Vec::new(),
|
||||
active_graph_node_ids: vec!["runtime-spine".to_string()],
|
||||
|
|
@ -3536,6 +3538,7 @@ mod tests {
|
|||
role_id: "modeling".to_string(),
|
||||
state_revision: 7,
|
||||
objective: None,
|
||||
dynamic_prompt_context: None,
|
||||
active_subgoal_id: None,
|
||||
active_subgoals: Vec::new(),
|
||||
active_graph_node_ids: Vec::new(),
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ mod tests {
|
|||
role_id: "research".to_string(),
|
||||
state_revision: 7,
|
||||
objective: None,
|
||||
dynamic_prompt_context: None,
|
||||
active_subgoal_id: None,
|
||||
active_subgoals: Vec::new(),
|
||||
active_graph_node_ids: Vec::new(),
|
||||
|
|
|
|||
|
|
@ -55,6 +55,15 @@ impl EpiphanyWorkerLaunchDocument {
|
|||
Self::Reorient(document) => &document.thread_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dynamic_prompt_context(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Role(document) => document.dynamic_prompt_context.as_deref(),
|
||||
Self::Reorient(document) => document.dynamic_prompt_context.as_deref(),
|
||||
}
|
||||
.map(str::trim)
|
||||
.filter(|context| !context.is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
|
|
@ -66,6 +75,8 @@ pub struct EpiphanyRoleWorkerLaunchDocument {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub objective: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub dynamic_prompt_context: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub active_subgoal_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub active_subgoals: Vec<EpiphanySubgoal>,
|
||||
|
|
@ -102,6 +113,8 @@ pub struct EpiphanyReorientWorkerLaunchDocument {
|
|||
pub checkpoint_kind: String,
|
||||
pub checkpoint_disposition: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub dynamic_prompt_context: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub checkpoint_focus: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub checkpoint_summary: Option<String>,
|
||||
|
|
@ -149,6 +162,7 @@ pub struct EpiphanyReorientLaunchRequestInput<'a> {
|
|||
pub state: &'a EpiphanyThreadState,
|
||||
pub checkpoint: &'a EpiphanyInvestigationCheckpoint,
|
||||
pub decision: &'a EpiphanyReorientDecision,
|
||||
pub dynamic_prompt_context: Option<String>,
|
||||
}
|
||||
|
||||
pub fn build_reorient_job_launch_request(
|
||||
|
|
@ -168,6 +182,7 @@ pub fn build_reorient_job_launch_request(
|
|||
input.decision,
|
||||
linked_subgoal_ids.clone(),
|
||||
linked_graph_node_ids.clone(),
|
||||
input.dynamic_prompt_context,
|
||||
));
|
||||
let output_contract_id = launch_document.output_contract_id().to_string();
|
||||
let organ_launch_contract = crate::default_launch_organ_contract(
|
||||
|
|
@ -200,6 +215,7 @@ fn build_reorient_worker_launch_document(
|
|||
decision: &EpiphanyReorientDecision,
|
||||
linked_subgoal_ids: Vec<String>,
|
||||
linked_graph_node_ids: Vec<String>,
|
||||
dynamic_prompt_context: Option<String>,
|
||||
) -> EpiphanyReorientWorkerLaunchDocument {
|
||||
EpiphanyReorientWorkerLaunchDocument {
|
||||
thread_id: thread_id.to_string(),
|
||||
|
|
@ -207,6 +223,7 @@ fn build_reorient_worker_launch_document(
|
|||
checkpoint_id: checkpoint.checkpoint_id.clone(),
|
||||
checkpoint_kind: checkpoint.kind.clone(),
|
||||
checkpoint_disposition: investigation_disposition_label(checkpoint.disposition).to_string(),
|
||||
dynamic_prompt_context,
|
||||
checkpoint_focus: Some(checkpoint.focus.clone()),
|
||||
checkpoint_summary: checkpoint.summary.clone(),
|
||||
checkpoint_next_action: checkpoint
|
||||
|
|
@ -404,6 +421,10 @@ mod tests {
|
|||
state: &state,
|
||||
checkpoint: &checkpoint,
|
||||
decision: &decision,
|
||||
dynamic_prompt_context: Some(
|
||||
"<epiphany_dynamic_context>\ncheckpoint weather\n</epiphany_dynamic_context>"
|
||||
.to_string(),
|
||||
),
|
||||
});
|
||||
|
||||
assert_eq!(request.binding_id, "reorient-worker");
|
||||
|
|
@ -424,5 +445,9 @@ mod tests {
|
|||
assert_eq!(document.retrieval_status, "stale");
|
||||
assert_eq!(document.graph_status, "changed");
|
||||
assert_eq!(document.watcher_status, "dirty");
|
||||
assert_eq!(
|
||||
document.dynamic_prompt_context.as_deref(),
|
||||
Some("<epiphany_dynamic_context>\ncheckpoint weather\n</epiphany_dynamic_context>")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue