feat(examples): Add supplier reliability agent for bounty #181#1611
feat(examples): Add supplier reliability agent for bounty #181#1611anzzyspeaksgit wants to merge 3 commits into
Conversation
Greptile SummaryThis PR adds a new However, the supporting files (README, all three test files, and
Confidence Score: 1/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as HTTP Client
participant Hono as Hono Adapter
participant Paywall as x402 Paywall
participant Handler as score handler
participant AP2 as AP2 Manifest
Client->>Hono: POST /entrypoints/score/invoke<br/>{supplierId: "acme-corp"}
Hono->>Paywall: Check payment header
alt No payment header
Paywall-->>Client: 402 Payment Required
else Valid payment
Paywall->>Handler: {input: {supplierId}}
Handler->>Handler: Hash supplierId → score [30–99]
Handler->>Handler: Map score → grade (A/B/C/D/F)
Handler->>Handler: Derive riskFactors[]
Handler-->>Hono: {output: {supplierId, score, grade, riskFactors}}
Hono-->>Client: 200 OK + JSON
end
Client->>AP2: GET /.well-known/agent-card.json
AP2-->>Client: Agent card (roles: merchant)
Prompt To Fix All With AIThis is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/README.md
Line: 1-5
Comment:
**README is copied from kitchen-sink without modification**
The entire content of this file describes the `kitchen-sink` example — it starts with `# Kitchen-Sink Example`, lists capabilities that don't exist in the supplier-reliability-agent (A2A, scheduler, stream, analytics-report, ask), references the wrong file structure (`src/kitchen-sink/`), and links to wrong endpoints. A developer following this README will be completely misled about what the supplier-reliability-agent actually does.
The README should document the `supplier-reliability-agent`: the single `score` entrypoint, the `supplierId` input, the `score`/`grade`/`riskFactors` output, and the 0.0003 USDC price.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/__tests__/a2a.test.ts
Line: 1-10
Comment:
**Test file is an exact copy of kitchen-sink a2a test**
This file imports `createKitchenSinkAgent` and `createClientAgent` — functions that are not exported from the supplier-reliability-agent module — so the tests will fail immediately with an import/resolution error.
More fundamentally, the `supplier-reliability-agent` does not include the `a2a()` extension (see `agent.ts`), so A2A functionality is not applicable to this agent. These tests should either be removed entirely or replaced with tests that are relevant to the supplier-reliability-agent's actual capabilities (the paid `score` entrypoint).
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/__tests__/agent.test.ts
Line: 1-7
Comment:
**Test imports wrong factory function and asserts wrong extensions**
The test imports `createKitchenSinkAgent` (line 3), which does not exist in this module. It should import `createSupplierReliabilityAgent` from `../agent`.
Additionally, the assertions on line 6 check for `a2a` and `scheduler` — neither of which is wired in `agent.ts` for the supplier-reliability-agent. The correct set of always-present extensions for this agent is: `payments`, `analytics`, and `ap2`.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/__tests__/entrypoints.test.ts
Line: 1-12
Comment:
**Test file exercises kitchen-sink entrypoints that do not exist in this agent**
The `registerEntrypoints` imported from `../entrypoints` only registers a single `score` entrypoint. However, this test file calls `echo`, `summarize`, `analytics-report`, `scheduler-status`, `ask`, and `stream` — none of which exist here. All of these test cases will fail with 404 or runtime errors.
The test should be replaced with a test of the actual `score` entrypoint, e.g. verifying that supplying a `supplierId` returns a `score` (number in [30, 99]), a `grade` (`A`–`F`), and a `riskFactors` array, and that the response is deterministic for the same input.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/client.ts
Line: 1-57
Comment:
**Client file is copied from kitchen-sink and is not relevant to this agent**
`client.ts` creates an agent named `kitchen-sink-client` (line 15), references the `kitchen-sink` agent in its description (line 16), and contains `runA2ADemo` which calls the `echo` skill of the kitchen-sink agent (line 42). The supplier-reliability-agent does not use `a2a()` (see `agent.ts`), so a client agent that calls its A2A skills makes no sense here.
This file should either be removed or replaced with a meaningful client example that invokes the `score` entrypoint via a standard HTTP call, which aligns with how the agent is actually used.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/entrypoints.ts
Line: 50-52
Comment:
**Score range does not match the comment**
The comment says "Score between 30 and 100", but the formula `(Math.abs(hash) % 70) + 30` produces values in the range **[30, 99]** inclusive — a score of exactly 100 is never produced because `% 70` yields 0–69.
The Zod output schema allows `z.number().min(0).max(100)`, so 100 is a valid output according to the type, but the implementation never reaches it. Either the comment should be corrected to say "between 30 and 99", or the formula should be changed to `% 71` to include 100 as a possible value.
```suggestion
const score = (Math.abs(hash) % 71) + 30; // Score between 30 and 100 (inclusive)
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/index.ts
Line: 19-21
Comment:
**Missing smoke test entry required by PR completion checklist**
Per `AGENTS.md` (PR Completion Checklist section): "If the PR adds or modifies SDK surface area (new extensions, entrypoints, or config patterns), add a corresponding smoke test in `packages/examples/src/__tests__/smoke.test.ts`."
This PR adds a new example with a paid entrypoint (`score`) but no smoke test was added to `packages/examples/src/__tests__/smoke.test.ts`. A minimal smoke test should verify that the agent builds, the server boots, the agent card is valid, and the `score` entrypoint returns a `402` without a payment header (since it has `price: '300'`).
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "feat(examples): Add ..." |
| # Kitchen-Sink Example | ||
|
|
||
| Demonstrates all major Lucid Agents SDK capabilities in a single runnable project — two agents working together. | ||
|
|
||
| ## What It Shows |
There was a problem hiding this comment.
README is copied from kitchen-sink without modification
The entire content of this file describes the kitchen-sink example — it starts with # Kitchen-Sink Example, lists capabilities that don't exist in the supplier-reliability-agent (A2A, scheduler, stream, analytics-report, ask), references the wrong file structure (src/kitchen-sink/), and links to wrong endpoints. A developer following this README will be completely misled about what the supplier-reliability-agent actually does.
The README should document the supplier-reliability-agent: the single score entrypoint, the supplierId input, the score/grade/riskFactors output, and the 0.0003 USDC price.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/README.md
Line: 1-5
Comment:
**README is copied from kitchen-sink without modification**
The entire content of this file describes the `kitchen-sink` example — it starts with `# Kitchen-Sink Example`, lists capabilities that don't exist in the supplier-reliability-agent (A2A, scheduler, stream, analytics-report, ask), references the wrong file structure (`src/kitchen-sink/`), and links to wrong endpoints. A developer following this README will be completely misled about what the supplier-reliability-agent actually does.
The README should document the `supplier-reliability-agent`: the single `score` entrypoint, the `supplierId` input, the `score`/`grade`/`riskFactors` output, and the 0.0003 USDC price.
How can I resolve this? If you propose a fix, please make it concise.| import { waitForTask } from '@lucid-agents/a2a'; | ||
| import { createAgentApp } from '@lucid-agents/hono'; | ||
| import { afterAll, beforeAll, describe, expect, it } from 'bun:test'; | ||
|
|
||
| import { createKitchenSinkAgent } from '../agent'; | ||
| import { createClientAgent } from '../client'; | ||
| import { registerEntrypoints } from '../entrypoints'; | ||
|
|
||
| const PORT = 19001; | ||
| const CLIENT_PORT = 19002; |
There was a problem hiding this comment.
Test file is an exact copy of kitchen-sink a2a test
This file imports createKitchenSinkAgent and createClientAgent — functions that are not exported from the supplier-reliability-agent module — so the tests will fail immediately with an import/resolution error.
More fundamentally, the supplier-reliability-agent does not include the a2a() extension (see agent.ts), so A2A functionality is not applicable to this agent. These tests should either be removed entirely or replaced with tests that are relevant to the supplier-reliability-agent's actual capabilities (the paid score entrypoint).
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/__tests__/a2a.test.ts
Line: 1-10
Comment:
**Test file is an exact copy of kitchen-sink a2a test**
This file imports `createKitchenSinkAgent` and `createClientAgent` — functions that are not exported from the supplier-reliability-agent module — so the tests will fail immediately with an import/resolution error.
More fundamentally, the `supplier-reliability-agent` does not include the `a2a()` extension (see `agent.ts`), so A2A functionality is not applicable to this agent. These tests should either be removed entirely or replaced with tests that are relevant to the supplier-reliability-agent's actual capabilities (the paid `score` entrypoint).
How can I resolve this? If you propose a fix, please make it concise.| import { describe, expect, it } from 'bun:test'; | ||
|
|
||
| import { createKitchenSinkAgent } from '../agent'; | ||
|
|
||
| describe('createKitchenSinkAgent', () => { | ||
| it('always-wired extensions (a2a, analytics, payments, scheduler, ap2)', async () => { | ||
| const agent = await createKitchenSinkAgent(); |
There was a problem hiding this comment.
Test imports wrong factory function and asserts wrong extensions
The test imports createKitchenSinkAgent (line 3), which does not exist in this module. It should import createSupplierReliabilityAgent from ../agent.
Additionally, the assertions on line 6 check for a2a and scheduler — neither of which is wired in agent.ts for the supplier-reliability-agent. The correct set of always-present extensions for this agent is: payments, analytics, and ap2.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/__tests__/agent.test.ts
Line: 1-7
Comment:
**Test imports wrong factory function and asserts wrong extensions**
The test imports `createKitchenSinkAgent` (line 3), which does not exist in this module. It should import `createSupplierReliabilityAgent` from `../agent`.
Additionally, the assertions on line 6 check for `a2a` and `scheduler` — neither of which is wired in `agent.ts` for the supplier-reliability-agent. The correct set of always-present extensions for this agent is: `payments`, `analytics`, and `ap2`.
How can I resolve this? If you propose a fix, please make it concise.| import { a2a } from '@lucid-agents/a2a'; | ||
| import { analytics } from '@lucid-agents/analytics'; | ||
| import { createAgent } from '@lucid-agents/core'; | ||
| import { createAgentApp } from '@lucid-agents/hono'; | ||
| import { http } from '@lucid-agents/http'; | ||
| import { payments, paymentsFromEnv } from '@lucid-agents/payments'; | ||
| import { scheduler } from '@lucid-agents/scheduler'; | ||
| import { beforeAll, describe, expect, it, mock } from 'bun:test'; | ||
|
|
||
| import { registerEntrypoints } from '../entrypoints'; | ||
|
|
||
| // POST to an entrypoint via app.fetch — no network required |
There was a problem hiding this comment.
Test file exercises kitchen-sink entrypoints that do not exist in this agent
The registerEntrypoints imported from ../entrypoints only registers a single score entrypoint. However, this test file calls echo, summarize, analytics-report, scheduler-status, ask, and stream — none of which exist here. All of these test cases will fail with 404 or runtime errors.
The test should be replaced with a test of the actual score entrypoint, e.g. verifying that supplying a supplierId returns a score (number in [30, 99]), a grade (A–F), and a riskFactors array, and that the response is deterministic for the same input.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/__tests__/entrypoints.test.ts
Line: 1-12
Comment:
**Test file exercises kitchen-sink entrypoints that do not exist in this agent**
The `registerEntrypoints` imported from `../entrypoints` only registers a single `score` entrypoint. However, this test file calls `echo`, `summarize`, `analytics-report`, `scheduler-status`, `ask`, and `stream` — none of which exist here. All of these test cases will fail with 404 or runtime errors.
The test should be replaced with a test of the actual `score` entrypoint, e.g. verifying that supplying a `supplierId` returns a `score` (number in [30, 99]), a `grade` (`A`–`F`), and a `riskFactors` array, and that the response is deterministic for the same input.
How can I resolve this? If you propose a fix, please make it concise.| import { a2a, fetchAgentCard, findSkill, waitForTask } from '@lucid-agents/a2a'; | ||
| import { createAgent } from '@lucid-agents/core'; | ||
| import { http } from '@lucid-agents/http'; | ||
|
|
||
| /** | ||
| * Creates a minimal client agent with the HTTP transport and A2A extension. | ||
| * Demonstrates that an agent does not need all capabilities — it can be | ||
| * purpose-built for a single role (here: calling other agents via A2A). | ||
| * The http() extension is required for createAgentApp() to serve its own card. | ||
| */ | ||
| export async function createClientAgent() { | ||
| return createAgent({ | ||
| name: 'kitchen-sink-client', | ||
| version: '1.0.0', | ||
| description: 'Client agent that demonstrates A2A calls to the kitchen-sink', | ||
| }) | ||
| .use(http()) | ||
| .use(a2a()) | ||
| .build(); | ||
| } | ||
|
|
||
| /** | ||
| * One-shot A2A demo: discovers the kitchen-sink, calls its echo entrypoint, | ||
| * and logs the result. Called from index.ts on startup. | ||
| */ | ||
| export async function runA2ADemo(kitchenSinkUrl: string) { | ||
| const agent = await createClientAgent(); | ||
| const a2aRuntime = agent.a2a; | ||
| if (!a2aRuntime) throw new Error('A2A runtime not available on client agent'); | ||
|
|
||
| console.log('[client] Fetching kitchen-sink agent card...'); | ||
| const card = await fetchAgentCard(kitchenSinkUrl); | ||
| console.log(`[client] Found: ${card.name} v${card.version}`); | ||
|
|
||
| const echoSkill = findSkill(card, 'echo'); | ||
| if (!echoSkill) | ||
| throw new Error('echo skill not found on kitchen-sink agent card'); | ||
| console.log(`[client] Discovered skill: ${echoSkill.id}`); | ||
|
|
||
| console.log('[client] Sending A2A task...'); | ||
| const { taskId } = await a2aRuntime.client.sendMessage(card, 'echo', { | ||
| text: 'Hello from the client agent!', | ||
| }); | ||
|
|
||
| const task = await waitForTask(a2aRuntime.client, card, taskId); | ||
| if (task.status !== 'completed') { | ||
| throw new Error( | ||
| `A2A task ${task.status}: ${String(task.error?.message ?? 'unknown')}` | ||
| ); | ||
| } | ||
|
|
||
| const output = task.result?.output as | ||
| | { text: string; timestamp: string } | ||
| | undefined; | ||
| console.log(`[client] Result: ${JSON.stringify(output)}`); | ||
| return output; | ||
| } |
There was a problem hiding this comment.
Client file is copied from kitchen-sink and is not relevant to this agent
client.ts creates an agent named kitchen-sink-client (line 15), references the kitchen-sink agent in its description (line 16), and contains runA2ADemo which calls the echo skill of the kitchen-sink agent (line 42). The supplier-reliability-agent does not use a2a() (see agent.ts), so a client agent that calls its A2A skills makes no sense here.
This file should either be removed or replaced with a meaningful client example that invokes the score entrypoint via a standard HTTP call, which aligns with how the agent is actually used.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/client.ts
Line: 1-57
Comment:
**Client file is copied from kitchen-sink and is not relevant to this agent**
`client.ts` creates an agent named `kitchen-sink-client` (line 15), references the `kitchen-sink` agent in its description (line 16), and contains `runA2ADemo` which calls the `echo` skill of the kitchen-sink agent (line 42). The supplier-reliability-agent does not use `a2a()` (see `agent.ts`), so a client agent that calls its A2A skills makes no sense here.
This file should either be removed or replaced with a meaningful client example that invokes the `score` entrypoint via a standard HTTP call, which aligns with how the agent is actually used.
How can I resolve this? If you propose a fix, please make it concise.| } | ||
|
|
||
| const score = (Math.abs(hash) % 70) + 30; // Score between 30 and 100 |
There was a problem hiding this comment.
Score range does not match the comment
The comment says "Score between 30 and 100", but the formula (Math.abs(hash) % 70) + 30 produces values in the range [30, 99] inclusive — a score of exactly 100 is never produced because % 70 yields 0–69.
The Zod output schema allows z.number().min(0).max(100), so 100 is a valid output according to the type, but the implementation never reaches it. Either the comment should be corrected to say "between 30 and 99", or the formula should be changed to % 71 to include 100 as a possible value.
| } | |
| const score = (Math.abs(hash) % 70) + 30; // Score between 30 and 100 | |
| const score = (Math.abs(hash) % 71) + 30; // Score between 30 and 100 (inclusive) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/entrypoints.ts
Line: 50-52
Comment:
**Score range does not match the comment**
The comment says "Score between 30 and 100", but the formula `(Math.abs(hash) % 70) + 30` produces values in the range **[30, 99]** inclusive — a score of exactly 100 is never produced because `% 70` yields 0–69.
The Zod output schema allows `z.number().min(0).max(100)`, so 100 is a valid output according to the type, but the implementation never reaches it. Either the comment should be corrected to say "between 30 and 99", or the formula should be changed to `% 71` to include 100 as a possible value.
```suggestion
const score = (Math.abs(hash) % 71) + 30; // Score between 30 and 100 (inclusive)
```
How can I resolve this? If you propose a fix, please make it concise.| import { createAgentApp } from '@lucid-agents/hono'; | ||
| import { createSupplierReliabilityAgent } from './agent'; | ||
| import { registerEntrypoints } from './entrypoints'; |
There was a problem hiding this comment.
Missing smoke test entry required by PR completion checklist
Per AGENTS.md (PR Completion Checklist section): "If the PR adds or modifies SDK surface area (new extensions, entrypoints, or config patterns), add a corresponding smoke test in packages/examples/src/__tests__/smoke.test.ts."
This PR adds a new example with a paid entrypoint (score) but no smoke test was added to packages/examples/src/__tests__/smoke.test.ts. A minimal smoke test should verify that the agent builds, the server boots, the agent card is valid, and the score entrypoint returns a 402 without a payment header (since it has price: '300').
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/examples/src/supplier-reliability-agent/index.ts
Line: 19-21
Comment:
**Missing smoke test entry required by PR completion checklist**
Per `AGENTS.md` (PR Completion Checklist section): "If the PR adds or modifies SDK surface area (new extensions, entrypoints, or config patterns), add a corresponding smoke test in `packages/examples/src/__tests__/smoke.test.ts`."
This PR adds a new example with a paid entrypoint (`score`) but no smoke test was added to `packages/examples/src/__tests__/smoke.test.ts`. A minimal smoke test should verify that the agent builds, the server boots, the agent card is valid, and the `score` entrypoint returns a `402` without a payment header (since it has `price: '300'`).
How can I resolve this? If you propose a fix, please make it concise.|
Thank you for the feedback, @greptile-apps. I've pushed a fix that corrects the copy-paste errors from the kitchen-sink example. The tests, README, and unused files have all been updated for the supplier reliability agent. |
|
Great work! The fixes look good. All the copy-paste references have been cleaned up: ✅ Tests now verify the correct extensions for a supplier reliability agent (payments, analytics, ap2, but no a2a) The PR looks ready to merge. Nice job addressing the feedback! |
|
Hi @daydreamsai / maintainers, since all the feedback has been addressed and this is ready, could this be merged? Thanks! |
|
Thank you again! One final update to complete the |
Summary
This PR submits a solution for the bounty in issue #181. It adds a new example agent, the 'Supplier Reliability Agent', to the directory.
This implementation provides a clean, focused example of a paid data agent built with the Lucid Agents SDK, making it a valuable resource for other developers in addition to fulfilling the bounty requirements.
Problem
Closes #181
Solution
Testing
This PR was created with AI assistance.