feat: add tag filtering to traces command#27
Open
Harry Nguyen (Hazzng) wants to merge 2 commits into
Open
Conversation
- Introduced `--tag` option for filtering traces by specified tags, supporting both OR and AND logic with `--all-tags`. - Updated README with usage examples for tag filtering.
4de041a to
8077dbd
Compare
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.
feat(tags): add tag-based trace filtering to traces command
Summary
Add the ability to filter traces by tag(s) using
--tag/-toption on thetracescommand. This enables users to fetch traces that have been tagged in LangSmith, . Add the output handling for fetching traces so if message is [] then fetch all output to be compatible with more agent outputs (not all agents just output messages)Problem
Users needed a way to fetch traces by their tags from LangSmith. The existing
tracescommand only supported time-based filtering (--last-n-minutes,--since) but had no way to filter by tags assigned to traces.Solution
Extended the
tracescommand with:--tag/-t TAGoption (can be repeated for multiple tags)fetch_traces_by_tags()fetcher functionoutputsdict for custom agents without standard message formatChanges
src/langsmith_cli/fetchers.pyfetch_traces_by_tags()function (+147 lines); Fixed message extraction to fall back to full outputs for custom agentssrc/langsmith_cli/cli.py--tagoptions; Added tag filtering logic for both directory and stdout modestests/test_fetchers.pyTestFetchTracesByTagsclass with 6 unit teststests/test_cli.pyTestTracesCommandTagOptionclass with 5 CLI teststests/conftest.pyREADME.mdUsage Examples
Testing
uv run pytest tests/ -v)20251225_023631)Breaking Changes
None - this is a purely additive feature.