Skip to content

fix(session): keep disable-model-invocation skills out of model context - #200

Open
fchengyan (fcy222fcy) wants to merge 1 commit into
microsoft:mainfrom
fcy222fcy:fix/skill-disable-model-invocation
Open

fchengyan (fcy222fcy) wants to merge 1 commit into
microsoft:mainfrom
fcy222fcy:fix/skill-disable-model-invocation

Conversation

@fcy222fcy

Copy link
Copy Markdown

Linked issue

Fixes #190 — "The harness doesn't honor disable-model-invocation: true".

What changed (Before / After)

Before: every skill directory with a SKILL.md was listed in the <skills> block that context_block() sends to the model, regardless of its frontmatter. A skill authored with disable-model-invocation: true — the Agent Skills convention used by Claude Code and Pi to mean "the person invokes this by hand, do not offer it to the model" — was still injected into the model's context, spending tokens on a skill the author explicitly opted out of.

After: skills() reads the disable-model-invocation frontmatter field into a model_invocation flag, and context_block() lists only skills whose flag allows model invocation. The skill stays in the slash-command menu (usercommands.available() uses the same skills() list unfiltered), so the person can still invoke it exactly as before. This is a frontmatter-contract fix, not a behavioural/benchmark tuning of the prompt, tools or status line: it removes a skill the author marked as hand-only, and the description text and formatting of remaining skills are untouched.

Accepted values for "disabled" are true, yes and 1 (case-insensitive); anything else — including an absent field — keeps the current behaviour (offered to the model).

Visual proof (UI / TUI / Web / Desktop / export changes)

N/A — this changes the context string built for the model; proof is the before/after test output below.

How you verified it

Reproduced first against unmodified main, then confirmed green after the fix:

  • Red (before, git checkout of session.py): both new tests failed —
    AssertionError: disable-model-invocation: true skill leaked into the model context, with the skill line
    - manual-skill: only run by hand (.../SKILL.md) visible inside the emitted <skills> block.
  • Green (after): pytest -q tests/test_skill_disable_model_invocation.py → 2 passed.
  • Regression baseline, same suite run with and without the change:
    • without: 30 failed, 26 passed, 3 skipped
    • with: 30 failed, 28 passed, 3 skipped
      The 30 failures are identical in both runs and are pre-existing Windows-only failures
      ("Freehand does not run natively on Windows yet (it requires POSIX bash)"); the +2 passes are the new tests.
      No new failures.
  • pyflakes src/freehand/session.py tests/test_skill_disable_model_invocation.py prints nothing.

Changed files: src/freehand/session.py (+7/−2), tests/test_skill_disable_model_invocation.py (+36, new).

AI disclosure & checklist

  • AI disclosure: AI-assisted (personally tested and verified — red/green reproduction and regression baseline captured locally)
  • uv run pyflakes src tests .github/scripts prints nothing and relevant tests pass locally (full suite runs in CI)
  • Left CHANGELOG.md untouched (maintainers update it at release time)
  • No change to what the model sees (prompt, tool descriptions, status line, notes), or benchmark evidence attached — see "What changed": this is a frontmatter-contract fix that removes a hand-only skill from the model context; the wording/layout of all remaining context is unchanged, and red/green evidence is attached. Happy to run the benchmark if maintainers want a number.
  • src/freehand/runtime/ still uses only the standard library and imports on Python 3.9

A SKILL.md that sets `disable-model-invocation: true` is still offered to
the person as a slash command, but is no longer listed in the <skills>
block sent to the model, matching Claude Code / Pi semantics. Fixes microsoft#190.

Added regression tests covering true/yes/TRUE values and confirming the
skill stays invokable by the person.

This branch has not been deployed

No deployments
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.

The harness doesn't honor disable-model-invocation: true

1 participant