Repository navigation
Add logfire-datasets skill for creating hosted datasets - #74
Draft
duncankmckinnon wants to merge 5 commits into
Draft
duncankmckinnon wants to merge 5 commits into
duncankmckinnon wants to merge 5 commits into
Conversation
The Logfire MCP server has no dataset tools, so agents had no guidance for creating hosted datasets. This locally owned skill covers configuring an API key with the datasets scopes, discovering and extracting cases from traces with SQL, and writing a Python retrieval and upload script against logfire.experimental.api_client. Registers the skill in the ownership manifest and mirrors it to skills/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Building a real dataset from agent-tracing showed the query API rejects API
keys ("401 Invalid read token"), so script-side queries need a separate read
token. Step 1 now defines a credential handoff: LOGFIRE_API_KEY for the
datasets API and LOGFIRE_READ_TOKEN for queries, resolved from the
environment or a gitignored .env, with an MCP-export fallback when no read
token is available.
Also documents scrubbed values, sub-agent runs, Claude Code/Codex session
spans, md5 checks for MCP exports, and that upserts bump case versions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The skill is general purpose, so it should not presume particular instrumentation. Removes the Pydantic AI attribute tables, Claude Code/Codex session layouts, and sub-agent span names in favour of a discovery-driven method: inventory spans, list and sample attributes, relate spans through the trace tree, and confirm the candidate selection with the user before extracting. Keeps only Logfire platform facts (records columns, SQL engine rules, scrubbing). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
duncankmckinnon
marked this pull request as ready for review
October 18, 2026 00:41
- Dedupe keeps one whole row per input instead of aggregating trace_id and span_id separately, which could pair ids from different runs. - Read token: keep the Logfire CLI route via the shared auth reference, but capture `read-tokens create` output straight into .env so it is never printed; don't use --save, whose location scripts don't read. - Credential checks report each variable's source (environment, .env, empty line, missing), accept `export`-prefixed lines, flag environment values that may belong to another project, and never add a duplicate .env line. - Confirm the API key's project via project_id before adding cases. - Detect partial scrubbing inside JSON values. - Push snippet no longer passes schemas or a literal `...`; push_dataset warning now covers schemas and description. - Narrow the description to hosted datasets to avoid overlapping logfire-evals; split multi-statement SQL blocks for single-query tools. - CONTRIBUTING: describe logfire-datasets auth correctly; add its mirror to .macroscope/ignore.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
duncankmckinnon
marked this pull request as draft
October 18, 2026 01:05
Author
|
Moving ownership of Back to draft until it merges. Then, per CONTRIBUTING's ordering rule, this PR becomes the ownership-map change: point |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Adds a locally owned
logfire-datasetsskill. The Logfire MCP server has no dataset tools, so agents currently have no guidance for creating hosted datasets in Datasets & Experiments. The skill walks an agent through:project:read_datasets,project:write_datasets) for the datasets API, and a read token for script-side queries. The read token can come from the UI or be minted with the Logfire CLI through the sharedauth.mdflow, aslogfire-evalsdoes; the CLI output is captured straight into.env. Includes a fixed handoff: credentials live in a gitignored.env, and the agent never sees the values. Read-only checks, plus aproject_idcheck, run before any write.expected_output.Running evaluations against a dataset is left to
logfire-evals.Files
plugins/logfire/skills/logfire-datasets/SKILL.md: the workflow.references/trace-extraction.md: a discovery-driven method for extraction, covering engine rules, the discovery sequence, how to read what discovery shows, scrubbed values, and choosing rows. It makes no assumptions about span names, attribute keys, or payload shapes.references/python-scripts.md: guidance for writing the script withlogfire.query_clientandlogfire.experimental.api_client. Covers credentials, stages, the case dict format, local validation, push behaviour, reading datasets back, and async clients.scripts/logfire-skill-sources.jsonas owned bypydantic/skills, mirrored toskills/logfire-datasets/, and the ownership test's skill count bumped from 9 to 10. READMEs and CONTRIBUTING updated.Design notes
add_cases()with dicts on an existing dataset, notpush_dataset(). Only the dict form carriessource_trace_id/source_span_id, so cases link back to their traces.push_dataset()also replaces dataset-level evaluators that may have been configured in the UI.span_id) make re-runs upsert instead of duplicate.logfire4.39 and 5.2.0 sources (the API is the same in both) and against valcore's working hosted-dataset integration.Testing
bash scripts/check-skill-sync.shpython3 -m unittest discover -s scripts/tests(7 tests pass)claude plugin validate .bazaar-pr-reviewsdataset (8 code-review cases) from delegated sub-agent runs in a real project and pushed it. Hosted content and trace links were verified against the source by md5. A re-push left the count at 8.What the end-to-end test changed
401 Invalid read token), even withproject:read, so script-side queries need a read token. The credentials step now distinguishesLOGFIRE_API_KEY(datasets) fromLOGFIRE_READ_TOKEN(queries). It also documents an MCP-export fallback with md5 integrity checks for small sets..env, because a variable the user exports after the agent session starts never reaches the agent's commands. Scripts look for.envin the working directory or project root.[Scrubbed due to '...'], which removed 7 of 15 candidate rows), relating spans through parent/child joins, values that share boilerplate and defeat naive keyword filters, and confirming wording-based filters with the user. Format-specific tables for particular instrumentation were removed so the skill stays general purpose.versioneven when its content is unchanged.Follow-up (upstream)
This PR narrows the
logfire-datasetsdescription to hosted datasets so it doesn't overlaplogfire-evals. Routing setup requests tologfire-datasets, and pointinglogfire-evals' hosted-dataset section at it, needs changes outside this repo, in two places:pydantic/logfire(logfire-sdk/logfire/.agents/skills/logfire-evalsandlogfire-setup): the public owners this repo syncs from, perscripts/logfire-skill-sources.json.pydantic/logfire-cli(skills/logfire-evals,skills/logfire-setup): the release-bound CLI adaptations bundled intologfire wizard/logfire skill, which are ported by hand rather than synced.🤖 Generated with Claude Code