Skip to content

fix(schema): align file_write mode default with Python implementation#91

Open
shaun0927 wants to merge 1 commit intolsdefine:mainfrom
shaun0927:fix/schema-filewrite-default
Open

fix(schema): align file_write mode default with Python implementation#91
shaun0927 wants to merge 1 commit intolsdefine:mainfrom
shaun0927:fix/schema-filewrite-default

Conversation

@shaun0927
Copy link
Copy Markdown
Contributor

Problem

assets/tools_schema.json (used for English-locale agents since the i18n
auto-detect in 7cadbd7) declares file_write.mode with a default of \"append\":

"mode": {"type": "string", "enum": ["overwrite", "append", "prepend"],
         "description": "Write mode", "default": "append"}

But assets/tools_schema_cn.json and the Python handler both default to
\"overwrite\":

// tools_schema_cn.json line 35
"default": "overwrite"
# ga.py:369
mode = args.get("mode", "overwrite")

When the LLM trusts the English schema's documented default and omits
mode, the Python handler silently overwrites the file. Same call,
opposite behavior depending on which locale loaded the schema.

Fix

Change the EN schema default to \"overwrite\" so all three sources of
truth — EN schema, CN schema, Python handler — agree:

-      "mode": {"type": "string", "enum": ["overwrite", "append", "prepend"], "description": "Write mode", "default": "append"}}}
+      "mode": {"type": "string", "enum": ["overwrite", "append", "prepend"], "description": "Write mode", "default": "overwrite"}}}

The reverse direction (changing CN + ga.py to \"append\") was rejected
because:

  • The Python handler has shipped overwrite since the introduction of
    the parameter, so overwrite is the de-facto behavior callers depend on.
  • file_write in CONTRIBUTING-style usage (huge edits with the
    <file_content> block before the call) targets a fresh write, not an
    append; flipping the default to append would silently change semantics
    for every existing skill that omits mode.

Verification

$ python -c "import json; json.load(open('assets/tools_schema.json'))"  # parses
$ diff <(grep -A0 '"default"' assets/tools_schema.json) <(grep -A0 '"default"' assets/tools_schema_cn.json)
# defaults match for file_write.mode

Net line count: 0.

assets/tools_schema.json declares file_write.mode default as 'append',
but assets/tools_schema_cn.json and ga.py both default to 'overwrite':

    # ga.py:369
    mode = args.get("mode", "overwrite")

Since the i18n switch in 7cadbd7 loads the English schema for en_*
locales, an LLM that trusts the schema default and omits the mode
parameter will silently overwrite instead of append. Align the English
schema with the Chinese schema and the Python handler so all three
agree on 'overwrite'.
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.

1 participant