From f36b57914c730b2d7549c2775a3cc1e14bbc35f8 Mon Sep 17 00:00:00 2001 From: skcd Date: Wed, 15 Jan 2025 18:57:26 +0000 Subject: [PATCH] [sidecar] make agent bin work similar to swe bench mcts --- sidecar/src/bin/agent_bin.rs | 77 +++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/sidecar/src/bin/agent_bin.rs b/sidecar/src/bin/agent_bin.rs index a0a99656b..a510fb9eb 100644 --- a/sidecar/src/bin/agent_bin.rs +++ b/sidecar/src/bin/agent_bin.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{path::PathBuf, sync::Arc}; /// This contains the binary responsible for running the agents as a farm /// Dead simple where the inputs are the input to the git repository containing the input @@ -34,39 +34,91 @@ pub async fn check_session_storage_path(config: Arc, session_id: .to_owned() } +/// Define the command-line arguments #[derive(Parser, Debug)] #[command( author = "skcd", - version = "0.1", - about = "Agent bin to point to a repo and run it (assumes an editor is running somewhere)" + version = "1.0", + about = "Agent binary sidecar runner" )] -struct AgentParameters { +struct CliArgs { + /// Git directory name #[arg(long)] timeout: usize, + /// Endpoint URL #[arg(long)] editor_url: String, + /// Timeout in seconds #[arg(long)] + input: PathBuf, + + /// Anthropic api key + #[arg(long, default_value = None)] anthropic_api_key: String, + /// OPen Router api key + #[arg(long, default_value = None)] + openrouter_api_key: Option, + + /// The run id for the current run #[arg(long)] run_id: String, #[arg(long)] - log_directory: String, + repo_name: String, + /// Directory to dump all the logs into #[arg(long)] + log_directory: String, + + /// Use json mode strictly + #[arg(long, default_value = "true")] + json_mode: bool, + + /// Use midwit mode (aka sonnet3.5 with tool) + #[arg(long, default_value = "true")] + midwit_mode: bool, + + /// Run in single trajectory but a lot of them + #[arg(long, default_value = None)] + single_traj_search: Option, + + /// Maximum depth for the search tree + #[arg(long, default_value = "30")] + max_depth: u32, +} + +/// Define the SWEbenchInstance struct for serialization +#[derive(Debug, serde::Serialize, serde::Deserialize)] +struct SWEbenchInstance { + repo: String, + instance_id: String, + base_commit: String, + patch: String, + test_patch: String, problem_statement: String, + hints_text: String, + created_at: String, + version: String, + #[serde(rename = "FAIL_TO_PASS")] + fail_to_pass: String, + #[serde(rename = "PASS_TO_PASS")] + pass_to_pass: String, + environment_setup_commit: String, +} - #[arg(long)] - working_directory: String, +#[derive(Debug, serde::Serialize, serde::Deserialize)] +struct InputParts { + git_drname: String, + instance: SWEbenchInstance, } #[tokio::main] async fn main() -> Result<(), Box> { println!("agent::start"); - let args = AgentParameters::parse(); + let args = CliArgs::parse(); let mut configuration = Configuration::default(); // we apply the edits directly over here @@ -101,9 +153,14 @@ async fn main() -> Result<(), Box> { let session_service = application.session_service.clone(); + let input_path = args.input; + let input_content = tokio::fs::read(input_path).await.expect("path content"); + let input_parts: InputParts = + serde_json::from_slice(&input_content).expect("Parse the serde json"); + let cloned_session_id = args.run_id.to_string(); - let user_message = args.problem_statement.clone(); - let cloned_working_directory = args.working_directory.clone(); + let user_message = input_parts.instance.problem_statement.clone(); + let cloned_working_directory = input_parts.git_drname.to_owned(); let tool_box = application.tool_box.clone(); let llm_broker = application.llm_broker.clone();