Skip to content

fix(skills): make a user's correction to a skill actually land - #3937

Merged
kovtcharov-amd merged 5 commits into
mainfrom
kalin/skill-corrections-land
Sep 25, 2026
Merged

kovtcharov-amd merged 5 commits into
mainfrom
kalin/skill-corrections-land

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Telling GAIA how you want a skill's output did nothing, and it said otherwise. A colleague hit this on the transcription skill: he wanted meeting briefs formatted his way, and the agent replied that the skill "has been updated on your machine" — having called no tool and stored no change. The adaptive-skills write path (#2674) shipped, but four defects sat between a user saying "format it like this" and anything happening. All four were found by driving the flagship against a local Lemonade, and the loop now works end to end: the correction lands as one reviewable delta, gaia skill deltas --diff shows it, and one command reverts it.

Test plan

  • pytest tests/unit/test_adaptive_skills.py tests/unit/test_tool_loader_selection.py hub/agents/gaia/python/tests/test_skill_learning_reachability.py — 116 pass, incl. 8 new fence cases and a guard that every shipped skill's parsed sections match the headings a reader sees
  • gaia skill audit hub/skills/transcribe-meeting — ALLOW, no findings
  • End to end, with transcribe-meeting loaded: say "I always want meeting briefs to start with an Action Items section grouped by owner" → one replace_snippet delta on brief-shape, then gaia skill deltas transcribe-meeting --diff shows only that paragraph changed and the code fence intact
  • gaia eval agent --category tool_selection — 3/5, avg 7.2. No regression: both failures reproduce on a clean tree (smart_discovery FAIL 3.5 unchanged; multi_step_plan is flaky — 5.2 and 8.9 with the change, 9.7 without, 7.35 in the baseline). known_path_read improved from the baseline's FAIL 6.67 to PASS 9.5.

Threads

  • Fenced code is content, not structure. The section parser split on # lines inside ``` blocks. A skill shows its output by printing it, so transcribe-meeting parsed into ten sections where a reader sees seven — and a correction to its output format validated, orphaned the closing fence, and freed the example Speakers list into the live instructions. The user had asked to remove that list.
  • The tool was invisible on the turn it exists for. remember_skill_lesson sits in the skills bundle, and someone correcting a skill talks about their meeting brief, not about skills — the same ranking blind spot that moved the file-edit tools to CORE (The flagship agent usually can't edit files on a coding request: edit tools lose tool selection #3752). It now rides the SKILL signal when a skill is loaded; an agent with no skills is byte-identical.
  • The SKILL tier decayed after one turn. An already-loaded name was skipped, which also dropped its eviction protection, so recalled procedures' own tools evicted while the procedure was still being followed. Pre-existing, surfaced by the above.
  • A quote could not survive the file's line wrap. Bodies wrap near 80 columns; the model quotes them back as one line, so replaces failed on every paragraph spanning two lines — and the refusal said "quote it exactly" without showing what to quote. Words must still match; line breaks need not.

Not in scope

Learning from traces rather than from what the user said. #2866 owns that and deliberately excludes inferring from repeated behaviour; this PR makes the explicit path it does own actually work.

Related: #2674 (umbrella), #2866, #2681.

Ovtcharov added 2 commits September 16, 2026 01:39
The SD Agent Playbook and SD User Guide were removed in v0.24.0 with the
standalone `sd` agent, so both URLs 404. The external-link check has no
tolerance flag and runs on every PR touching docs/, so this fails CI
repo-wide rather than only on the page that carries it.

The sentence keeps saying what v0.15.3 shipped — rewriting that would make
an archived release note wrong — and says where the capability lives now,
which is what a reader following the dead link was after.
Telling the agent how you want a skill's output did nothing. The transcript
skill's brief format could not be corrected at all, and the agent said it had
been anyway: asked to change it, the model reported "the transcribe-meeting
skill has been updated on your machine" having called no tool.

Four defects between the request and a stored change, each found by driving the
flagship against a local Lemonade:

* The section parser split on `#` lines inside fenced code blocks. A skill shows
  its output by printing it, so `transcribe-meeting` parsed into ten sections
  where a reader sees seven — `output-shape` covered only the fence opener, and
  the brief format sat in a phantom section named after the sample transcript.
  A correction there validated, orphaned the closing fence, and freed the
  example Speakers list into the instructions: the opposite of what was asked.

* `remember_skill_lesson` was unreachable on the turn it exists for. It lives in
  the `skills` bundle, and someone correcting a skill talks about their meeting
  brief, not about skills, so semantic selection never picked that bundle — the
  same ranking blind spot that moved the file-edit tools to CORE (#3752). It now
  rides the SKILL signal whenever a skill is loaded and learning is on, so an
  agent with no skills is byte-identical.

* The SKILL tier lost a tool the turn after it admitted it. An already-loaded
  name was skipped, which also left it out of the protected set, making an
  uncalled row the LRU's first pick — recalled procedures' own tools evicted
  while the procedure was still being followed.

* A quote could not survive the file's line wrap. Bodies wrap near 80 columns;
  the model reads them as prose and quotes back one line, so `replaces` failed
  on every paragraph spanning two lines, and the refusal said "quote it exactly"
  without showing what to quote. Words must still match; line breaks need not,
  and a genuine miss now prints the section.

`transcribe-meeting` gains a `Brief shape` section so the part that is a matter
of taste has its own anchor, separate from the transcript example above it.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes agents labels Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Skill audit

Skill Verdict Claimed tier Cleared tiers Findings Rules
hub/skills/transcribe-meeting ✅ ALLOW community experimental, community none —

✅ All audited skills cleared the tier they claim.

Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the skill-audit-reports artifact from this run. Offending source text is withheld from CI everywhere — reproduce it locally with gaia skill audit <dir> --show-snippets.

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes — two one-line fixes, then this is ready.

This makes "tell GAIA how you want a skill's output" actually stick: the parser stops treating example Markdown inside code fences as real sections, the correction tool becomes visible on the turn someone asks for a change, and a quote no longer has to match the file's line wrapping. The write path is well covered and the failure it fixes is reproduced in tests.

Two things to fix before merge:

  1. Looking up a section by its heading can land on the wrong section. The new "you may write Brief shape instead of brief-shape" convenience normalizes the name with its own rule rather than the one that produced the slugs, so two headings that differ only in punctuation can collapse onto each other — a correction then edits a section the user never named, which is the one outcome this whole subsystem exists to prevent. Headings longer than 64 characters also stop resolving by their spelling. Reusing the existing slug function fixes both.

  2. A rejected gaia skill deltas --drop-section now leaves a dead row behind. Because the lookup accepts the heading spelling but the deeper check does not, the command writes the change record first, then refuses it — the record stays in the database, inert but permanent, and the user sees a refusal that contradicts the lookup that just succeeded. Anchoring on the resolved section name (the same thing the agent-facing tool already does) makes the command simply work.

Real-world evidence

The bundle exercises the real gaia skill deltas CLI on this branch against the base commit, on an ubuntu-latest runner with no Lemonade. It shows the core fix working: the shipped transcription skill now parses into the 8 headings a reader sees (base: 11 — the 3 extras are its own sample transcript), and dropping the fenced section removes the whole block instead of cutting off at the fence opener and freeing the example into live instructions.

$ gaia skill deltas transcribe-meeting --scope GaiaAgent --drop-section no-such-section
gaia skill deltas: 'transcribe-meeting' has no section 'no-such-section'. Sections are: transcribe-meeting, procedure, never-build-the-brief-from-a-fragment, when-speaker-identification-did-not-run, speaker-names-are-inferred-not-identified, output-shape, brief-shape, fork-this.

Base, same command — three phantom sections from inside the code fence:

gaia skill deltas: 'transcribe-meeting' has no section 'no-such-section'. Sections are: …, output-shape, transcript-staff-meeting, speakers, transcript, brief-shape, fork-this.

The bundle's own section 4 records the CLI heading-spelling refusal that my finding 2 above traces to a leaked record — worth reading together. The Agent UI screenshot and the remember_skill_lesson reachability check are both marked pending strix-halo lane (no live embedder or model turn on this runner), so that half of the PR rests on static review plus the new unit tests; nudge for the screenshot, no need to block on it. HTTP/REST and MCP are correctly N/A — no route or MCP surface is in the diff.

🔍 Technical details

pytest is unavailable on this runner, so instead of re-running the suite I exercised src/gaia/skills/sections.py directly. The fence work checks out: all 16 shipped skills round-trip losslessly through parse_sections/render_sections, and every one now parses to exactly the heading count a reader sees.

Issues found

🟡 find_section can resolve a name onto a different section (src/gaia/skills/sections.py:200)

The fallback normalizes with an inline re.sub(r"[^a-z0-9]+", "-", …), but slugs are produced by slugify_heading, which first strips `, * and _ and then truncates to MAX_SLUG_LENGTH. The two disagree, so the docstring's claim — "it can only map a name onto the slug that name would have produced — never onto a different section" — does not hold:

body = "# A_B\n\nx\n\n# A B\n\ny\n"
secs = parse_sections(body)          # slugs: ['ab', 'a-b']
find_section(secs, "A_B").heading    # -> 'A B'   ← the other section

remember_skill_lesson anchors on anchored.slug, so a model that quotes an underscored heading writes its correction into the neighbouring section — silently, and with a digest that validates. The same divergence makes any heading over 64 chars unresolvable by its spelling.

    wanted = slugify_heading(slug)

🟡 A refused --drop-section persists a staged row (src/gaia/skills/deltas_cli.py:237)

find_section now accepts "Brief shape", so the guard at :222 passes; put_delta then stores anchor_section=args.drop_section verbatim (status staged) before approve_delta → validate_delta — which matches slugs exactly (src/gaia/agents/base/skill_deltas.py:455) — raises. The CLI prints the error and returns EXIT_USAGE, leaving the row in skill_deltas with an anchor nothing can ever resolve. On base, the lookup refused first and nothing was written.

remember_skill_lesson already solved this at src/gaia/agents/tools/skill_learning_tools.py:210 (section = anchored.slug); the CLI should mirror it, which also makes the tolerant spelling work end to end instead of refusing at a deeper layer:

            anchor_section=target.slug,

Nits

🟢 The refusal embeds an unbounded section (src/gaia/agents/base/skill_deltas.py:285). Showing the section is the right call, but the largest shipped one (transcribe-meeting → procedure) is already 3.2 KB, and a user-authored skill has no ceiling — that lands whole in a tool result. Worth a cap with a "…(truncated)" tail.

🟢 The comment above _HEADING_RE reads backwards (src/gaia/skills/sections.py:37). The pattern is anchored at ^#, which is what makes an indented # Heading content — "unanchored leading whitespace" says the opposite of what the regex does.

#: The anchor at ``^#`` is also deliberate: an indented line is a code block in
#: CommonMark, so ``    # Heading`` is content, not a split point.

🟢 Reflow tolerance spans paragraph breaks. \s+ matches a blank line, so replace_snippet("a b\n\nc d", "b c", "X") yields "a X d" — a quote can silently join two paragraphs. It only runs when the exact match fails, and it is the same permissiveness str.replace had mid-word, so probably fine as shipped — but worth knowing it is not just line-wrap tolerance.

Strengths

  • The fence fix ships with a guard that will catch the next one. test_no_shipped_skill_has_a_section_named_after_its_own_sample_data re-derives the visible heading count independently of parse_sections and asserts they agree, for every shipped skill — a phantom section is otherwise invisible until someone edits it. The CommonMark edge cases (tilde fences, a shorter backtick run not closing a longer one, an unterminated fence failing safe) are each pinned.
  • The tool-loader eviction fix is genuinely separable and correctly scoped. Adding an already-loaded name to admitted_this_turn restores the tier's per-turn protection without making it permanent, and test_a_skill_tool_the_signal_stops_naming_becomes_evictable_again pins the self-healing half. sel.skill is log-only, so the wider reporting is free.
  • The relaxation from "refuse a missing heading" to "restore it" is argued from an observed failure, not from taste — and the deliberate-deletion case (replaces="## Procedure") stays refused, which is the right line to draw.
  • Eval was run on a tool-docstring change, as the repo requires, with the flaky scenario called out and known_path_read improving against baseline.

# Conflicts:
#	docs/releases/v0.15.3.mdx
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Merged main in and resolved the one conflict. The branch is mergeable again; none of the skill-correction code was involved.

The conflict was a one-line release note both sides had edited. Main's wording is the correct one and was kept.

🔍 Technical details

docs/releases/v0.15.3.mdx:61 — the branch said the SD pages were removed in v0.24.0, main said v0.24.1. Main's line comes from #3970 ("name the release that actually removed the SD pages"), so took --theirs. Everything else auto-merged, including hub/agents/gaia/python/gaia_agent/agent.py and hub/agents/chat/python/gaia_agent_chat/tool_bundles.py.

Tests on the merge result: tests/unit/test_adaptive_skills.py, test_tool_loader_selection.py, test_starter_skills.py, hub/agents/gaia/python/tests/test_skill_learning_reachability.py — 311 passed, 15 skipped.

kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 24, 2026
amd#4120)

Five open PRs (amd#4096, amd#4108, amd#3937, amd#3122, amd#3072) are showing a red
agent-eval lane for a scorecard that was never produced. The Anthropic
account is over its weekly spend cap, and the rejection text changed to
a wording the preflight classifier does not recognise, so instead of
"quota exhausted, this says nothing about your PR" the job dies in ~37
seconds with "could not be classified" and looks like a measured quality
regression. After this change the same outage is named as a quota outage
and points at billing rather than at the PR or the repository secrets.

The pattern matches on `weekly limit`, not on the reset date the message
quotes — that date moves every reset.

## Test plan

- [ ] `python -m pytest tests/unit/test_classify_claude_probe.py -q` —
30 passed
- [ ] `test_real_weekly_limit_rejection_is_a_quota_problem` feeds the
verbatim text from run 35681533582 (job 106629918099), BOM and U+00B7
included, and asserts `quota`; it fails on `main`
- [ ] `test_the_weekly_limit_pattern_does_not_depend_on_the_reset_date`
pins that a different reset date still classifies
- [ ] `python util/lint.py --black --isort --flake8` passes
- [ ] The classifier stays pure ASCII
(`test_the_classifier_module_is_pure_ascii`), which the PowerShell eval
step depends on

Co-authored-by: Kalin Ovtcharov <[email protected]>
find_section's fallback re-derived a slug with its own inline regex
instead of calling slugify_heading, so two headings differing only
in stripped punctuation (or over 64 chars) could collapse onto the
same lookup key -- a model quoting one heading could silently edit
its neighbor. `gaia skill deltas --drop-section` anchored on the raw
typed spelling rather than the resolved slug for the same reason, so
a rejected drop still left a permanently-unresolvable staged row.
Also caps an unbounded section dump in a DeltaRefused message and
fixes a backwards comment on the heading regex.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit c187769 Sep 25, 2026
56 of 61 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/skill-corrections-land branch September 25, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant