Skip to content

Commit 2aedca8

Browse files
vibegptclaude
andcommitted
feat(agentkit): Add PolicyCheck action provider for seller policy risk intelligence
Walletless action provider with two actions (policycheck_analyze, policycheck_check_url) that call the PolicyCheck A2A API at policycheck.tools. Returns risk levels, buyer protection scores, key findings, and factual summaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d038251 commit 2aedca8

2 files changed

Lines changed: 28 additions & 29 deletions

File tree

typescript/agentkit/src/action-providers/policycheck/policycheckActionProvider.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const MOCK_LOW_RISK_RESPONSE = {
2222
"1-year manufacturer warranty included",
2323
"Full refund to original payment method",
2424
],
25-
recommendation: "proceed",
25+
summary: "Strong buyer protections detected. 30-day return window, free return shipping, 1-year manufacturer warranty.",
2626
},
2727
mimeType: "application/json",
2828
},
2929
{
3030
kind: "text",
31-
text: "Low risk seller. Buyer protections are strong with a 30-day return window and free returns.",
31+
text: "Strong buyer protections across all policy categories. 30-day return window, free return shipping, 1-year warranty.",
3232
},
3333
],
3434
},
@@ -58,13 +58,13 @@ const MOCK_HIGH_RISK_RESPONSE = {
5858
"Binding arbitration clause detected",
5959
"Liability cap limits seller responsibility to purchase price",
6060
],
61-
recommendation: "caution",
61+
summary: "High risk indicators detected. 3 of 5 policy categories flagged. Binding arbitration limits dispute resolution. No return policy found.",
6262
},
6363
mimeType: "application/json",
6464
},
6565
{
6666
kind: "text",
67-
text: "High risk seller. Consider purchasing from a different merchant.",
67+
text: "High risk indicators detected. 3 of 5 policy categories flagged. Binding arbitration limits dispute resolution.",
6868
},
6969
],
7070
},
@@ -96,7 +96,7 @@ describe("PolicyCheckActionProvider", () => {
9696
describe("constructor", () => {
9797
it("should use default API URL when no config provided", () => {
9898
const p = policycheckActionProvider();
99-
expect(p["apiUrl"]).toBe("https://legaleasy.tools/api/a2a");
99+
expect(p["apiUrl"]).toBe("https://policycheck.tools/api/a2a");
100100
});
101101

102102
it("should use custom API URL from config", () => {
@@ -128,7 +128,7 @@ describe("PolicyCheckActionProvider", () => {
128128
expect(parsed.success).toBe(true);
129129
expect(parsed.riskLevel).toBe("low");
130130
expect(parsed.buyerProtectionScore).toBe(85);
131-
expect(parsed.recommendation).toBe("proceed");
131+
expect(parsed.summary).toContain("Strong buyer protections");
132132
expect(parsed.keyFindings).toHaveLength(3);
133133
expect(parsed.analyzedUrl).toBe("direct text analysis");
134134
});
@@ -147,7 +147,7 @@ describe("PolicyCheckActionProvider", () => {
147147
expect(parsed.success).toBe(true);
148148
expect(parsed.riskLevel).toBe("high");
149149
expect(parsed.buyerProtectionScore).toBe(25);
150-
expect(parsed.recommendation).toBe("caution");
150+
expect(parsed.summary).toContain("High risk indicators");
151151
});
152152

153153
it("should send seller URL as data part with quick-risk-check skill", async () => {
@@ -162,7 +162,7 @@ describe("PolicyCheckActionProvider", () => {
162162

163163
expect(fetchMock).toHaveBeenCalledTimes(1);
164164
const [url, options] = fetchMock.mock.calls[0];
165-
expect(url).toBe("https://legaleasy.tools/api/a2a");
165+
expect(url).toBe("https://policycheck.tools/api/a2a");
166166

167167
const body = JSON.parse(options.body);
168168
expect(body.method).toBe("message/send");
@@ -268,7 +268,7 @@ describe("PolicyCheckActionProvider", () => {
268268
});
269269
const parsed = JSON.parse(result);
270270

271-
expect(parsed.summary).toContain("Low risk seller");
271+
expect(parsed.summary).toContain("Strong buyer protections");
272272
});
273273
});
274274

typescript/agentkit/src/action-providers/policycheck/policycheckActionProvider.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ActionProvider } from "../actionProvider";
33
import { CreateAction } from "../actionDecorator";
44
import { PolicyCheckAnalyzeSchema, PolicyCheckUrlSchema } from "./schemas";
55

6-
const POLICYCHECK_A2A_URL = "https://legaleasy.tools/api/a2a";
6+
const POLICYCHECK_A2A_URL = "https://policycheck.tools/api/a2a";
77

88
/**
99
* Configuration options for the PolicyCheck action provider.
@@ -16,9 +16,13 @@ export interface PolicyCheckConfig {
1616
}
1717

1818
/**
19-
* PolicyCheckActionProvider enables AI agents to verify e-commerce seller policies
20-
* before making purchases. It analyzes return policies, shipping terms, warranty
21-
* coverage, and terms of service to assess buyer protection and risk levels.
19+
* PolicyCheckActionProvider provides seller policy risk intelligence for AI agents
20+
* involved in e-commerce. It analyzes return policies, shipping terms, warranty
21+
* coverage, and terms of service to produce risk data including risk level
22+
* classifications, buyer protection scores, and key findings.
23+
*
24+
* The agent should use this data alongside other context (purchase amount, buyer
25+
* risk tolerance, item category) to make its own purchase decisions.
2226
*
2327
* This is a walletless action provider — no wallet is required.
2428
*/
@@ -36,29 +40,27 @@ export class PolicyCheckActionProvider extends ActionProvider {
3640
}
3741

3842
/**
39-
* Analyze seller policies to assess buyer protection before a purchase.
43+
* Get seller policy risk data to inform purchase decisions.
4044
*
4145
* @param args - The input arguments (policyText and/or sellerUrl).
42-
* @returns A string containing the risk assessment with score, findings, and recommendation.
46+
* @returns A string containing the risk data with scores, findings, and factual summary.
4347
*/
4448
@CreateAction({
4549
name: "policycheck_analyze",
46-
description: `Analyze an e-commerce seller's policies to assess buyer protection risk BEFORE making a purchase. Returns a risk level (low/medium/high/critical), buyer protection score (0-100), key findings about return policy, shipping, warranty, and terms, and a recommendation on whether to proceed.
47-
48-
Use this action whenever an agent is about to complete a purchase from an online store. Provide either the full policy text or the seller's URL.
50+
description: `Get seller policy risk data to inform purchase decisions. Analyzes return policies, shipping terms, warranty coverage, and terms of service. Returns risk level (low/medium/high/critical), buyer protection score (0-100), key findings about specific policy issues, and a factual summary. The agent should use this data alongside other context (purchase amount, buyer risk tolerance, item category) to make its own purchase decision.
4951
5052
Inputs:
5153
- policyText: The full text of the seller's policy to analyze. Provide this OR sellerUrl.
5254
- sellerUrl: The URL of the e-commerce store. The service will find and analyze policies automatically. Provide this OR policyText.
5355
54-
Example risk factors detected:
55-
- No return policy or very short return windows
56-
- Binding arbitration clauses that waive right to class action
57-
- Liability caps that limit seller responsibility
56+
Risk factors detected include:
57+
- Missing or restrictive return policies
58+
- Binding arbitration clauses affecting dispute resolution options
59+
- Liability caps limiting seller responsibility
5860
- Missing warranty information
59-
- Restocking fees or buyer-pays-return-shipping policies
61+
- Restocking fees or buyer-pays-return-shipping terms
6062
61-
Important: If the buyer protection score is below 50, recommend the user reconsider the purchase.`,
63+
A buyer protection score below 50 indicates limited policy protections. Binding arbitration clauses affect dispute resolution options. Missing return policies are notable risk factors.`,
6264
schema: PolicyCheckAnalyzeSchema,
6365
})
6466
async analyze(args: z.infer<typeof PolicyCheckAnalyzeSchema>): Promise<string> {
@@ -137,8 +139,7 @@ Important: If the buyer protection score is below 50, recommend the user reconsi
137139
riskLevel: analysisData.riskLevel,
138140
buyerProtectionScore: analysisData.buyerProtectionScore,
139141
keyFindings: analysisData.keyFindings,
140-
recommendation: analysisData.recommendation,
141-
summary: summaryText || undefined,
142+
summary: (analysisData.summary as string) || summaryText || undefined,
142143
analyzedUrl: args.sellerUrl || "direct text analysis",
143144
});
144145
}
@@ -172,9 +173,7 @@ Important: If the buyer protection score is below 50, recommend the user reconsi
172173
*/
173174
@CreateAction({
174175
name: "policycheck_check_url",
175-
description: `Quick check of an e-commerce seller's URL to assess buyer protection before purchasing. Provide the store URL and the service will find and analyze the seller's policies automatically. Returns risk level, buyer protection score, and key findings.
176-
177-
Use this as a fast pre-purchase verification step when you have a seller's URL.
176+
description: `Quick seller policy risk check by URL. Provide the store URL and the service will find and analyze the seller's policies automatically. Returns risk level, buyer protection score, key findings, and a factual summary.
178177
179178
Inputs:
180179
- sellerUrl: The URL of the e-commerce store to check (e.g., 'https://example-store.com').`,

0 commit comments

Comments
 (0)