Skip to content

fix: path is duplicated on tool calls causing them to fail (#4658)#4859

Merged
michaelneale merged 2 commits intoblock:mainfrom
demetrio108:fix-path-overlapping-4658
Sep 29, 2025
Merged

fix: path is duplicated on tool calls causing them to fail (#4658)#4859
michaelneale merged 2 commits intoblock:mainfrom
demetrio108:fix-path-overlapping-4658

Conversation

@demetrio108
Copy link
Copy Markdown
Contributor

@demetrio108 demetrio108 commented Sep 26, 2025

There is an issue opened

#4658
Path is duplicated on tool calls causing them to fail

What happens is when LLM calls text_editor in diff mode it passes
path: /a/b/c/base/src/file.go
in diff there is path: base/src/file.go

Inside mpatch they are merged and produce
path: /a/b/c/base/src/base/src/file.go

This path doesn't exist and tool fails.

Maybe it's an error from LLM side, that it calls tool incorrectly. But I tried several and it's a common issue.

So I propose to remove overlapping part from base_dir before sending to mpatch. I tested fix in Linux and it works good.

@michaelneale
Copy link
Copy Markdown
Collaborator

thanks @demetrio108 cc @tlongwell-block wonder if this was impacting well formed diff problem you mentioned?

@michaelneale
Copy link
Copy Markdown
Collaborator

@demetrio108 will need to run ./scripts/clippy-lint.sh (or ask goose to sort it out!)

let adjusted_components = base_components[..base_components.len() - max_k].to_vec();
PathBuf::from_iter(adjusted_components)
} else {
base_dir.to_path_buf()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should this change the type too? if so adjust the name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean Path to PathBuf? It's impossible to return Path. I'm not sure which name change you mean


// Apply patch with fuzzy matching (70% similarity threshold)
let success = apply_patch(patch, base_dir, false, 0.7).map_err(|e| match e {
let success = apply_patch(patch, &adjusted_base_dir, false, 0.7).map_err(|e| match e {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am not sure I have enough context here, but is this right? should we use the adjusted base here or should we have adjusted the patch file_path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Inside the patch there is valid path relative to current goose working directory. Base directory is passed wrong by LLM

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ah, thanks, that's helpful

Signed-off-by: demetrio108 <[email protected]>
@demetrio108
Copy link
Copy Markdown
Contributor Author

demetrio108 commented Sep 29, 2025

@demetrio108 will need to run ./scripts/clippy-lint.sh (or ask goose to sort it

@michaelneale done

Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

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

fix the n2 and let's merge!

@demetrio108
Copy link
Copy Markdown
Contributor Author

@DOsinga I don't understand, what n2?

@michaelneale
Copy link
Copy Markdown
Collaborator

@demetrio108 I think @DOsinga means the O n squared thing here #4859 (comment) - which looks like you changed some code for?

@michaelneale michaelneale merged commit 5c9be9a into block:main Sep 29, 2025
10 checks passed
@demetrio108
Copy link
Copy Markdown
Contributor Author

demetrio108 commented Sep 29, 2025

image

There's KMP algorithm with O(m+n) complexity, but it's an overkill in current case and it's not elegant

zanesq added a commit that referenced this pull request Sep 30, 2025
…-unification

* 'main' of github.com:block/goose: (24 commits)
  feat(cli): add `path` & `limit` to `session list` command (#4878)
  Allow better concurrent access (#4896)
  fix: Windows prompt cursor positioning issue with ANSI escape sequences (#4464)
  Fix: LiteLLM API key field not showing in UI configuration (#4105)
  fix: path is duplicated on tool calls causing them to fail (#4658) (#4859)
  add new prompt to get all available tutorials (#4802)
  Add filtering for agentVisible: false messages on streaming providers (#4847)
  alexhancock/mcp-crate-cleanup (#4885)
  docs: rename sub-recipe to subrecipe (#4886)
  docs: new multi-model section with autopilot topic (#4864)
  make agent manager singleton (#4880)
  Cli web auth token (#4456)
  fix(token_counter): fix panic with GitHub Copilot (#4632)
  Revert "Internal MCP Crate Cleanup (#4800)" (#4883)
  remove 2 redundant comments and one that lies (#4866)
  Internal MCP Crate Cleanup (#4800)
  Fix #4612: Return non-zero exit code when CLI session ends with error (#4621)
  Dead code cleanup (#4873)
  fix: restoring test data and correcting name (#4875)
  Add .goosehints file to enforce lowercase branding in documentation (#4870)
  ...
wpfleger96 added a commit to wpfleger96/goose that referenced this pull request Oct 1, 2025
* main: (206 commits)
  Tiny: fix github casing  (block#4903)
  remove anyOf from create_task tool (block#4897)
  chore(deps): bump tracing-subscriber from 0.3.19 to 0.3.20 (block#4442)
  fix optional recipe schema zod validation (block#4900)
  Added CMD+T keyboard shortcut that takes you to the Home tab (block#4541)
  feat(cli): add `path` & `limit` to `session list` command (block#4878)
  Allow better concurrent access (block#4896)
  fix: Windows prompt cursor positioning issue with ANSI escape sequences (block#4464)
  Fix: LiteLLM API key field not showing in UI configuration (block#4105)
  fix: path is duplicated on tool calls causing them to fail (block#4658) (block#4859)
  add new prompt to get all available tutorials (block#4802)
  Add filtering for agentVisible: false messages on streaming providers (block#4847)
  alexhancock/mcp-crate-cleanup (block#4885)
  docs: rename sub-recipe to subrecipe (block#4886)
  docs: new multi-model section with autopilot topic (block#4864)
  make agent manager singleton (block#4880)
  Cli web auth token (block#4456)
  fix(token_counter): fix panic with GitHub Copilot (block#4632)
  Revert "Internal MCP Crate Cleanup (block#4800)" (block#4883)
  remove 2 redundant comments and one that lies (block#4866)
  ...
HikaruEgashira pushed a commit to HikaruEgashira/goose that referenced this pull request Oct 3, 2025
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.

4 participants