Repository navigation
feat(agent): use Site Audit from the in-product assistant - #307
Merged
Merged
Conversation
Wire the three site-audit data functions (from #269/#270) into the in-product agent's tool registry so the chat can run and read audits: - run_site_audit (write — spends a monthly Site Audit credit), get_site_audit and list_site_audits (reads) added to buildAgentTools, reusing runSiteAuditFor / getSiteAuditFor / listSiteAuditsFor with the same McpAuthContext scoping as the other agent tools. - system-prompt: list the three tools and add a rule that run_site_audit is a credit-spending write — only fire on explicit user intent, then poll get_site_audit until completed and summarize score / weak categories / top fixes; relay the quota-limit message instead of retrying. Closes #271
3 tasks
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
Lets the in-product AI assistant (
/dashboard/agent) run and read Site Audits in chat — e.g. "audit my homepage" → it triggers an audit, polls for completion, then summarizes the score, weak categories, and the top AI-written fixes.Pure wiring: the agent keeps its own tool registry (
buildAgentToolsinweb/src/lib/agent/tools.ts) that wraps the sharedweb/src/lib/mcp/data.tsfunctions, with names matching the MCP tool ids. This PR reuses the site-audit data functions landed in #269/#270 (runSiteAuditFor,getSiteAuditFor,listSiteAuditsFor) the same way the agent already reusesgetVisibilitySummaryFor— no aggregation logic is duplicated, and ownership/quota stay server-side.Changes
web/src/lib/agent/tools.ts— register three tools:run_site_audit(brand_id, url) — write: triggers an audit, returnsstatus: "running". Consumes one of the org's monthly Site Audit credits (shared pool with the dashboard).get_site_audit(audit_id) — read: status + total/category scores + signals + AI recommendations.list_site_audits(brand_id) — read: recent audits to find one by url/date.web/src/lib/agent/system-prompt.ts— add the three tools to the "Tools available" list, plus a rule thatrun_site_auditis a credit-spending write: only fire on explicit user intent, then pollget_site_audituntilcompletedand summarize score / weak categories / top fixes; relay the quota-limit message instead of retrying. (The chat loop already multi-steps viastepCountIs(20), so trigger → poll → summarize completes in one turn.)Related issue
Closes #271
Type of change
feat— New featureHow to test
In the dashboard chat (
/dashboard/agent):run_site_audit, pollsget_site_audit, and reports the total score, weakest categories, and top AI fixes.list_site_audits, no credit consumed.Checklist
feature/)yarn typecheck,eslint,prettier --checkpass on changed files