Skip to content

Workspaces phase 2b: the agent runtime keeps to the workspace (#277) - #317

Merged
antiv merged 1 commit into
mainfrom
workspaces-phase-2b
Nov 1, 2026
Merged

antiv merged 1 commit into
mainfrom
workspaces-phase-2b

Conversation

@antiv

@antiv antiv commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Second of the five PRs of phase 2 (documents/design/2.0-plan.md). It follows #316.

What changes

  • The RBAC check is per workspace. RBACMiddleware.check_agent_access (the ADK callback, the LangGraph hook, MCP) takes the agent's workspace from its project and asks workspaces.caller_access whether the caller may use it:
    • a platform administrator, or an owner or admin of the workspace, may, and passes allowed_for_roles;
    • a member may, matched on their membership's agent_roles;
    • a widget visitor (widget_<key id>_…) may in their key's workspace only, and trigger_runner in any, both on users.roles;
    • anyone else, or anyone but a platform admin for an agent with no config, gets "This agent is not available".
  • Users the platform creates join the agent's workspace (the decision recorded in Workspaces phase 2a: the request's workspace, projects scoped (#277) #316). The check creates the user (get_or_create_user(user_id, workspace_id)), so an end user an API client runs through /run_sse, an A2A or a Slack user becomes a member where the agent is:
    • the RBAC callback and the LangGraph hook no longer create the user before the check, which put them in Default;
    • sync_default_members and the listeners leave a user who is a member of another workspace only out of Default;
    • until phase 3, every membership's agent_roles follow users.roles.
  • Proxy.
    • A non-admin is refused an agent of a workspace they can't use (_workspace_refusal), before the agent server is reached.
    • /list-apps answers with the request's workspace's agents, plain and ?detailed=true. An app with no config is listed to platform admins in the default workspace.
  • OpenAI API and MCP use the token's workspace.
    • /v1/models lists that workspace's agents, and a completion for another workspace's agent is a 404. GET /mcp and the agent MCP routes keep to it too.
    • A token whose owner left its workspace is refused (403).
    • get_pat_user records the workspace, and routes take it from the pat_workspace dependency.
  • Work Room lists the root agents of the current workspace the caller may use. 1.x listed every root agent and refused at the model call.
  • A2A stays admin-only through the proxy until 2e.

Behaviour on a 1.x installation

  • The clients' calls answer as before, and test_client_contract.py is unchanged.
    • Basic auth with /run_sse as an end user: the new user joins Default, as before.
    • PATs are in workspace 1, and every agent is there too.
  • Two visible changes, both from the plan:
    • administrators pass every agent's allowed_for_roles. Before, ["user"] refused someone who had only admin. This widens access, and only for admins. docs/user/agents.md and docs/user/users-and-roles.md are updated;
    • the Work Room hides agents the user can't use, which used to answer with an access-denied message.

Checked

  • Full suite: 1785 tests OK.
  • test_cross_workspace.py gains RBAC, OpenAI API, MCP, proxy and Work Room cases over two workspaces.
  • Mutation checks:
    • membership not checked per workspace: 4 tests fail;
    • the proxy without _workspace_refusal: 1 fails;
    • /v1/models unfiltered: 1 fails.
  • Local server, with the real agent server:
    • /list-apps through the proxy lists the same 49 apps as the agent server, plain and detailed;
    • /v1/models answers;
    • /run_sse with Basic auth as a new end user runs the agent, which answers "ok", and the user becomes a member of Default. The probe user was removed afterwards.

Docs

  • docs/dev/auth-and-access.md: proxy, agent check, tokens.
  • docs/dev/database-and-migrations.md: home workspace, sync.
  • docs/dev/openai-api-and-mcp.md and docs/dev/mcp-servers.md: the token's workspace.
  • docs/user/work-room.md, docs/user/personal-access-tokens.md, docs/user/agents.md, docs/user/users-and-roles.md.
  • The plan marks 2a done.
  • Other guides listed by drift (agent-runtime, langgraph-runtime, architecture, alerts, tracing, template-format, openai-compatibility) describe the role check without its rule, or code not changed here, so they still hold.

The RBAC check (RBACMiddleware.check_agent_access, used by the ADK callback, the
LangGraph hook and MCP) takes the agent's workspace from its project and asks
workspaces.caller_access whether the caller may use it: a platform administrator,
or an owner or admin of the workspace, passes allowed_for_roles; a member is matched
on agent_roles; a widget visitor only reaches their key's workspace, and
trigger_runner any. Anyone else gets "This agent is not available".

A user the check creates joins the agent's workspace rather than the default one,
so an end user an API client runs through /run_sse, an A2A or a Slack user lands
where the agent is. The member sync leaves such users out of the default workspace,
and until phase 3 every membership's agent_roles follow users.roles.

Entry points:
- the proxy refuses a non-admin an agent of a workspace they can't use, and
  /list-apps answers with the request's workspace's agents (plain and detailed);
- a personal access token works in its own workspace: /v1/models, chat
  completions (404 for another workspace's agent) and MCP. A token whose owner left
  its workspace is refused;
- the Work Room lists the current workspace's root agents the caller may use.

With one workspace the clients' calls answer as before; test_client_contract.py is
unchanged. Administrators now pass every agent's allowed_for_roles, as the plan
decided, and the guides say so.
@antiv
antiv merged commit 7fd5a3f into main Nov 1, 2026
2 checks passed
@antiv
antiv deleted the workspaces-phase-2b branch November 1, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant