Add Langfuse tracing for Codex and Claude Code runs#16
Merged
Conversation
Opt-in via a shared `agent.langfuse` block ({enabled, public_key,
secret_key, base_url}; all three credentials required when enabled).
Tracing is side-channel only: each agent uses its own native integration,
reads transcripts, fails open, and doesn't change agent behavior or
Teich's output files.
- Codex: the codex-observability plugin is baked into the runtime image at
a staging CODEX_HOME and seeded into each session's CODEX_HOME offline;
the generated config enables plugin_hooks, and `codex exec` runs with
--dangerously-bypass-hook-trust (it silently skips plugin hooks otherwise).
- Claude Code: the Langfuse Stop/SessionEnd hook is registered per session.
The langfuse SDK is installed into /opt/venv and the hook calls that
interpreter by absolute path, since Claude strips /opt/venv from a hook's
PATH. The plugin is pinned to a known-good commit.
A localhost/127.0.0.1 base_url is rewritten to host.docker.internal for the
in-container env value and the --add-host gate.
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.
Supersedes #15 with the same Langfuse tracing feature set, rebased on the merged Codex host-auth changes from #14.
Changes in this patched version:
agent.codexhost-auth/config additions.teich-runtime:v3, while Codex/Claude runs withagent.langfuse.enableduseteich-runtime:v3-langfusebuilt withTEICH_INSTALL_LANGFUSE=1.Validation:
env UV_CACHE_DIR=/tmp/uv-cache uv run --extra dev python -m compileall -q src/teichenv UV_CACHE_DIR=/tmp/uv-cache uv run --extra dev pytest -s -q tests/test_codex_langfuse.py tests/test_langfuse_agents.py tests/test_config.py tests/test_runner.py tests/test_converter.py tests/test_codex_auth_broker.py tests/test_cli.pyenv UV_CACHE_DIR=/tmp/uv-cache uv run --extra dev ruff check