Skip to content

feat(graph): LangGraph parity shims — sync invoke + mermaid/ascii renderers#249

Merged
fede-kamel merged 1 commit into
mainfrom
feat/graph-langgraph-parity-shims
May 22, 2026
Merged

feat(graph): LangGraph parity shims — sync invoke + mermaid/ascii renderers#249
fede-kamel merged 1 commit into
mainfrom
feat/graph-langgraph-parity-shims

Conversation

@fede-kamel
Copy link
Copy Markdown
Contributor

@fede-kamel fede-kamel commented May 22, 2026

Closes #250

Summary

Closes the 4 documented gaps between locus StateGraph and LangGraph's CompiledStateGraph:

  • invoke() / run_sync() — sync wrappers around ainvoke. Refuse with a clear error when called inside a running event loop, pointing the caller at ainvoke.
  • draw_mermaid() / draw_ascii() / get_mermaid() on StateGraph — so compiled.get_graph().draw_mermaid() works LangGraph-style. Both delegate to the existing locus.multiagent.visualize helpers.
  • get_graph() docstring spells out the rendering chain.

run_sync and get_mermaid were already documented in docs/concepts/multi-agent/graph.md but 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.
  • Full unit suite: 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.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 22, 2026
…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>
@fede-kamel fede-kamel force-pushed the feat/graph-langgraph-parity-shims branch from 64e7b76 to cfee601 Compare May 22, 2026 07:00
@fede-kamel
Copy link
Copy Markdown
Contributor Author

Context — how the gaps were found

The 4 gaps closed here were caught by a side-by-side LangGraph vs Locus verifier:

📎 Gist: https://gist.github.com/fede-kamel/cb45aeac259bb995f8be23a5d7ca6965 (langgraph_vs_locus.py) — same workflow / same model, run against both frameworks. The Locus side failed on compiled.invoke(...), compiled.run_sync(...), compiled.get_mermaid(), and compiled.get_graph().draw_mermaid() — all of which now work after this PR.

Tests added

tests/unit/test_graph.py::TestLangGraphParityShims — 6 regression tests, one per gap + a running-loop guard:

Test Covers
test_invoke_is_sync_and_runs Gap 1 — sync compiled.invoke({...})
test_run_sync_alias Gap 2 — run_sync matches docs
test_invoke_refuses_inside_running_loop Safety — clear error inside live loop
test_get_mermaid_and_draw_mermaid_equal Gap 3 — get_mermaid() matches docs
test_get_graph_chain_to_draw_mermaid Gap 4 — compiled.get_graph().draw_mermaid() chain
test_draw_ascii_runs Renderer parity — .draw_ascii() on StateGraph

All 6 pass locally and in CI (4794 unit tests green).

@fede-kamel fede-kamel merged commit 26036cc into main May 22, 2026
10 checks passed
fede-kamel added a commit that referenced this pull request May 23, 2026
#255)

Bumps version 0.2.0b19 → 0.2.0b20 and rolls the [Unreleased] section
into a dated [0.2.0b20] entry.

Bundles:

- PR #254 — feat(tools): use_oci + describe_oci open-spec OCI
  primitive (~190 services covered by one execution path,
  read-only by default), notebook 70 walkthrough, docs reorg.
- PR #249 — feat(graph): LangGraph parity shims (sync invoke,
  mermaid/ascii renderers).
- PR #247/#251 — fix(a2a): A2AClient httpx timeout configurable.
- PR #245 — fix(telemetry): OTel trace context propagation through
  the agent run loop.
- PR #246 — docs(readme): rebrand around the locus stack.
- PR #248 — docs(site): canonical URL locusagents.oracle.com.

Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(graph): LangGraph parity gaps — sync invoke + mermaid/ascii renderers missing

1 participant