mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Silence ty deprecation diagnostics and drop stale sampling doc mentions
This commit is contained in:
parent
1a43a3b8e9
commit
90f2e190d0
6 changed files with 15 additions and 22 deletions
|
|
@ -238,7 +238,7 @@ Custom spans are most useful around work that is expensive or hard to debug:
|
|||
- External calls such as databases, vector stores, HTTP APIs, or queue operations
|
||||
- Multi-step tool logic where one stage dominates latency
|
||||
- Prompt or resource generation that fans out to other systems
|
||||
- Sampling calls made from inside a tool via `ctx.sample(...)`
|
||||
- LLM calls a tool makes to a model provider
|
||||
|
||||
Avoid wrapping every small helper function or simple in-memory transformation. That usually adds noise without making traces easier to interpret.
|
||||
|
||||
|
|
@ -286,9 +286,9 @@ async def docs_resource(slug: str) -> str:
|
|||
return await load_doc(slug)
|
||||
```
|
||||
|
||||
### Sampling calls inside tools
|
||||
### LLM calls inside tools
|
||||
|
||||
If your tool uses `ctx.sample(...)`, keep the LLM work nested under the tool span so traces show both application logic and model latency together.
|
||||
A tool that [calls an LLM directly](/servers/sampling) should keep the model work nested under the tool span, so traces show application logic and model latency together.
|
||||
|
||||
For providers with their own OTEL integrations, prefer enabling that instrumentation rather than manually creating a span around every model call. For example, if you use Google GenAI, `logfire.instrument_google_genai()` will emit child spans with token and request metadata under the active FastMCP tool span.
|
||||
|
||||
|
|
|
|||
|
|
@ -1063,15 +1063,9 @@ async def process_data(data_uri: str, ctx: Context) -> dict:
|
|||
|
||||
# Report progress
|
||||
await ctx.report_progress(progress=50, total=100)
|
||||
|
||||
# Example request to the client's LLM for help
|
||||
summary = await ctx.sample(f"Summarize this in 10 words: {data[:200]}")
|
||||
|
||||
|
||||
await ctx.report_progress(progress=100, total=100)
|
||||
return {
|
||||
"length": len(data),
|
||||
"summary": summary.text
|
||||
}
|
||||
return {"length": len(data)}
|
||||
```
|
||||
|
||||
The Context object provides access to:
|
||||
|
|
@ -1079,7 +1073,6 @@ The Context object provides access to:
|
|||
- **Logging**: `ctx.debug()`, `ctx.info()`, `ctx.warning()`, `ctx.error()`
|
||||
- **Progress Reporting**: `ctx.report_progress(progress, total)`
|
||||
- **Resource Access**: `ctx.read_resource(uri)`
|
||||
- **LLM Sampling**: `ctx.sample(...)`
|
||||
- **Request Information**: `ctx.request_id`, `ctx.client_id`
|
||||
|
||||
For full documentation on the Context object and all its capabilities, see the [Context documentation](/servers/context).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue