agentscope-ai / agentscope-ai/agentscope-java

[Bug]: edit_file hangs indefinitely when old_string is empty

Open
#2,446 3 comments 0 reactions 0 assignees View on GitHub
area/core/agent bug
Dominant language
Java
Stars
5.6k
Forks
1.3k
Avg merge
4d 12h
Merged PRs (30d)
77

Description

Calling edit_file with an empty old_string never returns.

Reproduction:

filesystem.edit(runtimeContext, "/notes.md", "", "replacement", false);

The loop in FilesystemUtils.countOccurrences() calls indexOf("", idx).
Because the empty string has length 0, idx never advances and the loop runs forever.

Expected behavior:
Return a normal validation error such as:
"old_string must not be empty"

Suggested fix:
Validate oldString before countOccurrences() and add a unit test with a timeout assertion.

This should be a small backward-compatible fix with no API change.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.