Skip to content

fix(harness): mark optional FilesystemTool params as required=false#2227

Open
wzq-xzwj wants to merge 2 commits into
agentscope-ai:mainfrom
wzq-xzwj:fix/filesystemtool-optional-params
Open

fix(harness): mark optional FilesystemTool params as required=false#2227
wzq-xzwj wants to merge 2 commits into
agentscope-ai:mainfrom
wzq-xzwj:fix/filesystemtool-optional-params

Conversation

@wzq-xzwj

Copy link
Copy Markdown

Summary

Several @ToolParam parameters on FilesystemTool are documented as optional
(their descriptions say "Default: ...", "Optional ...") and the underlying
AbstractFilesystem implementation already handles missing / null / default
values gracefully. However, they are not annotated with required = false.

Because ToolParam.required() defaults to true, these parameters end up in the
generated JSON schema as required, contradicting both their descriptions and
the implementation.

Affected parameters:

Tool Param Description says Was in schema
read_file offset "Default: 0 (from beginning)" required
read_file limit "Default: 0 (all lines)" required
grep_files path dir/file to search required
grep_files glob "Optional file glob filter" required
glob_files path base dir to search from required

Why this matters

Models calling these tools believe they must supply every parameter. In practice
this pushes the model to always pass a glob filter to grep_files (narrowing
results unintentionally) or an explicit offset/limit to read_file, and often
leads models to prefer shell commands over the built-in tools. The mismatch
between the human-readable description ("Optional") and the schema ("required")
is confusing for both models and integrators.

Note: edit_file's replace_all is already correctly annotated with
required = false, which shows the intended pattern — the other optional
parameters were simply missed.

Implementation is already optional-safe

The backing implementation already tolerates missing values, so this is a
schema-only correction with no behavioral risk:

  • LocalFilesystem.grep(...): resolvePath(runtimeContext, path != null ? path : ".")
  • LocalFilesystem.glob(...): handles path == null → falls back to cwd
  • ripgrepSearch / javaSearch: if (includeGlob != null && !includeGlob.isBlank())
  • LocalFilesystem.read(...): int startIdx = Math.max(0, offset), limit > 0 ? ... : all

Change

Add required = false to the five parameters listed above. No logic changes.

Testing

  • Schema generation now marks these parameters as optional.
  • Existing behavior unchanged (implementation already handled absent values).

@CLAassistant

CLAassistant commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

read_file(offset,limit), grep_files(path,glob) and glob_files(path) are
documented as optional and the AbstractFilesystem implementation already
handles null/default values, but they lacked required=false and therefore
appeared as required in the generated tool schema. Align the annotations
with the descriptions and the implementation. Schema-only, no behavior
change. Mirrors the existing edit_file.replace_all annotation.
@wzq-xzwj wzq-xzwj force-pushed the fix/filesystemtool-optional-params branch from a89f2f6 to bd74c43 Compare July 15, 2026 10:35
…potless

The sessionId @ToolParam line exceeded the 100-column AOSP limit enforced by
spotless:check, causing the build to fail on every PR touching this module.
Wrap it as spotless expects. Formatting-only, no behavior change.
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants