Skip to content

feat(seer): Convert structured LLMContext JSON to markdown for on_page_context#112181

Merged
Mihir-Mavalankar merged 1 commit intomasterfrom
mihir/feat/structured-page-context-to-markdown
Apr 3, 2026
Merged

feat(seer): Convert structured LLMContext JSON to markdown for on_page_context#112181
Mihir-Mavalankar merged 1 commit intomasterfrom
mihir/feat/structured-page-context-to-markdown

Conversation

@Mihir-Mavalankar
Copy link
Copy Markdown
Contributor

  • When the frontend sends a structured LLMContextSnapshot as JSON in on_page_context (instead of the legacy ASCII DOM screenshot), the explorer chat endpoint now detects it and converts it to a readable markdown string before forwarding to Seer. Non-JSON on_page_context (the existing ASCII screenshot) passes through unchanged.
    + This is the backend half of the structured page context feature. The frontend counterpart (conditionally sending JSON instead of ASCII when organizations:context-engine-structured-page-context flag is on + dashboards page) will follow in a separate PR per the frontend/backend split deploy requirement.

  • This won't do anything currently right cuz the this is always false - snapshot = json.loads(on_page_context)

    Follow-up PRs

    1. Frontend PR: Wire getLLMContext() into useSeerExplorer.tsx — when the feature flag is on and the user is on a dashboards page, send JSON.stringify(getLLMContext()) as on_page_context instead of the ASCII screenshot
    2. Widget/chart context nodes: Add registerLLMContext('widget', ...) and registerLLMContext('chart', ...) to dashboard widget and chart components so the snapshot tree has richer data (query config, filters, etc. — not
      raw timeseries data)

@Mihir-Mavalankar Mihir-Mavalankar requested a review from azulus April 2, 2026 22:39
@Mihir-Mavalankar Mihir-Mavalankar self-assigned this Apr 2, 2026
@Mihir-Mavalankar Mihir-Mavalankar requested a review from a team as a code owner April 2, 2026 22:39
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 2, 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.

…e_context

When the frontend sends a structured LLMContextSnapshot as JSON in
on_page_context (instead of an ASCII DOM screenshot), the endpoint now
detects it and converts it to a markdown string before forwarding to
Seer. Non-JSON on_page_context (the existing ASCII screenshot) passes
through unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>


def _render_node(node: dict[str, Any], depth: int) -> str:
"""Recursively render an LLMContextSnapshot node and its children as markdown."""
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 think the answer is probably no, but there's a question as to whether some sort of indentation might make sense here. It tends to break markdown, but AI probably won't care tbh. My concern is that a parent with N children may cause the LLMs to kind of lose context of hierarchy later if they're reliant on matching up # counts. This is probably a non-issue, but flagging

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.

Yeah with increasing depth matching up # is probably not best. I'll try this out a biton the a dashboard pages and see. I'll add indents if there seem to be issues.

@Mihir-Mavalankar Mihir-Mavalankar merged commit 085bd28 into master Apr 3, 2026
65 checks passed
@Mihir-Mavalankar Mihir-Mavalankar deleted the mihir/feat/structured-page-context-to-markdown branch April 3, 2026 15:58
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.

2 participants