Repository navigation
docs: add a step-by-step LangGraph tutorial - #39
Open
how2how2how2-arch wants to merge 2 commits into
Open
how2how2how2-arch wants to merge 2 commits into
how2how2how2-arch wants to merge 2 commits into
Conversation
Walks one small LangGraph agent from a recorded run to a regression test: write the agent, record it, validate the bundle, replay it frozen, export a pytest test, and watch that test fail on the buggy decision and pass on the corrected one. It links to docs/langgraph.md for the adapter API and to examples/langgraph_agent for the larger worked example rather than restating either. The test extracts both code blocks from the page and runs every documented command in a clean subprocess, so a command that stops working fails CI instead of a reader. Refs utsab345#26.
The formatter prefers the quote style that needs no escaping: assert 'pip install "stepfork[langgraph]"' in text
This branch has not been deployed
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.
Adds the step-by-step tutorial #26 asks for:
docs/tutorials/langgraph-triage.md, plus a test that runs every command in it.What the page does. One small LangGraph triage agent, built in the order the issue names rather than as one lump:
python triage_agent.py→ a.sftracebundle,stepfork validate triage.sftrace --verify-integrity, theninspectto show what was captured,stepfork replay triage.sftrace --entrypoint triage_agent:run_agent, every recorded boundary substituted,behavior mismatch at 'decision': expected "escalate", got "queue",It links to
docs/langgraph.mdfor the adapter semantics and toexamples/langgraph_agentfor the two-tool example that also diffs and verifies integrity, and restates neither. The scenario is a support-ticket triage agent, deliberately not the refund agent the example already ships.mkdocs.ymlgains one nav line for it."The documented commands are tested."
tests/integration/test_docs_langgraph_tutorial.pyextracts both code blocks from the page (the agent, and the correction introduced in step 7), concatenates them, and runs every documented command in a clean subprocess — record, validate with--verify-integrity, inspect, replay, export, and pytest on both the buggy and the fixed entrypoint — asserting the recorded event types, the substituted boundaries, theMATCHEDverdict, and the two opposite pytest outcomes. A renamed flag or a removed option fails this test instead of a reader. It is modelled on the existingtests/integration/test_docs_langgraph_example.py, which guards the guide the same way.What I verified, and what I could not. The full suite passes: 703 passed with this test, 701 passed with it excluded, so nothing else moved. Every output quoted in the page is copied from an actual run on this machine; the numbers that vary per run (event count, timings) appear only inside blocks that are labelled as output of a reference run, and the test asserts the behavioural facts, not those counts.
Not run locally:
ruff check,ruff format --check,mypy, andmkdocs build --strict. This machine's wheel CDN throttles to about 19 KB/s, souv synccould not fetch those wheels at all — I ran the suite out of a venv built from the cached runtime dependencies instead. Line lengths are within the 88-character limit and imports follow the configured isort order, checked by hand, but that is not ruff and I am not claiming it is. The three relative links (../langgraph.md,../pytest-export.md,../trace-format.md) resolve to files that exist. CI will be the first place those four checks actually run, and if one of them objects I will fix it rather than argue.Refs #26.