Skip to main content

Re-own the shared agent

The symptom. Every chat turn fails, immediately and identically, with a message ending:

Agent 'prism' already exists but is not reachable by 'prism-provisioner' —
it is owned by another identity and not scoped to the shared workspace, so it
can be neither used nor replaced. It needs re-owning in the runner database:
an administrator runs reown_shared_agent.py once. See 'Re-own the shared
agent' in the Prism install docs.

Nothing else is wrong. The self test's runner line is green, sign-in works, ingest keeps running, and no upgrade fixes it.

Why. Prism keeps one agent that everybody chats to. Older versions created it as whichever person chatted first and shared it by a flag the runner has since stopped reading; current versions create it as a fixed identity, prism-provisioner, and share it through a workspace. An install created before that change and upgraded since is left with an agent row owned by somebody the app can no longer act as — and the agent's name is unique, so the app can neither use it nor create a replacement. It is one row, created once, that no upgrade migrates.

This is a one-off repair. Afterwards Prism adopts the agent into the shared workspace by itself, on the next chat turn.

What it does not touch. Only the agent row and the MCP profiles attached to it, and only their owner. No chat history, no sessions, no feedback, no ingested data, and nothing belonging to any other agent.

Before you start​

You need three things:

  • The script, scripts/reown_shared_agent.py, in the chart tarball — helm pull and untar leaves it at prism/scripts/reown_shared_agent.py.
  • The runner database DSN, which is the runner-database-url key of the install's Secret. It already has the right host, database, user, password and sslmode; use it as it stands rather than rebuilding it.
  • Somewhere to run it with Python 3 and asyncpg, that can reach that database. If the database has no route from your workstation — a private endpoint, a peered network — the prism-app container already has both, and the second recipe below runs the script inside it without installing anything.

Read the DSN out of the Secret:

RUNNER_DSN=$(kubectl get secret <secret name> -n <namespace> \
-o jsonpath='{.data.runner-database-url}' | base64 -d)

The Secret is <release>-secrets unless you set existingSecret, in which case it is yours and you know its name.

Confirm the three values that identify the row, from the app's own environment — the script defaults to internal, default and prism, which is right for most installs and wrong for any install that set them:

kubectl exec deploy/<release>-app -n <namespace> -- \
printenv CUSTOMER_ID PROJECT_ID AGENT_SLUG

Pass anything that differs as --customer, --project and --slug.

Step 1 — the dry run​

The script writes nothing unless you pass --apply, so the first run is a report. From a machine that can reach the database:

python3 prism/scripts/reown_shared_agent.py --dsn "$RUNNER_DSN"

If the database is only reachable from inside the cluster, pipe the script into the app's container, which has Python and asyncpg already:

kubectl exec -i deploy/<release>-app -n <namespace> -- \
env RUNNER_DATABASE_URL="$RUNNER_DSN" python3 - \
< prism/scripts/reown_shared_agent.py

Both print the same thing, in two sections — the shared agent (prism), then the restricted agent (prism-scoped) that viewer scoping uses — and for each: the agent's id, its current owner, the workspace it is in (left alone deliberately — that is the part Prism repairs itself), and every MCP profile attached to it with its owner. The restricted agent's section also reports its workspace; see The restricted agent below.

Read the output before you go on. Three outcomes, for each section:

What it saysWhat it means
would re-own to 'prism-provisioner': the agent, N profile(s)This is the fault. Continue.
already owned by 'prism-provisioner' — nothing to doWhatever is wrong, it is not this. Stop, and see Troubleshooting.
no agent 'prism' in .../... — nothing to repairYou are looking at the wrong database, or the wrong customer, project or slug. Check them before running anything else.
no agent 'prism-scoped' ...Normal on most installs; see The restricted agent.

The owner it reports will be an identity nobody recognises — an id from the directory, not an email address. That is expected, and is the whole fault: it is an id no later sign-in ever reproduced.

Step 2 — apply​

Whichever of the two you ran, the same command again with --apply on the end. In the piped form that goes before the <, not after it — everything after python3 - is an argument to the script:

python3 prism/scripts/reown_shared_agent.py --dsn "$RUNNER_DSN" --apply

kubectl exec -i deploy/<release>-app -n <namespace> -- \
env RUNNER_DATABASE_URL="$RUNNER_DSN" python3 - --apply \
< prism/scripts/reown_shared_agent.py

It moves the owner of the agent and of its attached MCP profiles, in one transaction, and prints applied.. Re-running it changes nothing — the second run reports already owned.

Step 3 — prove it​

Ask Prism a question. The turn that failed before now answers, and the first one also does the adoption the script left alone: the agent and its profiles join the shared workspace, so every other user is fixed by the same turn.

Then run the self test, which exercises the same provisioning path deliberately rather than incidentally.

The restricted agent​

With viewer scoping on, Prism answers viewers whose access is limited to their reporting line with a second agent, prism-scoped, which lives in a workspace of its own, prism (scoped), owned by Prism's own identity. The repair above covers it too: a prism-scoped row owned by someone else strands it exactly as it strands the shared agent, and the same run re-owns it. Only its own profile, Semantic Query (scoped), is re-owned with it; any other profile attached to it is somebody's own, and Prism detaches it by itself.

The restricted agent's section also checks five things about that workspace. Prism refuses every restricted viewer while any of them holds, or while a workspace of that name belongs to someone else (below), because each would put the same content in front of every restricted viewer, whatever their reporting line:

The script printsThe viewer is told
REFUSED workspace 'prism (scoped)' shares sessions between usersthe restricted agent's workspace shares conversations between users
REFUSED workspace 'prism (scoped)' has instructions setthe restricted agent's workspace has instructions or a description
REFUSED workspace 'prism (scoped)' has a description setthe restricted agent's workspace has instructions or a description
REFUSED workspace 'prism (scoped)' has N knowledge base(s) linkeda knowledge base is linked to the restricted agent's workspace
REFUSED workspace 'prism (scoped)' holds N uploaded file(s): '...'files have been added to the restricted agent's workspace

It checks the workspace named prism (scoped): the agent runner allows one workspace of a name per project, so there is at most one. It checks it whether or not the restricted agent exists yet, because Prism checks it before creating the agent.

If that workspace is owned by anyone but Prism, the script reports it as refused and names its owner. Prism will not use a workspace somebody else owns, because its owner could put anything in it, and while it holds the name Prism cannot create its own. Its owner has to rename or delete it. The script never changes a workspace Prism does not own.

The script exits with status 3 while any of these holds. It does not change them unless you ask it to: nothing should ever be added to that workspace, but what has been added may be somebody's work. You cannot change the workspace through the agent runner yourself, because only its owner can, and its owner is Prism. When you have decided, run the script again with --fix-restricted-workspace. It names what it would remove, and writes only with --apply:

python3 prism/scripts/reown_shared_agent.py --dsn "$RUNNER_DSN" --fix-restricted-workspace
python3 prism/scripts/reown_shared_agent.py --dsn "$RUNNER_DSN" --fix-restricted-workspace --apply

In the in-cluster form, the flags go after python3 -, as in step 2.

In one transaction, it turns session sharing off, clears the instructions and the description, unlinks each knowledge base (the knowledge base itself is kept, and stays linked anywhere else it is), and deletes the database records of the files uploaded to that workspace. The files' contents are kept by the agent runner's file store, not its database: the script prints where each one is stored (stored at), and removing them from there is yours to do. Nothing else is touched: not the shared agent, not its workspace, not any other.

One more refusal no flag of this script can clear. The agent runner's long-term memory is kept per person, so a restricted viewer's agent with memory on would recall what the same person's other agents stored. Prism turns memory off on the restricted agent, and refuses restricted viewers on an agent runner that has no per-agent memory switch:

The script printsWhat it means
REFUSED this agent runner has no per-agent memory switch, ...Restricted viewers are in use (the restricted agent or its workspace exists), and are refused until the agent runner is upgraded to one with the switch.
NOTE this agent runner has no per-agent memory switch: ...Nothing restricted exists yet. That is also what an install with viewer scoping on looks like on such a runner, because Prism refuses before creating anything. The script cannot tell whether viewer scoping is on.

The script detects the switch from the agent runner's database. An agent runner image rolled back after its database was upgraded is not detected: the database still has the switch while the running agent runner does not, and Prism refuses restricted viewers all the same.

A NOTE that the restricted agent has memory on needs no action: Prism turns it off on the next restricted viewer's question.

A NOTE that the restricted agent carries other profiles than Semantic Query (scoped) needs no action: Prism detaches the others itself on the next restricted viewer's question.

If it does not work​

Send us the dry run output — not the apply — plus the error the chat turn gives afterwards. The dry run names the ids and owners involved and contains no credential, so it is the one artefact worth attaching.

Two failures worth recognising first:

  • unrecognized configuration parameter on connecting means the DSN carried something the script did not strip. It strips uselibpqcompat, the one the chart adds; report the rest.
  • A connection that hangs or is refused is the route, not the repair. The database is not reachable from where you ran it; use the in-cluster recipe in step 1.