Repository navigation
LangGraph re-checks the role of the agent a turn resumes in (1.6.0, item 7) - #302
Merged
Merged
Conversation
…tem 7) A multi-agent graph starts each turn at the checkpointed current_agent, but execute_run checked the user's roles only for the agent requested. A user who lost a sub-agent's role, or whose sub-agent's allowed roles changed after a transfer, kept talking to it. execute_run now reads the agent the turn resumes in and checks it too when it is not the root, refusing as ADK does on the sub-agent's model call. A checkpoint that cannot be read refuses the turn. The transfer tool let a transfer through when it had no run context to check. It now refuses, except in the graph built for LangGraph Studio, which runs with no MATE user.
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.
What and why
1.6.0 item 7 (#276), found in the review of #278.
Every turn checked only the agent requested
On
AGENT_FRAMEWORK=langgraph, a multi-agent graph starts each turn at the checkpointedcurrent_agent:transfer_to_agentsetscurrent_agent, androute_entryroutes the next turn to it.But
execute_runcalledcheck_rbaconly forapp_name, the root agent. After a transfer, a user kept talking to the sub-agent even when the role check would refuse them there:ADK checks the agent that answers on every model call (
before_model_callback), so it refuses there.execute_runnow reads the agent the turn resumes in (_resumed_agent:current_agentfrom the checkpoint, or the root when it is not in the tree, which is also whereroute_entrysends it). When that agent is not the root, it runscheck_rbacfor it too.RBAC_ACCESS_DENIEDevent as the root check, with the audit entry and theACCESS_DENIEDusage row fromcheck_rbac.current_agent, so the user starts a new conversation. ADK behaves the same.A transfer without a run context was let through
transfer_to_agentchecked roles only when it had a run context, and transferred without a check when it had none. It now refuses, because there is no user to check.Production never runs without one:
execute_runand the evalLangGraphSnapshotAgentboth set it. The graph built for LangGraph Studio has no MATE user, so it is the one exception:AgentBuilder(require_run_context=False), used only instudio_graph.py. The shared builder and the eval builder keep the default.How it was tested
python -m unittest discover -s shared/test -p "test_*.py": 1635 tests pass, excepttest_browser_tools.test_real_headless_navigation. That test needs outbound network and fails the same way onmainin my environment.New:
test_langgraph_resumed_agent_rbac.py(8 tests). It builds a real multi-agent graph throughAgentBuilder.build_for_config, with plain nodes instead of models and an in-memory checkpointer, and runsexecute_runagainst it. It covers:current_agentoutside the tree starts at the root;7 of the 8 fail on
main. The one that passes is the root-only case, which behaves the same. In the first test the sub-agent's node ran onmain.Updated:
test_langgraph_agent_builder.py::test_transfer_returns_parent_commandnow sets a run context. It relied on a transfer passing without one.python -m pytest shared/test/test_sessions_api.pypasses.python scripts/gen_docs.py --checkis clean.Independent security review of the diff: no findings.
/run_sse, eval snapshots and Studio.user_id, and/run_sserequires the session to belong to that user and app.route_entry.It also raised a pre-existing issue, not touched here: deleting a LangGraph session does not delete its checkpoint thread, so a recreated session with the same id would load the old history. That needs the old session's UUID.
Checklist
shared/test/, andpython -m unittest discover -s shared/test -p "test_*.py"passesshared/sql/migrations/{postgresql,mysql,sqlite}/) (no schema change)python scripts/gen_docs.pyand committeddocs/reference/(nothing to regenerate)python scripts/gen_docs.py drift --base origin/mainand updated the guides it lists (or say below why they still hold)docs/user/(anddocs/dev/if it has internals worth knowing) (a fix; dev guides updated)Guides updated:
docs/dev/langgraph-runtime.md:docs/dev/agent-runtime.md: the LangGraph role check runs per turn, not per model call.docs/dev/auth-and-access.md: the LangGraph hook's coverage.Guide drift lists that still holds:
docs/dev/releases.md, for a CHANGELOG entry only.Generated by Claude Code