Skip to content

Add workspace ID to room table during agent runs - #3083

Open
ckelly17 wants to merge 3 commits into
devfrom
claude/runagent-workspace-id-bug-whjyxf
Open

ckelly17 wants to merge 3 commits into
devfrom
claude/runagent-workspace-id-bug-whjyxf

Conversation

@ckelly17

@ckelly17 ckelly17 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Overview

AgentRunner overlaid the workspace on the room only for the duration of a run — setting it
in memory via applyWorkspaceOverlay and restoring the original state in finally. A room
started by RunAgent therefore never had WORKSPACE_ID or options.workspace persisted to
the database, unlike a room created with CreateRoom(workspaceId=[...]).

The impact is that rooms belonging to an agent are invisible to GetWorkspaceRooms and any
other workspace-scoped query, making agent conversation history effectively undiscoverable from
the workspace.

Changes

One targeted change in AgentRunner.run():

Save WORKSPACE_ID and options.workspace when RunAgent starts a room with no messages.
After the room is loaded and the workspace is resolved, if the room has no messages yet — meaning
this is the first run against it — both fields are written to the database. The check on message
count ensures that rooms already in use keep their saved workspace and are not silently
re-pointed by a later run that passes a different workspaceId. Rooms with existing messages
still get the per-run overlay as before.

The save is gated on the workspace being active and viewable by the calling user, matching the
same access checks applied elsewhere in the agent pipeline.

Reproduction and Testing

All runs used workspace 4b862ba6 ("MCP Model Detection Test") and model engine aa876e7e
(Claude Sonnet 4-6 Vertex). Before/after state was observed via
GetWorkspaceRooms(workspaceId=["4b862ba6-..."]).

Before fix: only the room explicitly created with CreateRoom(workspaceId=[...]) appeared.
Every room started by RunAgent was absent regardless of how many times it was reused.

# Room creation In GetWorkspaceRooms before In GetWorkspaceRooms after
1 RunAgent — new room, workspace passed No ✓ f137466f
2 CreateRoom(workspaceId) then RunAgent No ✓ a2a85513
3 CreateRoom(workspaceId) alone ✓ d6a880ce ✓ d6a880ce
4 Existing room with prior messages — rerun No Correctly absent — has messages, workspace not overwritten

After the fix, GetWorkspaceRooms returns all four rooms that belong to the workspace.
Existing rooms with prior messages are unaffected: they retain their persisted workspace and
still receive the per-run overlay for the duration of the run.

claude and others added 2 commits October 2, 2026 06:47
RunAgent only overlaid the workspace on the room for the length of a run,
so a room started by RunAgent never got ROOM.WORKSPACE_ID or
options.workspace saved, unlike a room created with CreateRoom. A run that
starts an empty room now saves both, after checking the workspace is
active and viewable by the user. Rooms that already have messages keep
their saved workspace and still get the per-run overlay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nRQJ4qQU5EHJvmuq96eDc
@ckelly17
ckelly17 requested a review from a team as a code owner October 3, 2026 19:15
@snyk-io

snyk-io Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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.

2 participants