Repository navigation
Conversation
…sions Cursor cloud sessions do not fire Cursor's specialized hooks (beforeMCPExecution and friends), which agent-monitor needs to know so it handles their tool calls in the generic hooks. Report the "cursor-cloud" surface when the cursor client's hook runs with CURSOR_AGENT_SOCKET set (non-empty). Every other Cursor surface sends no header, as before. Like the Copilot surfaces, it is scoped to its own client: the variable is inherited by anything a cloud session spawns, so other clients never claim it. Implemented in all three senders: hook_events.agent_surface(), snyk-agent-guard.sh and snyk-agent-guard.ps1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PR Summary by QodoIdentify Cursor cloud sessions in guard hook requests
AI Description
Merge Risk
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab) |
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
X-Agent-Surface: cursor-cloudwhen thecursorclient's hook runs withCURSOR_AGENT_SOCKETset (non-empty), i.e. in a Cursor cloud session.cursorclient, like the Copilot surfaces: the variable is inherited by anything a cloud session spawns, so other clients never claim it.hook_events.agent_surface(),snyk-agent-guard.shandsnyk-agent-guard.ps1.Why
Cursor cloud sessions do not fire Cursor's specialized hooks (
beforeMCPExecution, ...). agent-monitor uses this header to handle their tool calls in the generic hooks instead of skipping them.Test plan
tests/unit/test_hook_events.pyandtests/unit/test_guard.py(966 passed, 34 skipped). New cases: cursor with/without/emptyCURSOR_AGENT_SOCKET, other clients never claim the surface, and the real.shscript against the test hook server.pwshfor cursor with/without the variable,claude-code, andgithub-copilot(the repo has no execution tests for.ps1).CURSOR_AGENT_SOCKETis set in the hook process environment.🤖 Generated with Claude Code
Note
Low Risk
Additive header behavior for one client and env var; scoped to avoid mis-attribution on other agents.
Overview
Hook forwarders now emit
X-Agent-Surface: cursor-cloudwhen thecursorclient runs with a non-emptyCURSOR_AGENT_SOCKET(Cursor cloud). Other Cursor surfaces still send no surface header, matching the existing Copilot-only surface pattern.The same detection is wired through
agent_surface()in Python andget_agent_surface/ PowerShell agent-surface logic in the shell hooks, withCURSOR_AGENT_SOCKETgated to--client cursorso inherited env vars cannot make other clients (e.g. claude-code, codex) claimcursor-cloud.Unit tests cover cursor with/without the variable, empty values, and cross-client isolation for both Python delivery and the
.shhook script.Reviewed by Cursor Bugbot for commit 00da6fb. Bugbot is set up for automated code reviews on this repo. Configure here.