-
Notifications
You must be signed in to change notification settings - Fork 293
fix: resolve worker tool call errors (browser_evaluate, browser_close, compaction) #475
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2108,12 +2108,17 @@ impl Tool for BrowserCloseTool { | |
| task.abort(); | ||
| } | ||
|
|
||
| if let Some(mut browser) = browser | ||
| && let Err(error) = browser.close().await | ||
| { | ||
| let message = format!("failed to close browser: {error}"); | ||
| tracing::warn!(policy = "close_browser", %message); | ||
| return Err(BrowserError::new(message)); | ||
| if let Some(mut browser) = browser { | ||
| if let Err(error) = browser.close().await { | ||
| // The browser connection may already be dead (e.g. "oneshot canceled" | ||
| // from a dropped WebSocket). That's fine — the browser is effectively | ||
| // closed. Log it but don't fail the tool call. | ||
| tracing::warn!( | ||
| policy = "close_browser", | ||
| %error, | ||
| "browser.close() failed, treating as already closed" | ||
| ); | ||
| } | ||
|
Comment on lines
+2057
to
+2067
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only suppress the known “browser already gone” close errors. This now turns every 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| if !persistent_profile && let Some(dir) = user_data_dir { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: spacedriveapp/spacebot
Length of output: 733
🏁 Script executed:
Repository: spacedriveapp/spacebot
Length of output: 179
Apply ToolResult safeguard to branch compaction as well.
The worker.rs fix (lines 749-770) correctly prevents orphaning
ToolResultblocks when compaction removes precedingToolCallmessages. However, branch.rs has identical compaction logic at line 296 without this safeguard. Since branch.rs enables tools via.tool_server_handle(self.tool_server.clone())at line 116, branches can also accumulate tool interactions and will hit the same Anthropic API rejection:"unexpected tool_use_id found in tool_result blocks".Apply the same while-loop boundary advancement from worker.rs (lines 756–770) to branch.rs's
compact_history()function to prevent runtime failures when branches compact their history.🤖 Prompt for AI Agents