Skip to content

feat(agent): render Site Audit results inline in the chat #272

Closed

Description

@gkhngyk

What

When the assistant runs/reads a Site Audit (#271), render the result as a compact inline audit card in the chat — score gauge, category bars, and the top recommendations — instead of a raw JSON tool-call disclosure.

Why

The Agent already renders charts inline via render_chart; an audit result is far more useful as the same kind of rich inline card than as a JSON blob. It mirrors the existing pattern and reuses the dashboard's audit UI.

Approach (mirror render_chart / AgentChart)

  • Add an echo-style render_audit tool to buildAgentTools (web/src/lib/agent/tools.ts) — like render_chart, its execute just returns its input. Schema carries the displayable fields: { url, totalScore, categoryScores, recommendations[], signalsEvaluated, signalsTotal }. The system prompt instructs the model to call it after get_site_audit/run_site_audit.
  • In web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx MessageBubble, add a branch part.type === 'tool-render_audit' → <AuditResultCard .../> (everything else still falls through to the generic JSON disclosure), matching how tool-render_chart → <ChartToolPart> works.
  • Build the card by reusing/adapting web/src/components/audit/audit-report.tsx (it already renders score gauge + category bars + recommendations); a compact variant is fine for the chat width.

Acceptance

  • After an audit tool call, the chat shows a readable audit card (score + grade, category breakdown, top fixes) — not raw JSON
  • Card visual language matches the dashboard audit report (score-band colors, etc.)
  • Non-audit tool calls are unaffected (still use the generic disclosure)

Depends on #271 (agent audit tools).

Activity

  1. added
    enhancement
    good first issue
    on Jun 17, 2026
  2. BharadwajKanneveti commented on Jun 22, 2026

    @BharadwajKanneveti
    Contributor

    Hi @gkhngyk can I work on this issue?

  3. gkhngyk commented on Jun 23, 2026

    @gkhngyk
    ContributorAuthor

    Assigned — thanks @BharadwajKanneveti! 🎉 Two pointers: (1) this builds on #271 (running/reading a Site Audit from the agent), so it's cleanest to land once the audit tool exists — feel free to coordinate or stack the PRs. (2) Mirror the existing render_chart / AgentChart pattern: add an echo-style render_audit tool in buildAgentTools and reuse the dashboard's audit UI (AuditReport and its pct/scoreColor/CATEGORY_META exports) so the inline card matches the rest of the product.

  4. gkhngyk commented on Jun 27, 2026

    @gkhngyk
    ContributorAuthor

    Quick update, @BharadwajKanneveti — the dependency for this, #271 (running/reading a Site Audit from the agent), is now implemented in #307. Once that merges, the run_site_audit / get_site_audit agent tools you'll build the inline card on top of will be in main. Feel free to start now by stacking on #307, or wait for it to land — whichever you prefer.

    As a reminder, the cleanest path is an echo-style render_audit tool in buildAgentTools mirroring render_chart / AgentChart, reusing the dashboard's AuditReport (pct / scoreColor / CATEGORY_META) so the inline card matches the rest of the product. Ping me if you'd like a hand — no rush, just flagging that you're unblocked.

  5. BharadwajKanneveti commented on Jun 27, 2026

    @BharadwajKanneveti
    Contributor

    Thanks for the update @gkhngyk I see #307 has been merged now.

    I'll rebase onto the latest main and continue implementing the inline audit rendering on top of the new audit tools, following the existing render_chart / AgentChart pattern and reusing the dashboard audit UI helpers to keep the card consistent with the rest of the product.

  6. gkhngyk commented on Jul 9, 2026

    @gkhngyk
    ContributorAuthor

    Hey @BharadwajKanneveti — friendly check-in on this one, no pressure. 🙂

    Good news: the dependency (#271, the agent Site Audit tools) is merged, so this is fully unblocked now. The audit tools (run_site_audit, get_site_audit, list audits) are live in web/src/lib/agent/tools.ts, and the render_chart → ChartToolPart pattern this issue mirrors is right there in web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx to copy from.

    So the two pieces left are: (1) add an echo-style render_audit tool alongside render_chart in tools.ts, and (2) add a part.type === 'tool-render_audit' branch in MessageBubble that renders an AuditResultCard (reuse/adapt web/src/components/audit/audit-report.tsx).

    Are you still planning to take it? Take your time if so — just wanted to flag that the blocker is gone. If you'd rather pass on it, no worries at all, just let us know and we'll leave it open for someone else. Thanks! 🙌

  7. BharadwajKanneveti commented on Jul 9, 2026

    @BharadwajKanneveti
    Contributor

    Hi @gkhngyk I have already made the changes you asked for but currently I am facing an issue with with claude api where in the rendering the agent is not responding to my answers to see my changes working or not so is there any way to resolve this ?
    Sorry for not raising this prior to you

  8. gkhngyk commented on Jul 9, 2026

    @gkhngyk
    ContributorAuthor

    No worries at all, @BharadwajKanneveti — and great that the code is done! 🙌

    That's just a local setup thing, not a bug in your changes: the in-product agent (web/src/app/api/agent/chat/route.ts) calls Anthropic, and in self-host mode it reads the key from process.env.ANTHROPIC_API_KEY (see web/src/lib/agent/key.ts). If that env var isn't set, the agent stays silent — which is exactly the "no response" you're seeing.

    Fix: add your own key to web/.env.local and restart yarn dev:

    ANTHROPIC_API_KEY=sk-ant-...   # from https://console.anthropic.com

    (You'll need your own key — we can't share ours.)

    Also: feel free to open your PR as a draft even before you can test the chat locally — reviewers can verify the audit card renders with a real key on our side, so you don't have to stay blocked on this. Thanks again! 🙌

  9. BharadwajKanneveti commented on Jul 9, 2026

    @BharadwajKanneveti
    Contributor

    Sure @gkhngyk I will raise the PR thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions