Skip to content
Docs
Request access

LangGraph agent

Available

The review-board team with one agent, the change summarizer, replaced by a LangGraph graph. Its model calls go through NuraMesh: each is policy-checked, priced, reserved against the budgets and written to the ledger, and the gates still decide whether the task is done.

  • NuraMesh installed with the LangGraph extra (nuramesh[langgraph]) and on your PATH, as in the Quickstart (install commands: Install options).
  • A throwaway folder to run in.
Terminal window
nuramesh init my-team --template review-board
created my-team from the 'review-board' template. Next:
nuramesh validate my-team/nuramesh.yaml
nuramesh try my-team --fake --approve-as human:you

This adds the graph to the end of team.py. It is built once per attempt by build(model). model is NuraMesh’s chat model: use it for every model call, and give the graph no provider keys of its own.

Terminal window
cat >> my-team/team.py <<'EOF'
# --- a tiny LangGraph graph: one node that asks the model and returns its answer ---
from typing import TypedDict
from langchain_core.messages import HumanMessage, SystemMessage
class State(TypedDict, total=False):
task: str
instructions: str
output: str
def build(model):
"""Called once per attempt with NuraMesh's chat model: every call it makes is checked and recorded."""
from langgraph.graph import END, START, StateGraph
def write(state: State) -> State:
reply = model.invoke(
[SystemMessage(content="You support a review board. Be brief."), HumanMessage(content=state["instructions"])]
)
return {"output": str(reply.content)}
graph = StateGraph(State)
graph.add_node("write", write)
graph.add_edge(START, "write")
graph.add_edge("write", END)
return graph.compile()
EOF

This edit swaps the summarizer’s plain worker for langgraph_worker(build) and stops if the text it expected is not there.

Terminal window
python - <<'EOF'
from pathlib import Path
path = Path("my-team/team.py")
text = path.read_text()
text = text.replace("from nuramesh.team import Team, TeamEnv", "from nuramesh.adapters.langgraph import langgraph_worker\nfrom nuramesh.team import Team, TeamEnv")
text = text.replace('workers={"change-summarizer": work}', 'workers={"change-summarizer": langgraph_worker(build)}')
assert "langgraph_worker(build)" in text
path.write_text(text)
EOF
Terminal window
nuramesh validate my-team/nuramesh.yaml
my-team/nuramesh.yaml: valid
Terminal window
nuramesh try my-team --fake --approve-as human:you --run-id first-run
Run first-run
Tasks: 2 done
[done] first-run-summary (change-summarizer, attempts 1): Summarize the change for the board
gate is-summary (rule): passed by gate:rule
gate correctness-reviewer-review (verifier): passed by agent:correctness-reviewer
gate security-reviewer-review (verifier): passed by agent:security-reviewer
gate maintainability-reviewer-review (verifier): passed by agent:maintainability-reviewer
[done] first-run-decision (change-summarizer, attempts 1): Record the board's decision
gate is-decision (rule): passed by gate:rule
Budgets:
correctness-monthly (agent correctness-reviewer): spent 0.001617 of 5.00, reserved 0.000000
maintainability-monthly (agent maintainability-reviewer): spent 0.001641 of 5.00, reserved 0.000000
rb-486e135495bd (run first-run): spent 0.005391 of 2.00, reserved 0.000000
security-monthly (agent security-reviewer): spent 0.001587 of 5.00, reserved 0.000000
summarizer-monthly (agent change-summarizer): spent 0.000546 of 5.00, reserved 0.000000
Ledger: run:first-run seq 46, head ae7724e36910c78e… (verified)

The summary still has to pass its three reviewers: the graph does the work, the gates decide.

Terminal window
nuramesh ledger verify --team my-team
org:my-team: 5 events, head 98ec0097e33f11bd… ok
run:first-run: 46 events, head ae7724e36910c78e… ok
2 streams, 0 broken

The model calls the graph made are in the same ledger as every other call, recorded as the task’s assignee with that agent’s model and budgets.

  • A graph that pauses for a human (interrupt() or a breakpoint) sends the task to a human; resuming is an engine call, not a command.
  • The adapter refuses what it cannot check: non-text content, tool-call messages and extra call arguments.
  • It cannot see tools your graph runs without asking: call authorize(...) before a tool or command, and give nodes no keys of their own.
  • Graphs whose nodes are all async are not supported yet.
  • This page uses the fake model only; a real provider needs the setup in the FAQ and limits.

Was this page helpful?