feat(opencode-bridge): P3 session lifecycle events — compact and subagent stop#975
Merged
Conversation
…gent stop - Add experimental.session.compacting hook → fires preCompact to hook_runner, injects additionalContext into output.context - Add session.compacted event → fires postCompact after compaction completes - Track subagent sessions via session.created (parentID detection) - Add session.status handler → detects subagent idle → fires subagentStop with subagentId, subagentName, parentSessionId - Only fire sessionStart for main sessions (skip subagent created events) - 4 new source-level checks + 3 new hook runner integration tests Unlocks: CompactLifecycleRule, SubagentStopRule, AutoBriefingRule (postCompact) Rules heatmap: 2 rules ░░░░→████, partial unlock for 6+ others
Owner
Author
|
/copilot-review |
magicpro97
added a commit
that referenced
this pull request
Jun 9, 2026
…n, cwd, stdout, shell.env ## Summary Closes all remaining data gaps between the opencode bridge and hook_runner rules. Part of Phase 2 opencode bridge (continuing from PR #973, #974, #975). ### Changes 1. **exitCode/exit_code/stdout in toolResult** — unlocks SkillUsageRule, TokenTrackerRule, VerificationGateRule 2. **reason in sessionEnd** — idle events pass reason="idle" instead of "unknown" 3. **cwd in userPromptSubmitted** — UserPromptContextRule finds CONTEXT.md correctly 4. **shell.env hook** — injects COPILOT_AGENT_SESSION_ID into all subprocess environments ### Testing 39/39 bridge tests pass, 13/13 security tests pass. ### Phase 2 Complete Status - ~90% rules compatible with opencode - 12 bridge hooks covering all 10 hook_runner events - Remaining gaps (agentStop, voting) are CLI-only or semantically inappropriate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds P3 session lifecycle events to the opencode bridge:
Changes
experimental.session.compactinghook — firespreCompactto hook_runner before compaction. Injects anyadditionalContextfrom rules intooutput.context.session.compactedevent — firespostCompactafter compaction completes.Subagent tracking — uses
session.createdevents to detect subagent sessions (those withparentID). Only firessessionStartfor main sessions.session.status(idle)handler — detects subagent idle → firessubagentStopwithsubagentId,subagentName,parentSessionId.Rules Unlocked
Partial unlock for 6+ additional rules that benefit from lifecycle signals.
Testing
Part of Phase 2 opencode bridge (continuing from PR #973, #974)