agentscope-ai / agentscope-ai/agentscope
[Bug]: AskUser accepts duplicate questions and option labels
- Lenguaje dominante
- Python
- Estrellas
- 31.6k
- Forks
- 3.5k
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 103
Descripción
### Prerequisites
- [x] I have searched the existing [issues](https://github.com/agentscope-ai/agentscope/issues) and [discussions](https://github.com/agentscope-ai/agentscope/discussions), and this is not a duplicate.
- [x] This is a bug, not a usage question. (For questions, please use [Discussions](https://github.com/agentscope-ai/agentscope/discussions/new?category=general) instead.)
### Background / Description
`AskUser` documents that question texts must be unique across a batch and option labels must be unique within each question. It also documents that option previews are supported only for single-select questions.
However, both `AskUserParams.model_validate()` and the exported `AskUser.input_schema` accept duplicate question texts, duplicate option labels within one question, and a non-null preview when `multi_select=True`.
This makes answers ambiguous because `AskUserAnswer.question` correlates an answer using the question text verbatim, while selected choices are represented by their labels.
Expected behavior: invalid or ambiguous question batches should be rejected by the same JSON Schema validation path used for model-generated tool calls.
Actual behavior: the payload is accepted without a validation error.
## 中文说明
`AskUser` 要求同一批次中的问题文本唯一、每个问题内的选项标签唯一,并说明 `preview` 仅支持单选问题。但 Pydantic 和实际用于工具输入校验的 JSON Schema 都会接受这些非法组合。由于答案依靠问题原文和选项标签进行关联,重复值会导致结果无法准确对应。
### Error Messages
```shell
No exception is raised. The reproduction prints:
schema accepted invalid AskUser payload
```
### Steps to Reproduce
```python
import jsonschema
from agentscope.tool import AskUser, AskUserParams
payload = {
"questions": [
{
"question": "Same?",
"header": "A",
"options": [
{"label": "Yes", "description": "first"},
{"label": "Yes", "description": "duplicate"},
],
},
{
"question": "Same?",
"header": "B",
"options": [
{"label": "One", "description": "one", "preview": "x"},
{"label": "Two", "description": "two"},
],
"multi_select": True,
},
],
}
AskUserParams.model_validate(payload)
jsonschema.validate(payload, AskUser.input_schema)
print("schema accepted invalid AskUser payload")
```
Run the script and observe that neither validation call raises.
中文:运行以上脚本,可以看到两条校验路径都没有拒绝非法输入。
### Environment
- AgentScope Version: 2.0.8 (`main` at `0fe41c07`)
- Python Version: 3.12.14
- OS: macOS 26.6.2 arm64
Guía de contribución
Línea de trabajo
Inspect where AskUser and AskUserParams are defined and where AskUser.input_schema is built, alongside the AskUserParams.model_validate flow. Re-run the provided Python reproduction payload against both validation calls to reproduce the current acceptance of duplicates. Then enforce uniqueness of question text and option labels, and reject preview on multi_select in the same validation path. Done means both AskUserParams.model_validate() and jsonschema.validate() now fail these cases.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 74/100