Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/provider/sources/system_one_decision_source.py" line_range="155-157" />
<code_context>
}
- else:
+ elif isinstance(question, DecisionBooleanQuestion):
+ if not isinstance(question.criteria, Mapping) or set(
+ question.criteria
+ ) != {"true", "false"}:
+ raise ValueError(
+ f"question {head} field `criteria` must be an object with `true`/`false` keys"
</code_context>
<issue_to_address>
**Invalid criteria reach System One**
When a boolean criteria mapping has exactly the `true` and `false` keys but at least one value is not a string, `ask()` checks only the keys, then copies the values into the JSON payload. System One receives values that violate the string-description contract and rejects the request instead of returning a decision or a local validation error.
Validate that both criteria values are strings before copying them into the payload.
</issue_to_address>
### Comment 2
<location path="astrbot/core/provider/sources/system_one_decision_source.py" line_range="167" />
<code_context>
+ "criteria": dict(question.criteria),
}
+ else:
+ raise TypeError(
+ f"question {head} type must be one of the following: DecisionBooleanQuestion, DecisionChoiceQuestion, DecisionScoreQuestion"
+ )
</code_context>
<issue_to_address>
**Unsupported questions raise the wrong exception**
When a caller passes an unsupported question object without an `instructions` attribute, `ask()` accesses `question.instructions.strip()` before reaching the fallback type check, so it raises `AttributeError` instead of `TypeError`; callers handling unsupported types by catching `TypeError` miss the failure.
Check that the question has a supported type before accessing its instructions.
</issue_to_address>Linked issues
#10920 [Bug] 决策模型协议 SystemOne 的 noul 类型请求未兼容标准格式 · 1 of 1 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Include criteria with true and false keys in System One noul questions. |
✅ Met | Boolean questions default to empty true and false descriptions, and the System One request forwards both keys. |
Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: astrbot/core/provider/sources/system_one_decision_source.py:157, astrbot/core/provider/sources/system_one_decision_source.py:167
Soulter
reviewed
Nov 1, 2026
Contributor
There was a problem hiding this comment.
Linked issues
#10920 [Bug] 决策模型协议 SystemOne 的 noul 类型请求未兼容标准格式 · 0 of 1 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | noul 类型 Questions 添加 criteria 的 true/false 字段,以兼容 SystemOne 接口 | 🟡 Partly met | 显式传入布尔 criteria 或启用配置后会携带 true/false 字段,但该配置默认关闭,未配置的请求仍会省略 criteria。 |
Member
|
你好,我觉得加单独的配置项也不是一个很好的解决方案。我觉得保留可选的入参,将选择权留给调用方(比如插件)即可,不需要单独的配置项。 这个配置不是用户关心的,因此不需要显式给用户看 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复了 issue #10920
Modifications / 改动点
"criteria": {"true": "", "false": ""},默认关闭,关闭时不传入 criteria。用于兼容某些 SystemOne 协议接口必须要传 true 和 false 字段的情况。Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
📚 I checked the affected WebUI instructions and screenshots in
docs/zhanddocs/enagainst the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog./ 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新
docs/zh和docs/en的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Resolves #10920
Summary by Sourcery
Fix System One compatibility for boolean decision questions by providing and validating their required criteria fields.
Bug Fixes:
trueandfalsecriteria fields when sent through the System One protocol.Documentation:
Tests: