agentscope-ai / agentscope-ai/agentscope-java
[Feature]: Support strict mode consistently across all tool definition paths
- 主要语言
- Java
- 星标
- 5.6k
- 派生
- 1.3k
- 平均合并
- 4 天 12 小时
- 30 天内合并 PR
- 77
描述
**Is your feature request related to a problem? Please describe.**
`ToolSchema` already exposes a `strict` field, and the OpenAI formatter also has support for propagating `strict` into the final tool/function definition.
However, strict mode is not consistently preserved across all tool definition and registration paths.
For example, when building a tool schema manually, it is possible to set strict mode explicitly:
~~~java
ToolSchema.builder()
.name(...)
.description(...)
.parameters(parameters)
.strict(true)
.build();
~~~
But in practice, this support is not consistently available through all higher-level tool registration flows.
In particular, when registering a schema through `Toolkit#registerSchema`, the provided `ToolSchema` appears to be wrapped into a `SchemaOnlyTool`, and during that process the original `ToolSchema` is not preserved as-is. As a result, the `strict` flag is effectively lost and does not reach the final tool definition sent to the model API.
This creates an inconsistency:
- `ToolSchema` already exposes `strict`
- the formatter layer already supports `strict`
- but some framework registration paths do not preserve or propagate it
This makes it difficult to rely on strict mode as a first-class capability.
**Describe the solution you'd like**
I’d like strict mode to be supported consistently across all tool schema definition and registration paths, including:
1. Manual `ToolSchema.builder(...)`
2. `Toolkit#registerSchema(...)`
3. `@Tool` annotation-based tools
4. `AgentTool` interface / implementation-based tools
5. Any other framework-provided path that eventually produces a `ToolSchema` or tool definition for model APIs
Concretely, it would be helpful if:
- `ToolSchema.strict` is always preserved when a tool is wrapped, converted, or re-registered
- higher-level APIs such as `@Tool` and `AgentTool` expose a way to configure strict mode
- all internal tool conversion paths propagate the strict flag into the final model API payload when the provider supports it
**Describe alternatives you've considered**
The current workaround is to avoid some higher-level registration paths and manually control tool schema construction as much as possible.
However, this has several downsides:
- it reduces the value of the higher-level abstractions
- it makes strict mode behavior depend on which registration path is used
- it is not obvious to users that `strict` may be silently lost during registration or wrapping
- it makes the API less consistent and less predictable
Another workaround would be to customize framework internals, but that is much heavier than having first-class support.
**Additional context**
According to the [OpenAI function calling documentation](https://developers.openai.com/api/docs/guides/function-calling), `strict: true` improves schema adherence for tool/function calling and is recommended when developers want reliable structured arguments.
Because of this, strict mode is not just a minor optional flag — it can materially affect tool calling reliability and schema correctness.
It would be great if AgentScope Java could provide a unified strict-mode experience across all tool-definition styles.
贡献指南
评估
这个 Issue 还没有评估数据。