refactor config
This commit is contained in:
parent
d90052cfd1
commit
04ece6afb1
5 changed files with 127 additions and 74 deletions
17
src/agent.rs
17
src/agent.rs
|
|
@ -66,19 +66,14 @@ impl Agent {
|
|||
self.logs.push('\n');
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) -> Result<(String, Option<String>), Box<dyn std::error::Error>> {
|
||||
pub async fn run(
|
||||
&mut self,
|
||||
config: &crate::config::Config,
|
||||
) -> Result<(String, Option<String>), Box<dyn std::error::Error>> {
|
||||
let mut finished = false;
|
||||
let start_time = Instant::now();
|
||||
let max_duration_secs = std::env::var("AGENT_MAX_DURATION_SECS")
|
||||
.ok()
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(120);
|
||||
let max_duration = Duration::from_secs(max_duration_secs);
|
||||
|
||||
let max_turns = std::env::var("AGENT_MAX_TURNS")
|
||||
.ok()
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(20);
|
||||
let max_duration = Duration::from_secs(config.agent_max_duration_secs);
|
||||
let max_turns = config.agent_max_turns;
|
||||
let mut turns = 0;
|
||||
|
||||
while !finished {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue