feat(examples): add LangGraph tracing example with AgentOps - #542
Open
REISEN2330 wants to merge 2 commits into
Open
feat(examples): add LangGraph tracing example with AgentOps#542REISEN2330 wants to merge 2 commits into
REISEN2330 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an offline LangGraph tracing example that runs under Agent Lightning’s AgentOps tracer, documents how to run it, and wires it into CI to ensure the example stays working.
Changes:
- Added a two-node LangGraph workflow example that traces spans into an in-memory store and asserts expected tracing behavior.
- Added README documentation for running and understanding the LangGraph example.
- Added a GitHub Actions job to execute the example in CI.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| examples/langgraph/trace_langgraph.py | New runnable example that builds a LangGraph workflow, runs it under tracing, and validates stored spans. |
| examples/langgraph/README.md | Documents how to run the example and what output/behavior to expect. |
| .github/workflows/tests.yml | Adds CI job to run the LangGraph example to prevent regressions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| enable-cache: true | ||
| python-version: '3.12' | ||
| - name: Sync dependencies | ||
| run: uv sync --frozen --no-default-groups --group langchain |
| def reverse_text(state: MessagesState) -> Dict[str, Any]: | ||
| """Reverse the last message's content without any model.""" | ||
| last = state["messages"][-1] | ||
| return {"messages": [AIMessage(content=last.content[::-1])]} # type: ignore |
| # The exact span names are owned by the AgentOps instrumentation, so | ||
| # assert on the structural guarantees instead: the workflow execution | ||
| # is captured and at least one model call was traced. | ||
| assert "langgraph.workflow.execute" in span_names, span_names |
Author
|
@microsoft-github-policy-service agree |
…align README with CI
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.
Fixes #535
What
Adds a self-contained
examples/langgraph/example that traces a smallLangGraph workflow through Agent Lightning's AgentOps tracer.
FakeMessagesListChatModelnode plusa plain Python node — no API keys, no GPU, no network calls required.
AgentOpsTracerinside a rollout and reads the capturedspans back from the in-memory store, asserting the workflow execution
and the model call were both captured.
wires a CPU-only smoke-test job into the CPU Test workflow so the
example is exercised on every PR.
Why
#535asked for LangChain/LangGraph usage examples. The repo alreadyships the AgentOps LangChain instrumentation (
get_langchain_handler),so this example demonstrates the supported integration path for
LangGraph agents.
Verification
uv sync --frozen --no-default-groups --group dev --group langchainpython examples/langgraph/trace_langgraph.py— exits 0, prints thecaptured spans (
langgraph.workflow.execute+ model call present)pre-commit run --files examples/langgraph/trace_langgraph.py examples/langgraph/README.md .github/workflows/tests.yml— clean