langfuse-agent-cli 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- langfuse_agent_cli-0.3.0/LICENSE +21 -0
- langfuse_agent_cli-0.3.0/PKG-INFO +235 -0
- langfuse_agent_cli-0.3.0/README.md +207 -0
- langfuse_agent_cli-0.3.0/langfuse_agent_cli.egg-info/PKG-INFO +235 -0
- langfuse_agent_cli-0.3.0/langfuse_agent_cli.egg-info/SOURCES.txt +40 -0
- langfuse_agent_cli-0.3.0/langfuse_agent_cli.egg-info/dependency_links.txt +1 -0
- langfuse_agent_cli-0.3.0/langfuse_agent_cli.egg-info/entry_points.txt +2 -0
- langfuse_agent_cli-0.3.0/langfuse_agent_cli.egg-info/requires.txt +5 -0
- langfuse_agent_cli-0.3.0/langfuse_agent_cli.egg-info/top_level.txt +1 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/__init__.py +2 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/__main__.py +7 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/cli.py +197 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/client.py +196 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/__init__.py +1 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/auth.py +93 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/dataset.py +37 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/doctor.py +90 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/help_map.py +167 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/prompt.py +123 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/score.py +24 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/setup.py +101 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/commands/trace.py +83 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/config.py +187 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/formatters/__init__.py +15 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/formatters/agent.py +95 -0
- langfuse_agent_cli-0.3.0/langfuse_cli/formatters/timeline.py +50 -0
- langfuse_agent_cli-0.3.0/pyproject.toml +58 -0
- langfuse_agent_cli-0.3.0/setup.cfg +4 -0
- langfuse_agent_cli-0.3.0/tests/test_agent_formatters.py +57 -0
- langfuse_agent_cli-0.3.0/tests/test_cli_basics.py +154 -0
- langfuse_agent_cli-0.3.0/tests/test_cli_commands.py +192 -0
- langfuse_agent_cli-0.3.0/tests/test_cli_trace.py +148 -0
- langfuse_agent_cli-0.3.0/tests/test_client.py +81 -0
- langfuse_agent_cli-0.3.0/tests/test_config.py +129 -0
- langfuse_agent_cli-0.3.0/tests/test_docs.py +45 -0
- langfuse_agent_cli-0.3.0/tests/test_help.py +42 -0
- langfuse_agent_cli-0.3.0/tests/test_live.py +92 -0
- langfuse_agent_cli-0.3.0/tests/test_output_safety.py +47 -0
- langfuse_agent_cli-0.3.0/tests/test_output_summary.py +175 -0
- langfuse_agent_cli-0.3.0/tests/test_prompt_compile.py +25 -0
- langfuse_agent_cli-0.3.0/tests/test_setup.py +296 -0
- langfuse_agent_cli-0.3.0/tests/test_timeline.py +36 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tarkeshwar Narayan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langfuse-agent-cli
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Agent-oriented CLI and skill for Langfuse traces, prompts, datasets and scores.
|
|
5
|
+
Author-email: Tarkeshwar Narayan <122815908+tns15june@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/tns15june/langfuse-agent-cli
|
|
8
|
+
Project-URL: Repository, https://github.com/tns15june/langfuse-agent-cli
|
|
9
|
+
Project-URL: Issues, https://github.com/tns15june/langfuse-agent-cli/issues
|
|
10
|
+
Keywords: langfuse,llm,observability,agent,cli,skills
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: System :: Monitoring
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests>=2.28.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# langfuse-agent-cli (`lf`)
|
|
30
|
+
|
|
31
|
+
Command-line access to [Langfuse](https://langfuse.com) traces, prompts, datasets and scores, shaped
|
|
32
|
+
for AI coding agents: JSON by default (`--compact` trims it), failing traces with their error messages
|
|
33
|
+
in one command, a trace as a tree, and an agent skill that teaches the commands.
|
|
34
|
+
|
|
35
|
+
> **Status: prototype.** Langfuse ships an official CLI,
|
|
36
|
+
> [`@langfuse/cli`](https://github.com/langfuse/langfuse-cli), which covers the whole API, and official
|
|
37
|
+
> agent skills, [`langfuse/skills`](https://github.com/langfuse/skills). This project tries out
|
|
38
|
+
> agent-oriented features on the same API.
|
|
39
|
+
> [RFC.md](https://github.com/tns15june/langfuse-agent-cli/blob/main/RFC.md) describes which of them it
|
|
40
|
+
> proposes upstream.
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
- Python 3.10 or newer
|
|
45
|
+
- Langfuse v4, self-hosted or Cloud. The trace commands read `/api/public/v2/observations`;
|
|
46
|
+
`lf doctor` reports if a server does not have it.
|
|
47
|
+
- Node.js 22.20 or newer, only for installing the agent skill
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pipx install langfuse-agent-cli # or: uv tool install langfuse-agent-cli
|
|
53
|
+
lf setup
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`lf setup` takes three steps and is safe to run again:
|
|
57
|
+
|
|
58
|
+
1. **Credentials.** It keeps working credentials that it finds. When no profile is saved, or the
|
|
59
|
+
saved profile's keys are rejected, it asks for the host and the keys (the secret is not echoed)
|
|
60
|
+
and saves them. It never replaces saved keys when the server is merely unreachable, and keys from
|
|
61
|
+
`LANGFUSE_*` variables, `--env-file` or key flags, which take precedence over profiles, are left for
|
|
62
|
+
you to fix.
|
|
63
|
+
2. **Agent skill.** It installs the `langfuse-agent-cli` skill with the
|
|
64
|
+
[skills CLI](https://github.com/vercel-labs/skills), which asks which coding agents to install it
|
|
65
|
+
for when it finds more than one. The skill comes from the release tag that matches your `lf`
|
|
66
|
+
version.
|
|
67
|
+
3. **Check.** It runs `lf doctor`.
|
|
68
|
+
|
|
69
|
+
To have a coding agent install it, give the agent this prompt:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
Install langfuse-agent-cli by following https://raw.githubusercontent.com/tns15june/langfuse-agent-cli/main/INSTALL.md
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The agent installs the CLI and runs `lf setup --yes`, which never prompts and installs the skill for
|
|
76
|
+
that agent. If no working credentials are configured, the agent asks you to run `lf setup` yourself,
|
|
77
|
+
which asks for the host and the keys.
|
|
78
|
+
|
|
79
|
+
To install the latest code from GitHub instead of PyPI:
|
|
80
|
+
`pipx install git+https://github.com/tns15june/langfuse-agent-cli`.
|
|
81
|
+
|
|
82
|
+
### Upgrade and uninstall
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pipx upgrade langfuse-agent-cli && lf setup # lf setup also installs the matching skill
|
|
86
|
+
npx skills remove --global langfuse-agent-cli
|
|
87
|
+
pipx uninstall langfuse-agent-cli
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
With uv, use `uv tool upgrade langfuse-agent-cli` and `uv tool uninstall langfuse-agent-cli`. Saved
|
|
91
|
+
profiles stay in `~/.config/langfuse/profiles.json` until you delete that file.
|
|
92
|
+
|
|
93
|
+
## Credentials
|
|
94
|
+
|
|
95
|
+
`lf` takes the host and both keys from one source; the first match wins:
|
|
96
|
+
|
|
97
|
+
1. `--env-file <path>`
|
|
98
|
+
2. `--profile <name>` or `LANGFUSE_PROFILE`
|
|
99
|
+
3. `LANGFUSE_PUBLIC_KEY` or `LANGFUSE_SECRET_KEY` (either one selects this source), with the host from
|
|
100
|
+
`LANGFUSE_BASE_URL`, then `LANGFUSE_HOST` (default `https://cloud.langfuse.com`)
|
|
101
|
+
4. The saved current profile
|
|
102
|
+
|
|
103
|
+
`--host`, `--public-key` and `--secret-key` override single values; prefer environment variables or a
|
|
104
|
+
profile over passing keys on the command line, where they end up in shell history. `lf` reads a
|
|
105
|
+
`.env` file only when it is passed with `--env-file`.
|
|
106
|
+
|
|
107
|
+
To save another profile (the keys are prompted for, and the secret is not echoed):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
lf auth login --profile-name local --host http://localhost:3000 --default
|
|
111
|
+
lf doctor
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Profiles live in `~/.config/langfuse/profiles.json`, readable only by you (mode 0600).
|
|
115
|
+
|
|
116
|
+
## Commands
|
|
117
|
+
|
|
118
|
+
Data commands print JSON by default and short lines with `-o text`; `doctor`, `setup`, `auth` and
|
|
119
|
+
`help-map` print text. Three options keep JSON small:
|
|
120
|
+
|
|
121
|
+
- `--compact` drops null and empty fields.
|
|
122
|
+
- `--agent-fields name,level` keeps only the listed fields of each row.
|
|
123
|
+
- `--output-summary` writes JSON output over 16 KB to a file and prints the file's path, size and keys
|
|
124
|
+
instead.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Failing traces, one entry per trace, with each error message
|
|
128
|
+
lf trace list --status error --limit 10 --compact
|
|
129
|
+
|
|
130
|
+
# One trace as a tree; add --io for short inputs and outputs
|
|
131
|
+
lf trace get <trace-id> --timeline
|
|
132
|
+
|
|
133
|
+
# A trace with its inputs and outputs; over 16 KB it goes to a file
|
|
134
|
+
lf trace get <trace-id> --io --output-summary
|
|
135
|
+
|
|
136
|
+
# The traces of a session, oldest first (the newest 1000)
|
|
137
|
+
lf trace session <session-id> --compact
|
|
138
|
+
|
|
139
|
+
# Recent traces, filtered
|
|
140
|
+
lf trace list --user-id user-42 --from-ts 2026-10-24T00:00:00Z --limit 20
|
|
141
|
+
|
|
142
|
+
# Prompts
|
|
143
|
+
lf prompt list -o text
|
|
144
|
+
lf prompt get support/greeter
|
|
145
|
+
lf prompt get welcome-bot --vars '{"user_name": "Alice", "plan": "pro"}' -o text
|
|
146
|
+
lf prompt push welcome-bot --text 'Hello {{user_name}}!' --labels staging
|
|
147
|
+
|
|
148
|
+
# Datasets and scores
|
|
149
|
+
lf dataset list
|
|
150
|
+
lf dataset get intent-classification-evals
|
|
151
|
+
lf score create --trace-id <trace-id> --name accuracy --value 1
|
|
152
|
+
|
|
153
|
+
# Discover commands and options
|
|
154
|
+
lf help-map
|
|
155
|
+
lf help "trace get"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
A timeline, from synthetic data:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
Trace 33579e8e8ec602e878f0744ad53ac1fe: 3 observations, 1 error
|
|
162
|
+
✓ AGENT support-agent-turn
|
|
163
|
+
✓ GENERATION plan-step (model: gpt-4o-mini)
|
|
164
|
+
✗ [ERROR] TOOL search_tool_call
|
|
165
|
+
Message: 503 Service Unavailable
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Observations with a measured duration show it in brackets, such as `[1.24s]`. Langfuse 4.70 reports
|
|
169
|
+
no duration for observations of zero length, like these synthetic ones.
|
|
170
|
+
|
|
171
|
+
Exit codes: `0` success, `1` API or configuration error, `2` invalid command. The reason for a failure is
|
|
172
|
+
on stderr, except that `doctor`, `setup --yes` and `auth status` print their whole report, failures
|
|
173
|
+
included, on stdout. `setup` also exits `1` when the skill was not installed.
|
|
174
|
+
|
|
175
|
+
## API endpoints used
|
|
176
|
+
|
|
177
|
+
| Command | Endpoint |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| `trace list` | `GET /api/public/v2/observations?isRootObservation=true` |
|
|
180
|
+
| `trace list --status error` | `GET /api/public/v2/observations?level=ERROR`, grouped by trace |
|
|
181
|
+
| `trace get` | `GET /api/public/v2/observations?traceId=…`, all pages |
|
|
182
|
+
| `trace session` | `GET /api/public/v2/observations?sessionId=…&isRootObservation=true` |
|
|
183
|
+
| `prompt list`, `prompt get`, `prompt push` | `/api/public/v2/prompts` |
|
|
184
|
+
| `dataset list`, `dataset get` | `/api/public/v2/datasets`, `/api/public/dataset-items` |
|
|
185
|
+
| `score create` | `POST /api/public/scores` |
|
|
186
|
+
| `doctor` | `/api/public/health`, `/api/public/projects`, `/api/public/v2/observations?limit=1` |
|
|
187
|
+
| `auth login`, `auth status` | `/api/public/projects` |
|
|
188
|
+
| `setup` | `/api/public/projects`, then the `doctor` requests |
|
|
189
|
+
|
|
190
|
+
## Development
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pip install -e ".[dev]"
|
|
194
|
+
ruff check .
|
|
195
|
+
pytest -q
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The unit tests replay responses recorded from Langfuse 4.70.0 (synthetic data). The live tests run
|
|
199
|
+
every command against a real instance, for example one started from Langfuse's official
|
|
200
|
+
`docker-compose.yml`:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
export LANGFUSE_BASE_URL=http://localhost:3000 LANGFUSE_PUBLIC_KEY=pk-lf-... LANGFUSE_SECRET_KEY=sk-lf-...
|
|
204
|
+
pip install langfuse
|
|
205
|
+
python scripts/seed_langfuse.py # synthetic prompts, a dataset and traces: use a throwaway project
|
|
206
|
+
LF_LIVE=1 pytest tests/test_live.py -v
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
CI runs the unit tests on Python 3.10 to 3.13 and the live tests against the latest Langfuse release,
|
|
210
|
+
on every push and weekly.
|
|
211
|
+
|
|
212
|
+
### Releasing
|
|
213
|
+
|
|
214
|
+
The Publish workflow uploads to PyPI with trusted publishing, so no token is stored; the PyPI project
|
|
215
|
+
lists `publish.yml` and the GitHub environment `pypi` as its trusted publisher. Bump `__version__` in
|
|
216
|
+
`langfuse_cli/__init__.py`, commit, then push that commit and its tag together:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
git tag v0.3.0 && git push --atomic origin main v0.3.0
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The workflow checks that the tag matches the version, runs the tests, builds and checks the
|
|
223
|
+
distributions, installs the wheel, and uploads the wheel and the source archive. `main` should never
|
|
224
|
+
carry a version without its tag, because `lf setup` and `lf doctor` point at the skill under that tag.
|
|
225
|
+
|
|
226
|
+
## Prior art
|
|
227
|
+
|
|
228
|
+
The command map (`lf help-map`), the `--output-summary` option, `lf setup` and the agent install prompt
|
|
229
|
+
follow Atlassian's
|
|
230
|
+
[Teamwork Graph CLI](https://developer.atlassian.com/platform/teamwork-graph/twg-cli/getting-started/installation/),
|
|
231
|
+
whose `--select` option does what `lf`'s `--agent-fields` does.
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# langfuse-agent-cli (`lf`)
|
|
2
|
+
|
|
3
|
+
Command-line access to [Langfuse](https://langfuse.com) traces, prompts, datasets and scores, shaped
|
|
4
|
+
for AI coding agents: JSON by default (`--compact` trims it), failing traces with their error messages
|
|
5
|
+
in one command, a trace as a tree, and an agent skill that teaches the commands.
|
|
6
|
+
|
|
7
|
+
> **Status: prototype.** Langfuse ships an official CLI,
|
|
8
|
+
> [`@langfuse/cli`](https://github.com/langfuse/langfuse-cli), which covers the whole API, and official
|
|
9
|
+
> agent skills, [`langfuse/skills`](https://github.com/langfuse/skills). This project tries out
|
|
10
|
+
> agent-oriented features on the same API.
|
|
11
|
+
> [RFC.md](https://github.com/tns15june/langfuse-agent-cli/blob/main/RFC.md) describes which of them it
|
|
12
|
+
> proposes upstream.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Python 3.10 or newer
|
|
17
|
+
- Langfuse v4, self-hosted or Cloud. The trace commands read `/api/public/v2/observations`;
|
|
18
|
+
`lf doctor` reports if a server does not have it.
|
|
19
|
+
- Node.js 22.20 or newer, only for installing the agent skill
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pipx install langfuse-agent-cli # or: uv tool install langfuse-agent-cli
|
|
25
|
+
lf setup
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`lf setup` takes three steps and is safe to run again:
|
|
29
|
+
|
|
30
|
+
1. **Credentials.** It keeps working credentials that it finds. When no profile is saved, or the
|
|
31
|
+
saved profile's keys are rejected, it asks for the host and the keys (the secret is not echoed)
|
|
32
|
+
and saves them. It never replaces saved keys when the server is merely unreachable, and keys from
|
|
33
|
+
`LANGFUSE_*` variables, `--env-file` or key flags, which take precedence over profiles, are left for
|
|
34
|
+
you to fix.
|
|
35
|
+
2. **Agent skill.** It installs the `langfuse-agent-cli` skill with the
|
|
36
|
+
[skills CLI](https://github.com/vercel-labs/skills), which asks which coding agents to install it
|
|
37
|
+
for when it finds more than one. The skill comes from the release tag that matches your `lf`
|
|
38
|
+
version.
|
|
39
|
+
3. **Check.** It runs `lf doctor`.
|
|
40
|
+
|
|
41
|
+
To have a coding agent install it, give the agent this prompt:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
Install langfuse-agent-cli by following https://raw.githubusercontent.com/tns15june/langfuse-agent-cli/main/INSTALL.md
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The agent installs the CLI and runs `lf setup --yes`, which never prompts and installs the skill for
|
|
48
|
+
that agent. If no working credentials are configured, the agent asks you to run `lf setup` yourself,
|
|
49
|
+
which asks for the host and the keys.
|
|
50
|
+
|
|
51
|
+
To install the latest code from GitHub instead of PyPI:
|
|
52
|
+
`pipx install git+https://github.com/tns15june/langfuse-agent-cli`.
|
|
53
|
+
|
|
54
|
+
### Upgrade and uninstall
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pipx upgrade langfuse-agent-cli && lf setup # lf setup also installs the matching skill
|
|
58
|
+
npx skills remove --global langfuse-agent-cli
|
|
59
|
+
pipx uninstall langfuse-agent-cli
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
With uv, use `uv tool upgrade langfuse-agent-cli` and `uv tool uninstall langfuse-agent-cli`. Saved
|
|
63
|
+
profiles stay in `~/.config/langfuse/profiles.json` until you delete that file.
|
|
64
|
+
|
|
65
|
+
## Credentials
|
|
66
|
+
|
|
67
|
+
`lf` takes the host and both keys from one source; the first match wins:
|
|
68
|
+
|
|
69
|
+
1. `--env-file <path>`
|
|
70
|
+
2. `--profile <name>` or `LANGFUSE_PROFILE`
|
|
71
|
+
3. `LANGFUSE_PUBLIC_KEY` or `LANGFUSE_SECRET_KEY` (either one selects this source), with the host from
|
|
72
|
+
`LANGFUSE_BASE_URL`, then `LANGFUSE_HOST` (default `https://cloud.langfuse.com`)
|
|
73
|
+
4. The saved current profile
|
|
74
|
+
|
|
75
|
+
`--host`, `--public-key` and `--secret-key` override single values; prefer environment variables or a
|
|
76
|
+
profile over passing keys on the command line, where they end up in shell history. `lf` reads a
|
|
77
|
+
`.env` file only when it is passed with `--env-file`.
|
|
78
|
+
|
|
79
|
+
To save another profile (the keys are prompted for, and the secret is not echoed):
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
lf auth login --profile-name local --host http://localhost:3000 --default
|
|
83
|
+
lf doctor
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Profiles live in `~/.config/langfuse/profiles.json`, readable only by you (mode 0600).
|
|
87
|
+
|
|
88
|
+
## Commands
|
|
89
|
+
|
|
90
|
+
Data commands print JSON by default and short lines with `-o text`; `doctor`, `setup`, `auth` and
|
|
91
|
+
`help-map` print text. Three options keep JSON small:
|
|
92
|
+
|
|
93
|
+
- `--compact` drops null and empty fields.
|
|
94
|
+
- `--agent-fields name,level` keeps only the listed fields of each row.
|
|
95
|
+
- `--output-summary` writes JSON output over 16 KB to a file and prints the file's path, size and keys
|
|
96
|
+
instead.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Failing traces, one entry per trace, with each error message
|
|
100
|
+
lf trace list --status error --limit 10 --compact
|
|
101
|
+
|
|
102
|
+
# One trace as a tree; add --io for short inputs and outputs
|
|
103
|
+
lf trace get <trace-id> --timeline
|
|
104
|
+
|
|
105
|
+
# A trace with its inputs and outputs; over 16 KB it goes to a file
|
|
106
|
+
lf trace get <trace-id> --io --output-summary
|
|
107
|
+
|
|
108
|
+
# The traces of a session, oldest first (the newest 1000)
|
|
109
|
+
lf trace session <session-id> --compact
|
|
110
|
+
|
|
111
|
+
# Recent traces, filtered
|
|
112
|
+
lf trace list --user-id user-42 --from-ts 2026-10-24T00:00:00Z --limit 20
|
|
113
|
+
|
|
114
|
+
# Prompts
|
|
115
|
+
lf prompt list -o text
|
|
116
|
+
lf prompt get support/greeter
|
|
117
|
+
lf prompt get welcome-bot --vars '{"user_name": "Alice", "plan": "pro"}' -o text
|
|
118
|
+
lf prompt push welcome-bot --text 'Hello {{user_name}}!' --labels staging
|
|
119
|
+
|
|
120
|
+
# Datasets and scores
|
|
121
|
+
lf dataset list
|
|
122
|
+
lf dataset get intent-classification-evals
|
|
123
|
+
lf score create --trace-id <trace-id> --name accuracy --value 1
|
|
124
|
+
|
|
125
|
+
# Discover commands and options
|
|
126
|
+
lf help-map
|
|
127
|
+
lf help "trace get"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A timeline, from synthetic data:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
Trace 33579e8e8ec602e878f0744ad53ac1fe: 3 observations, 1 error
|
|
134
|
+
✓ AGENT support-agent-turn
|
|
135
|
+
✓ GENERATION plan-step (model: gpt-4o-mini)
|
|
136
|
+
✗ [ERROR] TOOL search_tool_call
|
|
137
|
+
Message: 503 Service Unavailable
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Observations with a measured duration show it in brackets, such as `[1.24s]`. Langfuse 4.70 reports
|
|
141
|
+
no duration for observations of zero length, like these synthetic ones.
|
|
142
|
+
|
|
143
|
+
Exit codes: `0` success, `1` API or configuration error, `2` invalid command. The reason for a failure is
|
|
144
|
+
on stderr, except that `doctor`, `setup --yes` and `auth status` print their whole report, failures
|
|
145
|
+
included, on stdout. `setup` also exits `1` when the skill was not installed.
|
|
146
|
+
|
|
147
|
+
## API endpoints used
|
|
148
|
+
|
|
149
|
+
| Command | Endpoint |
|
|
150
|
+
| --- | --- |
|
|
151
|
+
| `trace list` | `GET /api/public/v2/observations?isRootObservation=true` |
|
|
152
|
+
| `trace list --status error` | `GET /api/public/v2/observations?level=ERROR`, grouped by trace |
|
|
153
|
+
| `trace get` | `GET /api/public/v2/observations?traceId=…`, all pages |
|
|
154
|
+
| `trace session` | `GET /api/public/v2/observations?sessionId=…&isRootObservation=true` |
|
|
155
|
+
| `prompt list`, `prompt get`, `prompt push` | `/api/public/v2/prompts` |
|
|
156
|
+
| `dataset list`, `dataset get` | `/api/public/v2/datasets`, `/api/public/dataset-items` |
|
|
157
|
+
| `score create` | `POST /api/public/scores` |
|
|
158
|
+
| `doctor` | `/api/public/health`, `/api/public/projects`, `/api/public/v2/observations?limit=1` |
|
|
159
|
+
| `auth login`, `auth status` | `/api/public/projects` |
|
|
160
|
+
| `setup` | `/api/public/projects`, then the `doctor` requests |
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip install -e ".[dev]"
|
|
166
|
+
ruff check .
|
|
167
|
+
pytest -q
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The unit tests replay responses recorded from Langfuse 4.70.0 (synthetic data). The live tests run
|
|
171
|
+
every command against a real instance, for example one started from Langfuse's official
|
|
172
|
+
`docker-compose.yml`:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
export LANGFUSE_BASE_URL=http://localhost:3000 LANGFUSE_PUBLIC_KEY=pk-lf-... LANGFUSE_SECRET_KEY=sk-lf-...
|
|
176
|
+
pip install langfuse
|
|
177
|
+
python scripts/seed_langfuse.py # synthetic prompts, a dataset and traces: use a throwaway project
|
|
178
|
+
LF_LIVE=1 pytest tests/test_live.py -v
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
CI runs the unit tests on Python 3.10 to 3.13 and the live tests against the latest Langfuse release,
|
|
182
|
+
on every push and weekly.
|
|
183
|
+
|
|
184
|
+
### Releasing
|
|
185
|
+
|
|
186
|
+
The Publish workflow uploads to PyPI with trusted publishing, so no token is stored; the PyPI project
|
|
187
|
+
lists `publish.yml` and the GitHub environment `pypi` as its trusted publisher. Bump `__version__` in
|
|
188
|
+
`langfuse_cli/__init__.py`, commit, then push that commit and its tag together:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
git tag v0.3.0 && git push --atomic origin main v0.3.0
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The workflow checks that the tag matches the version, runs the tests, builds and checks the
|
|
195
|
+
distributions, installs the wheel, and uploads the wheel and the source archive. `main` should never
|
|
196
|
+
carry a version without its tag, because `lf setup` and `lf doctor` point at the skill under that tag.
|
|
197
|
+
|
|
198
|
+
## Prior art
|
|
199
|
+
|
|
200
|
+
The command map (`lf help-map`), the `--output-summary` option, `lf setup` and the agent install prompt
|
|
201
|
+
follow Atlassian's
|
|
202
|
+
[Teamwork Graph CLI](https://developer.atlassian.com/platform/teamwork-graph/twg-cli/getting-started/installation/),
|
|
203
|
+
whose `--select` option does what `lf`'s `--agent-fields` does.
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
MIT
|