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

feat: support goose mode in UI #1434

Merged
merged 9 commits into from
Mar 1, 2025
Merged

feat: support goose mode in UI #1434

merged 9 commits into from
Mar 1, 2025

Conversation

yingjiehe-xyz
Copy link
Collaborator

@yingjiehe-xyz yingjiehe-xyz commented Feb 28, 2025

Right now, the approval workflow is like in the agent reply, when we have some tool calls, we will hold here before execution and have a recv queue waiting for confirmation, in CLI, it doesn't have any issue. In UI, I had two options to implement the approval flow:

  1. have a separate API for confirmation only
  2. send a confirmation message via reply endpoint,

However, I found that we have the lock on reply API until the streaming is done, so both of options don't work in this case, because previous session is not done, waiting for confirmation to finish the stream, but the confirmation message is waiting for the existing stream to release the lock, then you see, deadlock....
The tweak I did is to use read write lock in AppState, I did a quick check in the repo, looks like in reply api, we don't have to use the write lock

Test:
image

Config
image

@yingjiehe-xyz yingjiehe-xyz marked this pull request as ready for review February 28, 2025 17:36
@@ -274,7 +274,8 @@ impl Agent for TruncateAgent {

// Wait for confirmation response through the channel
let mut rx = self.confirmation_rx.lock().await;
if let Some((req_id, confirmed)) = rx.recv().await {
// Loop the recv until we have a matched req_id due to potential duplicate messages.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you help me understand why we need this? what are examples of duplicate messages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, right now, the Allow tool button is not disabled after clicking, I am trying to make it happen in following PR, so the user may click allow button multiple times or click previous allow tool button

@@ -134,7 +134,7 @@ async fn create_agent(

let new_agent = AgentFactory::create(&version, provider).expect("Failed to create agent");

let mut agent = state.agent.lock().await;
let mut agent = state.agent.write().await;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would we be able to determine whether to use 'read' vs 'write' lock here for instance?

Nothing is done with the agent past line 137, so curious how to determine that agent needed a write lock instead of read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use write lock by default to avoid any missed errors. Also in some cases, like update the system prompt or add extension, we should use the write lock

Copy link
Collaborator

@wendytang wendytang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have some general questions, but RwLock seems like a good idea!

@yingjiehe-xyz yingjiehe-xyz merged commit f7f2540 into main Mar 1, 2025
6 checks passed
@yingjiehe-xyz yingjiehe-xyz deleted the yingjiehe/goosemode branch March 1, 2025 01:00
@yingjiehe-xyz yingjiehe-xyz linked an issue Mar 3, 2025 that may be closed by this pull request
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.

Goose's UI doesn't allow you to change Goose's permissions
3 participants