Summary
The onSessionStart hook input should include the agent name that the CLI was launched with (--agent <name>). Currently, the input only contains source, initialPrompt, timestamp, and cwd there's no way for an extension to know which agent it's running inside.
Use Case
Myelin is a knowledge graph memory extension for Copilot CLI agents. On session start, it injects agent-specific context from the graph different agents get different knowledge nodes based on their domain. For example, a security-focused agent gets security decisions and patterns, while a frontend agent gets UI component relationships.
To do this, the extension needs to know which agent is running. Today, the onSessionStart input doesn't provide this, so users must manually set a COPILOT_AGENT environment variable before launching:
�ash COPILOT_AGENT=myagent copilot --agent myagent
This is redundant the CLI already knows the agent name from --agent. It just doesn't pass it to extensions.
Proposed Change
Add an agentName field to the onSessionStart hook input:
ypescript onSessionStart input: { source: "startup" | "resume" | "new", agentName?: string, // <-- NEW: the --agent value, if provided initialPrompt?: string, timestamp: number, cwd: string, }
This would also be useful in other hooks (onSessionEnd, onUserPromptSubmitted, etc.) or as a field on the invocation object, since the agent identity doesn't change mid-session.
Workaround
Extensions can read process.env.COPILOT_AGENT if users set it manually before launching, but this requires users to know about the env var and duplicate the agent name in their launch command.
Impact
Any extension that wants to provide agent-specific behavior personalized context injection, per-agent logging, agent-specific tool configuration hits this gap today.
Summary
The
onSessionStarthook input should include the agent name that the CLI was launched with (--agent <name>). Currently, the input only containssource,initialPrompt,timestamp, andcwdthere's no way for an extension to know which agent it's running inside.Use Case
Myelin is a knowledge graph memory extension for Copilot CLI agents. On session start, it injects agent-specific context from the graph different agents get different knowledge nodes based on their domain. For example, a security-focused agent gets security decisions and patterns, while a frontend agent gets UI component relationships.
To do this, the extension needs to know which agent is running. Today, the
onSessionStartinput doesn't provide this, so users must manually set aCOPILOT_AGENTenvironment variable before launching:�ash COPILOT_AGENT=myagent copilot --agent myagentThis is redundant the CLI already knows the agent name from
--agent. It just doesn't pass it to extensions.Proposed Change
Add an
agentNamefield to theonSessionStarthook input:ypescript onSessionStart input: { source: "startup" | "resume" | "new", agentName?: string, // <-- NEW: the --agent value, if provided initialPrompt?: string, timestamp: number, cwd: string, }This would also be useful in other hooks (
onSessionEnd,onUserPromptSubmitted, etc.) or as a field on theinvocationobject, since the agent identity doesn't change mid-session.Workaround
Extensions can read
process.env.COPILOT_AGENTif users set it manually before launching, but this requires users to know about the env var and duplicate the agent name in their launch command.Impact
Any extension that wants to provide agent-specific behavior personalized context injection, per-agent logging, agent-specific tool configuration hits this gap today.