Skip to content

When multiple sessionStart/subagentStart hooks output additionalContext, only the last one is injected into the context #3589

Description

@MrWolfZ

Describe the bug

I have multiple sessionStart/subagentStart hooks, and each of them prints {"additionalContext":"some value"} to stdout. I observed, that only the last emitted value is actually injected into the context. I validated this by simulating this with 2 synthetic hooks that inject different things and then asking the agent about them (or telling it to spawn a sub-agent and ask it). In all cases, only one of the two values is known to the agent.

To be clear, the hooks are all called (I validated this by adding an echo <hook_name> >> /tmp/test.txt to each hook), so the problem is not that only one of them is run. All are run, but only the last output is injected.

Affected version

GitHub Copilot CLI 1.0.56.

Steps to reproduce the behavior

  1. Define multiple sessionStart/subagentStart hooks that each print additionalContext to stdout
  2. Start a new copilot instance
  3. Ask it about both the injected contexts.

Expected behavior

If multiple hooks return additional context, they should all be concatenated.

Additional context

No response

Activity

  1. added theissue type on May 30, 2026
  2. changed the title [-]When multiple sessionStart/subagentStart hooks output `additionalContext`, only the last one is injected into the context[/-] [+]When multiple `sessionStart`/`subagentStart` hooks output `additionalContext`, only the last one is injected into the context[/+] on May 30, 2026
  3. added
    area:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents
    area:context-memoryContext window, memory, compaction, checkpoints, and instruction loading
    on May 30, 2026
  4. tspearconquest commented on Sep 10, 2026

    @tspearconquest

    I'm replicating similar behavior. I have a single large session start hook which just grew past 10kB. Claude Desktop is documented to truncate the additionalContext for each hook that breaches exactly 10000 bytes (less than the above mentioned 10kB). It stores the full context in a file and shows the model a preview of the beginning, trimmed to 2kB, however it properly handles multiple additionalContext entries from different hooks.

    Copilot doesn't do the truncation but does drop all except for the last additionalContext outright, meaning my single hook that wants to support both has to output separate shapes for Copilot vs Claude. Ugly.

  5. ThomasMichon commented on Sep 20, 2026

    @ThomasMichon

    The root cause here has been fixed upstream in copilot-agent-runtime: multiple sessionStart/subagentStart hook �dditionalContext values are now concatenated in execution order instead of last-writer-wins (github/copilot-agent-runtime#17878, merged).

    This hasn't shipped in a released Copilot CLI build yet as of this comment (latest release at merge time was 1.0.86 / 1.0.87-0 pre-release, both predating the fix). I'll follow up here once a release containing it is available, with the version number and confirmation that multiple hook contributions are delivered correctly.

  6. tspearconquest commented on Sep 20, 2026

    @tspearconquest

    @ThomasMichon thank you! Would you be able to share any details about whether the outputs will be processed in parallel and thusly, have no guaranteed order?

  7. copilot-cli-bot commented on Sep 29, 2026

    @copilot-cli-bot

    This appears to be resolved as of GitHub Copilot CLI v1.0.89. Please update to that release or a newer stable version. We're closing this as completed. If it still happens, please comment with your version and reproduction steps.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:context-memoryContext window, memory, compaction, checkpoints, and instruction loadingarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions