Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] Runs agent as an async spawned task #328

Draft
wants to merge 1 commit into
base: v1.0
Choose a base branch
from

Conversation

jsibbison-square
Copy link
Collaborator

We have a problem with the existing cli in that if the user presses Ctrl+c it will interrupt the agents action (with a tool result error) but then leave the agent running to respond to the error.

The user is trying to interrupt the process.

This PR is a POC that shows if we run the agent as a spawned async task then when the ctrl+c is pressed it is handled by the cli code (tokio::signal::ctrl_c) rather than the agent. This signals the spawned agent to break via a channel which results in the underlying process being terminated without further interaction. This is obviously a pretty ungraceful shutdown for the agent but required to stop processing immediately.

How do we know it actually stops any underlying tools under the hood? I had it run a shell command loop that wrote a line for every second. When interrupting I was able to assert that the shell command stopped writing rather than completing the loop.

The downside is that we spinning up the agent from scratch for each user message. This can be avoided but requires making the agent and its attributes cloneable so they can survive the async move. An alternative would be to explore if we can push this async interaction deeper into the agent. At that stage we should probably consider having the cli interact with the goose-server rather than the agent directly and just solve that interaction.

@jsibbison-square jsibbison-square marked this pull request as draft November 26, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant