Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(agent): unquote quoted scalar values in skill and memory frontmatter

Haozhe Wud0c4f31e757c
diff --git a/agent/src/agent/frontmatter.py b/agent/src/agent/frontmatter.py
index 128561d4b..e302eeb5f 100644
--- a/agent/src/agent/frontmatter.py
+++ b/agent/src/agent/frontmatter.py
@@ -16,7 +16,7 @@ _FRONTMATTER_RE = re.compile(
def parse_frontmatter(text: str) -> tuple[Dict[str, Any], str]:
"""Parse YAML-like frontmatter and body from a markdown file.
- Supports string, list (``[a, b]``), and boolean values.
+ Supports string, quoted string, list (``[a, b]``), and boolean values.
Args:
text: Markdown text with optional ``---`` delimited frontmatter.
@@ -36,7 +36,9 @@ def parse_frontmatter(text: str) -> tuple[Dict[str, Any], str]:
key, value = line.split(":", 1)
key = key.strip()
value = value.strip()
- if value.startswith("[") and value.endswith("]"):
+ if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'":
+ meta[key] = value[1:-1]
+ elif value.startswith("[") and value.endswith("]"):
items = [item.strip().strip("'\"") for item in value[1:-1].split(",")]
meta[key] = [i for i in items if i]
elif value.lower() in ("true", "false"):
diff --git a/agent/tests/test_skills.py b/agent/tests/test_skills.py
index 5cc719900..f88b5b7b8 100644
--- a/agent/tests/test_skills.py
+++ b/agent/tests/test_skills.py
@@ -43,6 +43,11 @@ class TestParseFrontmatter:
meta, _ = _parse_frontmatter(text)
assert meta["tags"] == []
+ def test_quoted_scalars_lose_their_quotes_and_stay_strings(self) -> None:
+ text = "---\nname: 'foo'\ndescription: \"Use when: a, b\"\nflag: \"true\"\nraw: \"[a]\"\n---\nBody"
+ meta, _ = _parse_frontmatter(text)
+ assert meta == {"name": "foo", "description": "Use when: a, b", "flag": "true", "raw": "[a]"}
+
def test_no_frontmatter(self) -> None:
text = "Just plain text, no frontmatter."
meta, body = _parse_frontmatter(text)