Skip to content

Commit

Permalink
feat(agents): Add pub accessor for agent context (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv authored Jan 20, 2025
1 parent 274d9d4 commit 70181d9
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 @@ -476,9 +476,15 @@ impl Agent {
Ok(())
}

/// Tell the agent to stop. It will finish it's current loop and then stop.
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 @@ -524,6 +530,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 70181d9

Please sign in to comment.