Skip to content

Commit

Permalink
feat(agents): Add pub accessor for agent context
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv committed Jan 19, 2025
1 parent e4e4468 commit 07ad3ce
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions swiftide-agents/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,15 @@ impl Agent {
Ok(())
}

/// Tell the agent to stop. It will finish it's current looop and then stop.

Check warning on line 478 in swiftide-agents/src/agent.rs

View workflow job for this annotation

GitHub Actions / Lint

"looop" should be "loop".

Check failure on line 478 in swiftide-agents/src/agent.rs

View workflow job for this annotation

GitHub Actions / Lint

`looop` should be `loop`
pub fn stop(&mut self) {
self.state = state::State::Stopped;
}

/// Access the agent's context
pub fn context(&self) -> &dyn AgentContext {
&self.context
}
}

#[cfg(test)]
Expand Down Expand Up @@ -523,6 +529,8 @@ mod tests {
assert_eq!(agent.tools.len(), 2);
assert!(agent.find_tool_by_name("mock_tool").is_some());
assert!(agent.find_tool_by_name("stop").is_some());

assert!(agent.context().history().await.is_empty());
}

#[test_log::test(tokio::test)]
Expand Down

0 comments on commit 07ad3ce

Please sign in to comment.