Skip to content

Keep a person's chats inside the workspace they were started in - #62

Closed
gek1980 wants to merge 1 commit into
packstub:mainfrom
Biz-lab-ai:tenant-wall
Closed

gek1980 wants to merge 1 commit into
packstub:mainfrom
Biz-lab-ai:tenant-wall

Conversation

@gek1980

@gek1980 gek1980 commented Nov 17, 2026

Copy link
Copy Markdown

Hi, we run the agents plugin on a Filament panel with tenancy (one person often belongs to several businesses) and plan to keep using and contributing to it.

The problem

Conversations are keyed by the participant alone. A person who is a member of two workspaces sees, opens and searches the chats of both: a chat started in workspace A shows up in the sidebar and the chat list of workspace B, and the turn endpoint accepts it there — so B's tools run with A's history in the prompt.

By the threat model in SECURITY.md this stays within what that same person could see by hand, so we are sending it as a regular pull request rather than by email. Please relabel the changelog line if you see it differently.

The change

  • A migration adds a nullable tenant column (with an index) to agent_conversations.
  • AgentConversationStore::conversationsOf($participant) is the one query for "this person's chats": participant, plus the current tenant when there is one (Agents::tenant()).
  • storeConversation() records the current tenant; conversationBelongsTo() also checks it.
  • AgentChat (list, search) and AgentTurns::owned() use conversationsOf().
  • Without tenancy nothing changes: tenant stays null and no filter is added.

Upgrading: run php artisan migrate. In apps with tenancy, chats stored before the migration have no tenant and stay hidden until it is filled in — we chose hiding over guessing which workspace they belong to; happy to change that if you prefer a different default.

Tests

  • New tests/Feature/TenantWallTest.php; PostedAndDeferredTest now expects another workspace's conversation to be refused.
  • composer test: 131 passed. Without the src change the new test fails.

A companion pull request in packstub/filament-agents moves the Chats page and the sidebar onto conversationsOf(); it needs this one released first.

🤖 Generated with Claude Code

One person who belongs to two workspaces saw, opened and searched the chats
of both: conversations were keyed by the participant alone. A conversation
now records its workspace and every lookup of "the person's chats" filters
by the current one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQ7RLkriGEGCWb5ydUfdzf
@icaliman

Copy link
Copy Markdown
Member

Thank you, this is a great catch and a clean change. It's merged as #65 with your commit kept as it was, rebased onto 1.12.0. On top of it, the migration now fills in tenant for existing chats from their turns, so they stay visible after the upgrade instead of hiding, and it reads the table name from ai.conversations.tables.conversations. It goes out in 1.13.0 today, and then filament-agents#98 can follow.

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