Merge pull request #1953 from maximharizanov/fix/copilot-initiator-attribution

fix(copilot): mark internal hook injections as agent-initiated
This commit is contained in:
YeonGyu-Kim
2026-02-20 11:54:01 +09:00
committed by GitHub
19 changed files with 292 additions and 22 deletions
+9 -2
View File
@@ -16,6 +16,10 @@ type ToolContextWithCallID = ToolContext & {
call_id?: string
}
type ToolContextWithMetadata = ToolContextWithCallID & {
metadata?: (value: unknown) => void
}
function resolveToolCallID(ctx: ToolContextWithCallID): string | undefined {
if (typeof ctx.callID === "string" && ctx.callID.trim() !== "") return ctx.callID
if (typeof ctx.callId === "string" && ctx.callId.trim() !== "") return ctx.callId
@@ -145,6 +149,7 @@ CONTENT FORMAT:
},
execute: async (args: HashlineEditArgs, context: ToolContext) => {
try {
const metadataContext = context as ToolContextWithMetadata
const filePath = args.filePath
const { edits } = args
@@ -188,9 +193,11 @@ CONTENT FORMAT:
},
}
context.metadata(meta)
if (typeof metadataContext.metadata === "function") {
metadataContext.metadata(meta)
}
const callID = resolveToolCallID(context)
const callID = resolveToolCallID(metadataContext)
if (callID) {
storeToolMetadata(context.sessionID, callID, meta)
}