feat(graph): LangGraph parity shims — sync invoke + mermaid/ascii renderers#249
Merged
Merged
Conversation
…derers Fills the 4 documented gaps between StateGraph and LangGraph's CompiledStateGraph: - `invoke()` / `run_sync()` — sync wrappers around `ainvoke`, refuse inside a running event loop with a clear error pointing at `ainvoke`. - `draw_mermaid()` / `draw_ascii()` / `get_mermaid()` on StateGraph, so `compiled.get_graph().draw_mermaid()` works LangGraph-style. - `get_graph()` docstring updated to spell out the chain. `run_sync` and `get_mermaid` were already documented in docs/concepts/multi-agent/graph.md but missing from the class. Adds TestLangGraphParityShims (6 tests) covering sync execution, the running-loop guard, and renderer chain equivalence. Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
64e7b76 to
cfee601
Compare
Contributor
Author
Context — how the gaps were foundThe 4 gaps closed here were caught by a side-by-side LangGraph vs Locus verifier: 📎 Gist: https://gist.github.com/fede-kamel/cb45aeac259bb995f8be23a5d7ca6965 ( Tests added
All 6 pass locally and in CI (4794 unit tests green). |
4 tasks
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.
Closes #250
Summary
Closes the 4 documented gaps between locus
StateGraphand LangGraph'sCompiledStateGraph:invoke()/run_sync()— sync wrappers aroundainvoke. Refuse with a clear error when called inside a running event loop, pointing the caller atainvoke.draw_mermaid()/draw_ascii()/get_mermaid()onStateGraph— socompiled.get_graph().draw_mermaid()works LangGraph-style. Both delegate to the existinglocus.multiagent.visualizehelpers.get_graph()docstring spells out the rendering chain.run_syncandget_mermaidwere already documented indocs/concepts/multi-agent/graph.mdbut the methods were missing — this brings the API in line with the docs.Test plan
TestLangGraphParityShims— 6 new tests: sync invoke, run_sync alias, running-loop guard, mermaid/ascii rendering,get_graph().draw_mermaid()chain.uv run pytest tests/unit/— 4794 passed.uv run ruff check+ruff format --check— clean.uv run mypy src/locus/multiagent/graph.py— no issues.uv run mkdocs build --strict— builds clean.