e2e testing

This commit is contained in:
2026-08-10 07:22:56 -05:00
parent fa43f723a5
commit 88ad290c7e
29 changed files with 1695 additions and 99 deletions
+64 -1
View File
@@ -294,8 +294,8 @@ impl AIAgentActionResultType {
| Self::StartAgent(_)
| Self::SendMessageToAgent(_)
| Self::AskUserQuestion(_)
| Self::RunAgents(_)
| Self::WaitForEvents(_) => self.to_string(),
Self::RunAgents(result) => result.model_content(),
}
}
}
@@ -1629,6 +1629,69 @@ pub enum RunAgentsAgentOutcomeKind {
Failed { error: String },
}
impl RunAgentsResult {
fn model_content(&self) -> String {
let value = match self {
Self::Launched {
model_id,
harness_type,
execution_mode,
agents,
} => {
let execution_mode = match execution_mode {
RunAgentsLaunchedExecutionMode::Local => serde_json::json!({
"type": "local",
}),
RunAgentsLaunchedExecutionMode::Remote {
environment_id,
worker_host,
computer_use_enabled,
} => serde_json::json!({
"type": "remote",
"environment_id": environment_id,
"worker_host": worker_host,
"computer_use_enabled": computer_use_enabled,
}),
};
let agents = agents
.iter()
.map(|agent| match &agent.kind {
RunAgentsAgentOutcomeKind::Launched { agent_id } => serde_json::json!({
"name": agent.name,
"status": "launched",
"agent_id": agent_id,
}),
RunAgentsAgentOutcomeKind::Failed { error } => serde_json::json!({
"name": agent.name,
"status": "failed",
"error": error,
}),
})
.collect::<Vec<_>>();
serde_json::json!({
"status": "launched",
"model_id": model_id,
"harness_type": harness_type,
"execution_mode": execution_mode,
"agents": agents,
})
}
Self::Denied { reason } => serde_json::json!({
"status": "denied",
"reason": reason,
}),
Self::Failure { error } => serde_json::json!({
"status": "failure",
"error": error,
}),
Self::Cancelled => serde_json::json!({
"status": "cancelled",
}),
};
value.to_string()
}
}
impl Display for RunAgentsResult {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
+91 -1
View File
@@ -1,4 +1,7 @@
use super::{StartAgentResult, StartAgentVersion};
use super::{
AIAgentActionResultType, RunAgentsAgentOutcome, RunAgentsAgentOutcomeKind,
RunAgentsLaunchedExecutionMode, RunAgentsResult, StartAgentResult, StartAgentVersion,
};
#[test]
fn deserializes_legacy_start_agent_success_without_version_as_v1() {
@@ -42,3 +45,90 @@ fn deserializes_legacy_start_agent_cancelled_without_version_as_v1() {
}
);
}
#[test]
fn run_agents_model_content_contains_resolved_config_and_agent_outcomes() {
let result = AIAgentActionResultType::RunAgents(RunAgentsResult::Launched {
model_id: "resolved-model".to_string(),
harness_type: "oz".to_string(),
execution_mode: RunAgentsLaunchedExecutionMode::Remote {
environment_id: "env-1".to_string(),
worker_host: "worker.example".to_string(),
computer_use_enabled: true,
},
agents: vec![
RunAgentsAgentOutcome {
name: "research".to_string(),
kind: RunAgentsAgentOutcomeKind::Launched {
agent_id: "agent-1".to_string(),
},
},
RunAgentsAgentOutcome {
name: "tests".to_string(),
kind: RunAgentsAgentOutcomeKind::Failed {
error: "capacity exhausted".to_string(),
},
},
],
});
let content: serde_json::Value = serde_json::from_str(&result.model_content())
.expect("run-agents model content should be valid JSON");
assert_eq!(
content,
serde_json::json!({
"status": "launched",
"model_id": "resolved-model",
"harness_type": "oz",
"execution_mode": {
"type": "remote",
"environment_id": "env-1",
"worker_host": "worker.example",
"computer_use_enabled": true,
},
"agents": [
{
"name": "research",
"status": "launched",
"agent_id": "agent-1",
},
{
"name": "tests",
"status": "failed",
"error": "capacity exhausted",
},
],
})
);
assert_eq!(
result.to_string(),
"Orchestrate launched (1/2 agents started)"
);
}
#[test]
fn run_agents_model_content_serializes_terminal_non_launch_outcomes() {
for (result, expected) in [
(
RunAgentsResult::Denied {
reason: "not approved".to_string(),
},
serde_json::json!({ "status": "denied", "reason": "not approved" }),
),
(
RunAgentsResult::Failure {
error: "invalid request".to_string(),
},
serde_json::json!({ "status": "failure", "error": "invalid request" }),
),
(
RunAgentsResult::Cancelled,
serde_json::json!({ "status": "cancelled" }),
),
] {
let result = AIAgentActionResultType::RunAgents(result);
let content: serde_json::Value = serde_json::from_str(&result.model_content())
.expect("run-agents model content should be valid JSON");
assert_eq!(content, expected);
}
}