Skip to content

ref(seer): Add priority-based root node selection to snapshot_to_markdown#113715

Merged
Mihir-Mavalankar merged 4 commits intomasterfrom
mihir-mavalankar/ref/priority-based-context-node-selection
Apr 22, 2026
Merged

ref(seer): Add priority-based root node selection to snapshot_to_markdown#113715
Mihir-Mavalankar merged 4 commits intomasterfrom
mihir-mavalankar/ref/priority-based-context-node-selection

Conversation

@Mihir-Mavalankar
Copy link
Copy Markdown
Contributor

@Mihir-Mavalankar Mihir-Mavalankar commented Apr 22, 2026

  • Sort root nodes by data.priority (descending, default 0) and render only nodes at the highest priority level. This lets frontend components declare their importance so the backend selects the most relevant context without frontend route-based filtering.
  • Currently root nodes don't have priority but the followup frontend PR will add it- ref(seer): Use priority field instead of frontend route filtering #113717

…down

Sort root nodes by data.priority (descending, default 0) and render
only nodes at the highest priority level. This lets frontend components
declare their importance so the backend selects the most relevant
context without frontend route-based filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Mihir-Mavalankar Mihir-Mavalankar self-assigned this Apr 22, 2026
@Mihir-Mavalankar Mihir-Mavalankar requested a review from a team as a code owner April 22, 2026 18:42
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 22, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 00c9422. Configure here.

Comment thread src/sentry/seer/explorer/client_utils.py Outdated
Use isinstance check to safely handle cases where priority is None
or a non-int value instead of relying on dict.get default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@Zylphrex Zylphrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question around why priority is stored inside data instead of being lifted to the node but otherwise LTGM

data = node.get("data")
if isinstance(data, dict):
for key, value in data.items():
if key == "priority":
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the name of this coming from? Should this be in a constant somewhere explaining why they're being skipped? Should it be stored separately from the actual data so we don't need to do special handling by comparing it against a hard coded key name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each page defines the priority of root nodes on it. So say on dashboards, the dashboard page root has priority 0 so it's but into the LLM on page context. Now if the user opens a new widget pullout on that dashboard it should get higher priority i.e. and should be put into the on page context rather than the original dashboard since that's what the user is interacting with. The logic in the function only puts the root nodes with the highest priority in the on page context.
Priority is only relevant for root nodes. The continue here is just to skip it once they are sorted and processed and to not the add the priority explicitly into the LLM on page context.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of making it a const as well. You can reference the key when setting the vals on the json blob as well, ts has a nice shortcut syntax for that: {[SOME_CONST]: some_val}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll move it a be an optional property node so we don't need this special handling here.

Move priority to a top-level node field rather than embedding it in
data. This avoids hardcoded key skipping in _render_node.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread src/sentry/seer/explorer/client_utils.py Outdated
The docstring referenced data.priority but _get_priority reads from
node.priority directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Mihir-Mavalankar Mihir-Mavalankar merged commit 7b1bd12 into master Apr 22, 2026
56 checks passed
@Mihir-Mavalankar Mihir-Mavalankar deleted the mihir-mavalankar/ref/priority-based-context-node-selection branch April 22, 2026 21:09
Mihir-Mavalankar added a commit that referenced this pull request Apr 23, 2026
…13717)

+ Add priority: 1 to widget-builder's useLLMContext data so the backend
selects it over the dashboard node. Remove the WIDGET_BUILDER_ROUTES
frontend filtering that was doing this client-side.
+ Will merge this after the backend PR:
#113715

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants