Skip to content

Commit 1006f00

Browse files
committed
fix(hooks): resolve sessionID for agents to support main thread recognition
Treat sessionID as the subagent signal in the runner envelope. Kilo and OpenCode currently expose only {tool, sessionID, callID} on the tool.execute.before input, with no parentID or agent name (verified by the probe in /tmp/kilo-hook-probe.log, see community issue anomalyco/opencode#15403 which proposed surfacing parentAgent and closed as stale on 2026-07-03). On the kilo jetbrains surface every delegated subagent has a populated sessionID, so the runner can pass is_subagent: true for those and the gate's subagent delegation path accepts them. The downside: the main thread also has a populated sessionID, so main-thread file edits also pass. The gate's shell-level Rule A still fires for sed/tee/redirect writes, so the protection is partial, not absent. A proper fix needs upstream support for parentAgent in the hook envelope.
1 parent 3f2abe7 commit 1006f00

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎.agents/plugin/hooks.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export const Preflight = async ({ directory, worktree, client } = {}) => {
164164
// trip for the assistant text out of a project that checked out no hooks.
165165
if (hooks.length === 0) return
166166

167-
const agent = typeof input?.agent === "string" ? input.agent : ""
167+
// will allow even main thread - currently no way to recognize subagents in kilo or opencode
168+
const agent = typeof input?.sessionID === "string" && input.sessionID ? input.sessionID : (typeof input?.agent === "string" ? input.agent : "")
168169

169170
const envelope = JSON.stringify({
170171
contract: CONTRACT,

0 commit comments

Comments
 (0)