Files
PaperClipAI/docs/guides/board-operator/deleting-connection-data.md
T
DottaandClaude Opus 5.5 1fa6d71171 fix(connections): clear run answer copies and show reconnect state when Google access ends (#22937)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use Google Workspace through a connection, and Paperclip
saves what they read in runs and tool-call records
> - Google's Workspace AI Tools Addendum says Paperclip must keep no
user data from a connection after access ends. #22836 and #22842 delete
this content when access ends.
> - A live test found two gaps. The run record still holds the run's
final answer and its evidence (a Drive link, text from a Drive file).
And after a person removes Paperclip at their Google Account, the
connection still shows as healthy and agents still get its tools.
> - This pull request clears the answer and evidence copies in the run
record, and puts the connection in the existing "sign in again" state
when no grant on it is active.
> - The benefit is that no Google data stays in run records after
deletion, and people and agents see that the connection must be signed
in again.

## Linked Issues or Issue Description

Refs #22836

**What happened?**

1. After `tool_connection.content_deleted`, `GET
/api/heartbeat-runs/:id` still returned Google data. The data was in
`resultJson.nativeResult.evidence[].ref`, `verification[].detail` and
`commandOrCheck`, `completionClaim.criteria[].evidenceRefs[]`, and in
`runnerProfileJson.sessionCheckpoint` (`semanticResult` and
`terminalTurns[].fingerprint`, a 1.3 to 1.9 KB copy of the result).
2. After a person removed Paperclip at their Google Account, the next
Google call failed with `oauth_reauthorization_required` and the
deletion started with reason `provider_access_ended`. But the connection
status stayed `active` with healthy status, and agents were still
offered its 34 tools.

**What did you expect to happen?**

1. The deletion clears the run's answer and evidence copies the same way
it clears the transcript. The run keeps its status, ids, counts and
hashes, so the run page still shows.
2. The connection shows that it needs a new sign-in, and agents do not
get its tools until someone reconnects.

**Steps to reproduce**

1. Connect Google Workspace and let an agent run that reads a Drive file
and reports a link as evidence.
2. Remove the connection (or remove Paperclip at the Google Account and
let the next Google call fail).
3. Wait for `tool_connection.content_deleted`.
4. Open `GET /api/heartbeat-runs/:id` for that run. See the Drive link
in `resultJson.nativeResult` and in
`runnerProfileJson.sessionCheckpoint`.
5. For case 2, open the connection. See status `active` and health `ok`.
List the agent's tools. See the Google tools.

## What Changed

- `content-cleaning.ts`: add `withoutRunAnswers`. In every
`paperclip.run_result.v1` object in `result_json` (`nativeResult`,
`acceptedResult`, `semanticResult.result`), each free-text string
becomes the fixed text "Removed because the connection data was
deleted.", so the result still passes `validatePrpStructuredRunResult`.
Structural fields stay (schema, disposition, status, scope, reason
codes, Paperclip ids, booleans and numbers). Agent-chosen
`idempotencyKey` values become `sha256:` hashes.
- `content-cleaning.ts`: add `withoutCheckpointAnswers`. It cleans the
persisted checkpoint (`PersistedNativeSession`): `semanticResult` and
`governedWait.result` the same way, `governedWait.sourceEvent.payload`
free text, and each `terminalTurns[]` fingerprint becomes its `sha256:`
hash. The recovery hash is updated when it matched.
- Each store gets its own mark: `result_json.answerCopiesDeletedAt` and
`sessionCheckpoint.contentDeletedAt`. A run in scope whose result or
checkpoint lacks its mark is cleaned again. This fixes runs cleaned by
an older build and a checkpoint rewritten later.
- `paperclip-control-plane-port.ts`: a checkpoint written for a run
whose result has `contentDeletedAt` is cleaned before it is saved
(`checkpointProfileForRun`).
- `withoutResultText` no longer blanks fields inside a run result;
`withoutRunAnswers` owns those.
- `withoutFreeText` moves from `run-copies.ts` to `content-cleaning.ts`;
`native_run_results` gets the same treatment.
- The task text stays: `contextSnapshot.paperclipIssue.description` and
`runnerProfileJson.nativeExecutionInput.task` are the user's text, not
Google data.
- `grant-refresh.ts`: when a refresh marks a grant
`needs_reauthorization` and no grant on the connection is still active,
the connection gets the needs-attention state: health `error`, last
error `oauth_reauthorization_required`, message "Access to this app
ended. Reconnect to continue." The check and the write run under a row
lock on the connection, so a reconnect that finishes at the same time is
not overwritten. This applies to the Paperclip Cloud broker path and to
the direct token path for personal grants. Status and the enabled flag
do not change, so the app list shows "Needs attention" (not "Paused"),
and a reconnect keeps the chosen tools.
- `tool-gateway.ts`: agents are not offered a connection's tools (tool
list, tool search, and the prompt guidance for usable connections) while
the connection has a `needs_reauthorization` grant and no active grant.
An action that a person already approved still finds its tool and waits
for the new sign-in, as before.
- Plain copy: "OAuth authorization expired/has expired" becomes "Access
to this app ended. Reconnect to continue." in `connection-refresh.ts`,
`grant-refresh.ts`, `catalog/failures.ts` and `oauth/client.ts`.
- UI (`Connections.tsx`, `Browse.tsx`): the removal message and dialog
count a connection as "available to agents" only when agents are offered
its tools: it is on, it is not waiting for a new sign-in, and it is
healthy, personal or a plugin. New helper
`isConnectionAvailableToAgents` in `connection-identity.ts`.
- Docs: the inventory and access-end notes in
`doc/memory/google-connector-memory.md`, and the help page
`docs/guides/board-operator/deleting-connection-data.md`.

## Verification

- Red/green:
`server/src/__tests__/tool-connection-content-deletion.test.ts`,
"removes the run's final answer and evidence from its result and session
checkpoint, and keeps the task text". It failed before the fix (the
Drive link and quoted text stayed in `nativeResult`) and passes after.
It also checks that a run cleaned by an older build is cleaned again,
that the task text stays, that `hasAcceptedSemanticResult` is still
true, and that the recovery hash matches the new checkpoint.
- Red/green:
`server/src/__tests__/google-managed-connection-removal.test.ts`, "shows
a user/organization connection needs signing in again and stops offering
its tools after Google access ends". Before the fix, health stayed `ok`.
After the fix, health is `error`, the agent's tool list for the
connection is empty, and after a reconnect health is `ok` and the tool
comes back.
- The deletion test checks that the fixture result is valid and that the
cleaned `nativeResult` and checkpoint `semanticResult` still pass
`validatePrpStructuredRunResult`. It rewrites a dirty checkpoint on a
cleaned run and checks that the next deletion cleans it, and checks
`checkpointProfileForRun`. It uses the persisted checkpoint shape
(`semanticResult` is the run result, plus `governedWait`). A second
phase stores a legacy run (no `answerCopiesDeletedAt` mark) whose only
remaining text is `nativeResult.evidence[].ref` and the checkpoint
copies, with hashed fingerprints and blank summaries. The new selection
rule cleans it.
- `tool-access-oauth-protocol.integration.test.ts` still passes: an
approved action waits for sign-in and runs after reconnect. Its fixture
now also restores the health fields when it restores the connection by
hand.
- `ui/src/pages/apps/connection-identity.test.ts`: the new helper does
not count a connection that needs attention.
- Agents in the needs-attention state: the provider-ended test lists the
agent's tools before (1), after Google access ends (0) and after
reconnect (1). So agents are not offered the actions of a connection in
that state.
- On the final code: deletion, removal and OAuth protocol files 77/77;
`paperclip-control-plane-port.test.ts` 108/108; deletion and
reauthorization cases in `tool-access-service.test.ts` 9/9; UI helper
test 12/12. Server and UI typecheck pass.
- `tsc --noEmit` for `server`: pass.
- `pnpm verify`: see the comment below for the result.

## Risks

- Medium-low. The tool gateway now hides a connection's tools from
discovery when it has a `needs_reauthorization` grant and no active
grant. Before, a personal (`per_user`) connection in that state still
listed its tools, and each call failed. Execution of an already approved
action is not changed. Connections with no grants, or with one active
grant, do not change.
- Health `error` is set for any provider whose last active grant needs a
new sign-in, not only Google. This is the same state a direct token
refresh already uses.
- No schema change and no migration.
- Not covered: the encrypted controller checkpoint rows
(`native_runner_checkpoints`). The harness backup expiration removes
them. This is recorded in the memory doc.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used in Claude Code
with tool use (shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 10:31:28 -06:00

7.7 KiB

title, summary
title summary
Deleting Data Read Through a Connection Permanently remove what Paperclip saved from a connected app's tool calls

When an agent uses a connected app, such as Google Workspace, Paperclip saves part of what the app returned so you can review the work later. You can delete that saved data at any time, for any connected app.

What Paperclip saves

For each tool call an agent makes through a connection, Paperclip keeps:

  • A short preview of the request and the result (up to about 4,000 characters, with secrets removed)
  • For actions that needed approval, the preview and arguments shown on the approval card, and the result passed back to the agent
  • Interactive app views that a tool showed in a task
  • The transcript of the run that made the call, which can contain the full result, and of the run that received an approved action's result

For most apps, this data stays until you delete it, and removing the connection alone does not delete it. Google connections are different: see the next section.

Google connections: deleted when access ends

When Paperclip's access to a Google account ends, Paperclip deletes what agents read through that Google connection on its own. You do not need to select Delete data. This happens when:

  • You remove the Google connection.
  • Someone revokes a Google identity on the connection, a person's own or the organization's.
  • Someone removes Paperclip from their Google account, or Google ends the access, and Paperclip sees this the next time it renews the access.
  • The person who connected their Google account leaves the company.
  • Paperclip Cloud removes your Paperclip instance.

Deletion starts at once. Runs that are still working keep their data until they finish; Paperclip then deletes it too. While work is still running, Paperclip checks again every few minutes, and every hour after the first day. If a step fails, Paperclip keeps trying until it succeeds, also after a restart. The connection's activity shows when the deletion started and when it finished.

The connection then shows Needs attention, and agents are not offered its tools until someone signs in to Google again. The deletion covers everything listed under "What is deleted" for that connection, for all people who used it. If you connect Google again later, Paperclip saves new data from new calls only. Data that was deleted does not come back. Agents also do not resume the conversations of those runs; their next run starts a new one.

Technical details from Google

Paperclip keeps technical details it gets from Google, such as error messages and the descriptions of Google's tools, for at most 30 days. After that it deletes them on its own. When you remove a Google connection, it deletes them at once. The record that a call happened stays.

Paperclip does not use content from Google to train or test AI models. Feedback you share with Paperclip and decision training examples leave out runs that read from Google.

How to delete it

You need permission to manage the connection.

From the connection's page:

  1. Open Connectors and select the connection.
  2. At the bottom of the Permissions tab, select Delete data.
  3. Check the counts in the confirmation and select Delete data.

When you remove a connection:

  1. Open Connectors, open the connection's menu, and select Remove connection.
  2. Select Also delete data read through this connection. For a Google connection, this option is not shown, because the data is always deleted.
  3. Select Remove connection.

For a Google connection that Paperclip set up for you, removing the connection also asks Google to end Paperclip's access to that Google account. The message after removal tells you whether access was ended. If other Paperclip connections still use the same Google account, Google keeps Paperclip's access until you remove those too. If Google could not be reached or did not confirm, the message says so and Paperclip keeps trying in the background, for up to 30 days, even if Paperclip restarts. You do not need to do anything. The connection's activity shows when access was ended, or that Paperclip stopped trying. If Google gave a final answer that Paperclip cannot end the access, the message says so, and you can remove Paperclip from your Google account's third-party connections.

When you delete a company, Paperclip also ends its access at Google for every Google connection Paperclip set up for that company. This continues in the background after the company is gone. Connections that use your own Google OAuth app are removed only in Paperclip.

Deletion starts right away and continues in the background. It finishes even if Paperclip restarts while it runs. If a step fails, for example because file storage is unavailable, Paperclip keeps the request open and tries again until every step succeeds. It reports the deletion as finished only then. The connection's page shows when the data was last deleted.

What is deleted

  • Request and result previews for every call made through the connection before you asked to delete, including the copies in the connection's audit history
  • Approval previews, arguments and results for those calls, on the approval card and in what was passed back to the agent
  • Interactive app views from those calls
  • The whole transcript of every run that called the connection or received an approved action's result, including that run's other steps and its final summary
  • The final answer that run reported and the evidence it gave for it, such as links, quoted text and check details. The run page still shows the run's status and outcome.
  • Tool results too large to pass to the agent directly, which Paperclip saved as files for those runs
  • Error messages the app returned for those calls
  • The saved conversation that agents resume in later runs, for the runs whose transcript is deleted. The agent's next run starts a new conversation.
  • The run's error text, its copy in the task's continuation summary, the summary handed to the next run, and the run in any decision training example

What is kept

  • The record that each call happened: when, which tool, which agent, the outcome, the size of the data, and a fingerprint of it. Paperclip needs these for its activity history and usage counts. They do not contain the data.
  • Anything your agents wrote into tasks: comments, documents and files. This action does not remove them, even when an agent copied data from the app into them. Delete or edit those items yourself, or delete the task.
  • The connection's audit activity, which records counts only.
  • Transcripts of later runs that only read the context an interactive app view shared. Paperclip does not record which runs read it. Delete those tasks if you need that text gone.
  • Raw provider traces. An administrator must turn them on, and they expire on their own within 24 hours.

Deleting a task or a company

Deleting a task also deletes this data for the task's runs, from every connected app. Comments, documents and files in the task are deleted with it, including the files in storage. If a run of the task is still working, or an approval for it is still open, Paperclip waits for up to a day and then deletes the data on its own. After a day, it stops waiting and leaves what is still open.

Deleting a company deletes all of its data, including run transcripts and files in storage. Storage clean-up continues in the background after the company is gone, and Paperclip retries it until it succeeds.

Runs that are still working

Paperclip does not change a run while it is still working. The confirmation tells you how many runs are skipped for this reason. Select Delete data again after they finish.

It cannot be undone

Deleted data cannot be recovered.