Skip to content

Commit 86e197f

Browse files
committed
sampling
1 parent 6a94a41 commit 86e197f

File tree

5 files changed

+1779
-448
lines changed

5 files changed

+1779
-448
lines changed

exercises/03.sampling/01.problem.simple/README.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ prompt for the LLM in the next step.
1111

1212
**Here's what you'll do:**
1313

14+
- When the create_entry tool is called, call the `suggestTagsSampling` function
15+
with the agent and the createdEntry.id.
16+
- We don't want to wait for the sampling function to finish so instead of "await"
17+
use "void" which effectively ignores the promise.
18+
- First check if the client supports sampling. If it does, proceed with the
19+
sampling request.
1420
- Implement a function that sends a sampling request to the client using
1521
`agent.server.server.createMessage` (the `server.server` thing is funny, but
1622
our MCP server manages an internal server and that's what we're accessing).
@@ -22,10 +28,7 @@ prompt for the LLM in the next step.
2228

2329
And don't forget to call it when the user creates a new journal entry!
2430

25-
> **Note:** Before making a sampling request, you should check whether the
26-
> client supports sampling. You can do this with
27-
> `agent.server.server.getClientCapabilities()`. If sampling is not supported,
28-
> you should skip the sampling request. For example:
31+
Here's an example of how to check if the client supports sampling:
2932

3033
```ts
3134
const clientCapabilities = agent.server.server.getClientCapabilities()

0 commit comments

Comments
 (0)