Skip to content

fix: writeNoSqlDatabaseContent 对嵌套对象更新缺乏明确的行为说明,导致模型误用 $set 覆盖整个嵌套对象#692

Open
binggg wants to merge 1 commit intomainfrom
automation/attribution-issue-mojxks03-yvtgc5-writenosqldatabasecontent-set
Open

fix: writeNoSqlDatabaseContent 对嵌套对象更新缺乏明确的行为说明,导致模型误用 $set 覆盖整个嵌套对象#692
binggg wants to merge 1 commit intomainfrom
automation/attribution-issue-mojxks03-yvtgc5-writenosqldatabasecontent-set

Conversation

@binggg
Copy link
Copy Markdown
Member

@binggg binggg commented Apr 29, 2026

Attribution issue

  • issueId: issue_mojxks03_yvtgc5
  • category: tool
  • canonicalTitle: writeNoSqlDatabaseContent 对嵌套对象更新缺乏明确的行为说明,导致模型误用 $set 覆盖整个嵌套对象
  • representativeRun: atomic-js-none-update-nosql-nested-object-implicit/2026-04-29T10-44-28-d9o87y

Automation summary

  • root_cause: The writeNoSqlDatabaseContent MCP tool documentation mentioned that nested field updates should use dot notation (e.g., address.city), but it did not provide a concrete example showing the WRONG vs CORRECT approach. When the user's prompt was ambiguous ("把 shipping 更新为 {"city":"guangzhou"}"), the model interpreted it as replacing the entire shipping object rather than just updating the city field within shipping. The documentation lacked explicit guidance on how to interpret such ambiguous user requests.
  • changes: Updated the writeNoSqlDatabaseContent tool description in mcp/src/tools/databaseNoSQL.ts to:
  1. Add a concrete WRONG vs CORRECT example in the main description: "当用户说「把 shipping 更新为 {city: "guangzhou"}」时,如果 shipping 原本是 {city: "beijing", province: "hebei"},正确的做法是 $set: {\"shipping.city\": \"guangzhou\"},错误的做法是 $set: {shipping: {city: \"guangzhou\"}}(会删除 province 字段)"
  2. Add explicit guidance in the update parameter description: "当用户说「把 X 更新为 {Y: Z}」时,应理解为「更新 X.Y 为 Z」,使用点号路径而非替换整个对象"
  3. Add bold warning markers (**⚠️ 嵌套对象局部更新必须使用点号路径**) to highlight the importance of this behavior
  • validation:
  • All 15 databaseNoSQL tests pas

Changed files

  • mcp/src/tools/databaseNoSQL.ts

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcb0dd8904

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.optional()
.describe(
"更新内容(对象或字符串,推荐对象)(update 操作必填)。按 MongoDB 更新语义传入 MgoUpdate:部分更新请使用 `$set`、`$inc`、`$unset`、`$push` 等操作符,例如使用 `$set` 更新 `status`;不要直接传“字段到值的普通对象”,否则可能替换整条文档。更新嵌套字段时必须使用点号路径,例如通过 `$set` 更新 `address.city`;不要把整个 `address` 对象作为 `$set` 的值传入,否则会替换整个 `address` 对象。",
"更新内容(对象或字符串,推荐对象)(update 操作必填)。按 MongoDB 更新语义传入 MgoUpdate:部分更新请使用 `$set`、`$inc`、`$unset`、`$push` 等操作符,例如使用 `$set` 更新 `status`。**⚠️ 嵌套字段更新必须使用点号路径**:`$set: {\"address.city\": \"shenzhen\"}` 只更新 `address.city`,保留其他字段;`$set: {address: {city: \"shenzhen\"}}` 会替换整个 address 对象,删除其他字段。当用户说「把 X 更新为 {Y: Z}」时,应理解为「更新 X.Y 为 Z」,使用点号路径而非替换整个对象。",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit full-object replacement intent

The new instruction in writeNoSqlDatabaseContent overgeneralizes nested updates by saying 把 X 更新为 {Y: Z} should be interpreted as 更新 X.Y 为 Z, which forces dot-notation even when a user explicitly intends to replace the whole nested object (for example, intentionally dropping sibling keys like province). In those cases the tool guidance now steers the model toward partial updates and can silently keep stale fields, producing incorrect persisted data relative to the user’s request.

Useful? React with 👍 / 👎.

@binggg
Copy link
Copy Markdown
Member Author

binggg commented Apr 29, 2026

Attribution post-PR evaluation

  • visibility: internal identifiers, run ids, and private links are intentionally omitted
  • attempt: 1
  • eval_scope: primary_only
  • overall: FAILED
  • summary: at least one planned evaluation case failed
  • updated_at: 2026-04-29T11:15:34.200Z

Cases

  • [FAILED] — primary — evaluation failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant