Skip to content

Copilot Agent Host: custom agent frontmatter hooks are dropped #341681

Closed

Description

Reported on VS Code 1.143.0-insider, commit 4c6cba15, using the Copilot / Agent Host harness.

Steps to reproduce

  1. In a trusted workspace with hooks enabled, define a custom .agent.md with a SessionStart marker hook and a PreToolUse hook that denies shell execution.
  2. Select that agent in a new Copilot / Agent Host session.
  3. Ask it to run a harmless shell command covered by the deny hook.
  4. Repeat with the selected agent supplied by a file-based plugin.

Expected: The marker hook runs and the deny hook blocks the tool before execution.

Actual: Agent-frontmatter hooks do not run; the tool executes without the agent's denial. Plugin-level and global hooks can still run.

Potential RCA

The agent converter constructs CustomAgentConfig without copying hooks. Selected plugin agents use the same conversion. This converter is unchanged at the reported revision.

A converter-level probe confirms that hooks are dropped. Direct-runtime execution of equivalent CustomAgentConfig.hooks reportedly runs SessionStart and returns Denied by preToolUse hook; the full packaged-build reproduction remains to be verified.

Preserve agent hooks through conversion while retaining trust, policy, and working-directory semantics. Regression coverage should assert hook execution and tool denial for workspace/user agents and selected plugin agents, plus isolation when switching agents.

🤖 Posted by GitHub Copilot on Harald's behalf.

Activity

  1. added
    bug
    on Oct 15, 2026
  2. digitarald commented on Oct 19, 2026

    @digitarald
    ContributorAuthor

    Additional evidence from the hook migration documentation review in microsoft/vscode-docs#10503:

    • The exact @github/[email protected] package pinned by current VS Code declares CustomAgentConfig.hooks. Its toWireCustomAgents serializer preserves the field when provided. The SDK field was added in the October 12 snapshot.
    • At 9dcad803e, toSdkCustomAgents still does not read or forward frontmatter hooks.
    • agentHost: keep plugin subagents in Copilot catalog #342092 now projects all enabled plugin agents into the explicit SDK agent catalog. Its rationale confirms that pluginDirectories discovery does not merge those agents back when customAgents is supplied, so the omission needs fixing in the conversion path rather than relying on native plugin discovery.

    The docs PR now treats affected plugin-agent scoped-hook migration as incomplete and warns against broadening hooks to plugin-wide/repository-wide events as a workaround. Product regression coverage should retain the source/trust and plugin-path semantics described in this issue, and exercise both selected agents and subagents.

  3. added
    unreleased
    on Oct 19, 2026
  4. added this to the 1.144.0 milestone on Oct 19, 2026
  5. added
    insiders-released
    and removed
    unreleased
    on Oct 21, 2026
  6. aiday-mar commented on Oct 26, 2026

    @aiday-mar
    Collaborator

    I see the following, which I assume means the issue is verified.

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buginsiders-releasedverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions