Skip to content

feat(skill): add YAML auto-repair for unquoted colons in frontmatter#1443

Open
hexly666 wants to merge 4 commits into
agentscope-ai:mainfrom
hexly666:feat/yaml-auto-repair
Open

feat(skill): add YAML auto-repair for unquoted colons in frontmatter#1443
hexly666 wants to merge 4 commits into
agentscope-ai:mainfrom
hexly666:feat/yaml-auto-repair

Conversation

@hexly666
Copy link
Copy Markdown

@hexly666 hexly666 commented May 19, 2026

Enhance MarkdownSkillParser to automatically repair YAML frontmatter containing unquoted colon-space patterns in scalar values. When SnakeYAML fails to parse, the parser now attempts to quote problematic values before giving up.

Closes #1442

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.12, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]

Description

When parsing YAML frontmatter in Markdown skill files, SnakeYAML fails to parse scalar values that contain unquoted colon-space patterns (: ). For example:

description: test, node: cannot find EDI partner

YAML interprets the : after node as a new key-value separator, causing a parsing error. This results in the entire frontmatter being rejected and metadata being lost.

I added an auto-repair mechanism to the MarkdownSkillParser that activates when SnakeYAML fails to parse the frontmatter:

Detection: On parse failure, the parser examines the raw YAML content for lines containing unquoted : patterns within scalar values.

Repair: It wraps problematic values in double quotes, escaping internal quotes and backslashes:

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

Enhance MarkdownSkillParser to automatically repair YAML frontmatter
containing unquoted colon-space patterns in scalar values. When SnakeYAML
fails to parse, the parser now attempts to quote problematic values
before giving up.

Refs agentscope-ai#1442
@hexly666 hexly666 requested a review from a team May 19, 2026 14:35
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


helm30 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 75.51020% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...gentscope/core/skill/util/MarkdownSkillParser.java 75.51% 3 Missing and 9 partials ⚠️

📢 Thoughts on this report? Let us know!

helm30 added 3 commits May 19, 2026 23:56
…repair

Add 14 new test cases to cover missing branches in the YAML auto-repair
logic introduced in the previous commit:

- testKeyWithSpaceNotRepaired: covers repair skipping keys with spaces
- testColonAtLineStart: covers firstColon == 0 branch
- testColonAtLineEnd: covers line.length() == firstColon + 1 branch
- testColonNoSpaceAfter: covers URL values without ': ' pattern
- testEmptyValueNoQuoting: covers empty trimmed value in needsQuoting
- testColonsWithoutSpaces: covers colons without space after
- testMultipleLinesMixedQuoting: covers mixed quoted/unquoted values
- testRepairWithDoubleQuotes: covers double quote escaping during repair
- testRepairWithBackslash: covers backslash escaping during repair
- testRepairStillFailsAfterQuoting: covers repair retry failure path
- testYamlParsesToNull: covers loaded == null branch
- testNonMapTopLevelYaml: covers non-map top-level YAML branch

Tests: 58 total (44 + 14 new), all passing.
Refs agentscope-ai#1442
Copy link
Copy Markdown
Author

@hexly666 hexly666 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

[Bug]: Improve skill YAML frontmatter parsing tolerance for unquoted colons in scalar values

2 participants