Skip to content

feat: agents ask for keys on a private card instead of in chat - #1000

Merged
badcuban merged 2 commits into
mainfrom
feat/secure-chat-keys
Nov 18, 2026
Merged

badcuban merged 2 commits into
mainfrom
feat/secure-chat-keys

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

An agent that needed an API key asked for it in chat, so a pasted key landed in the thread's events, the database, logs and every connected app.

A new secret_request tool puts a card above the message box. The user's answer goes over its own RPC (secretRequest.respond) to one destination, chosen when the agent asks:

  • env_file: a NAME=value line in a git-ignored, untracked env file in the thread's folder. The request is bound to real paths when asked and checked again at the write, which is always a rename. In a repository the temp copy sits under .git/threadlines-secret-saves, so a checkpoint's git add can't stage it.
  • commands: an owner-only file under <state>/agent-secrets/<thread hash>/<request>/value, removed after 24 hours, on Remove now, and on archive, delete or move.

Events, projections, logs and other clients hold only the name and the outcome. The first device to press Save wins, a retry gets the stored answer, values are never trimmed, and a save cut off by a restart settles without writing again. The asking agent gets one message with the outcome; Not now and cancels reach it as a note at its next turn. The card says plainly that the agent can still read the key: it runs as the user.

Also in this PR:

  • The server secret store removes leftover temp copies at startup and creates temp files owner-only.
  • secret_request is loaded up front, so agents don't fall back to asking in chat. That adds about 1.3 KB to every Claude request (agentContextBudget.json updated on purpose).
  • The Claude replay fixtures were re-recorded because allowedTools gained secret_request.
  • Migration 121 adds projection_threads.secret_requests (nullable, no backfill).

Design: docs/design/secret-requests.md. Step 2, hiding a key a command later prints, is not built.

An agent that needed an API key asked for it in chat, so a pasted key
landed in the thread's events, the database, logs and every connected app.

A new secret_request tool puts a card above the message box. The user's
answer goes over its own RPC to one destination: a NAME=value line in a
git-ignored env file in the thread's folder, or an owner-only file for the
agent's commands that is removed after 24 hours. Events, projections, logs
and other clients hold only the name and the outcome. The first device to
press Save wins, a retry gets the stored answer, values are never trimmed,
and a save interrupted by a restart settles without writing again. The
existing secret store now removes leftover temp copies and creates its
files owner-only.

Design: docs/design/secret-requests.md. Step 2 (hiding a printed key) is
not built.
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 18, 2026 11:34pm UTC

Request Review

…acktracking regex

CodeQL flagged js/polynomial-redos: a multi-line key with a long run of tabs
made the edge-whitespace regex slow. Both helpers now scan the closing line
breaks and spaces directly.
@badcuban
badcuban added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit c7c5c47 Nov 18, 2026
24 checks passed
@badcuban
badcuban deleted the feat/secure-chat-keys branch November 18, 2026 23:50

This branch was previously deployed

1 inactive deployment
Preview — b411e26a Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants