Skip to content

sessionStart additionalContext duplicated on each turn and passed to subagents #4665

Description

@sfuqua

Describe the bug

I am observing two anomalous behaviors with content my sessionStart hooks inject into the session:

  • Every single prompt I submit reinjects (duplicates) the same additionalContext prior to my first message. Confirmed via /context as well as analysis of AIC and tokens consumed, and a minimal repro plugin.
  • Subagents get the additionalContext prepended, which is new behavior (at some point, not sure which version). This is not a subagentStart hook, it's sessionStart.

My sessionStart is about 1k tokens right now which means every single prompt gets an additional 1k token rider repeating itself in the transcript, and it's also tuned to the top level session and I don't want it in subagent contexts.

Affected version

1.0.82

Steps to reproduce the behavior

  1. Create a sessionStart hook that injects ~1k tokens of lorem ipsum + a canary phrase via additionalContext
  2. Load the hook in an otherwise blank session
  3. Say "hi", invoke /context, observe the expected ~1k tokens
  4. Take two more turns "hi: respond ACK"; "hi again: respond ACK"
  5. /context, observe ~2k additional message tokens more than expected based on the short turns

Unzip attachment for a standalone repro; run copilot with --plugin-dir pointing at it and follow steps in the README.

sessionstart-context-replay-repro.zip

Expected behavior

sessionStart context is injected once; no additional compounding cost is paid per turn other than that flat set of tokens at the start of the conversation.

sessionStart context is not propagated to subagents.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions