Skip to content

Studio: put a just-created API token in the Agents command and API examples - #15890

Merged
shimmyshimmer merged 3 commits into
mainfrom
studio-api-token-commands
Oct 29, 2026
Merged

shimmyshimmer merged 3 commits into
mainfrom
studio-api-token-commands

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

What changed

After you create an API token on Settings > API, the commands and examples that need it now include it again, so you can copy them straight into a terminal.

Reported on r/unsloth: creating a token used to fill it into the commands for connecting clients, but after #15467 the API page's Agents tab only links to Settings > Agents, whose command never carried a token. The Settings > API examples also lost the token as soon as you left that tab.

  • Settings > Agents: the generated command and the subagent setup command get --api-key <new token> when Studio is reached on a non-loopback address (LAN, tunnel). Loopback stays keyless, since the CLI mints its own key there. Only a token created in this page session is used: an explicit key is cached by the CLI per server, so a stale one would replace a working saved key.
  • Settings > API: the Chat, Images / Video and Audio examples and the Agent access (MCP) section keep the new token after you switch tabs, close Settings, or press Done on the token card. They used to read it from the API tab's own state, which only one tab at a time keeps mounted.
  • API page (monitor): the "No API traffic yet" examples and the per-model example request dialog use the new token instead of sk-unsloth-YOUR_KEY, and the example box is redacted from reload snapshots when it holds a real token.

The token lives in a small in-memory store (fresh-api-key-store.ts): never persisted, gone on reload, and dropped when that token is revoked (matched on its key_prefix). The one-time "Your token" card is unchanged.

Settings > Agents right after creating a token, opened on a non-loopback address. The token is masked in the screenshot.

Agents command

Settings > API after switching to Remote & LAN and back, and the API page's examples.

API examples

How it was verified

  • npm run typecheck, npm run build, npm test (14377 pass, 0 fail). New tests/agents-fresh-api-key.test.ts covers the command with and without a fresh key, loopback staying keyless, revoke only dropping the matching token, and the Settings > API and API page wiring. Two layout tests that named the old revealed variable now name freshKey.
  • Local Studio from this branch, opened through a non-loopback hostname mapped to 127.0.0.1 so the commands take their LAN form: create a token, then Settings > Agents, Settings > API after switching tabs, and the API page. Same steps on the base bundle show no token / the placeholder.

Not tested here

Windows PowerShell commands were not run (same builder path, covered by the existing shell tests). A real LAN or tunnel client was not connected.

shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 29, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 29, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T05:02:02.428346Z 7734d51 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 203450155b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

commandOs,
selectedAgent,
modelArgs,
freshApiKey,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Redact token-bearing Agents commands from reload snapshots

When a token has been created and Studio is accessed through a non-loopback address, this now puts the raw token into both Agents commands, but their CopyableCode renderer has no data-reload-snapshot-sensitive marker. Reloading with either command visible therefore lets public/reload-snapshot.js clone the token into sessionStorage and restore it in the reload overlay, even though the new store is intended to keep it memory-only and discard it on reload. Mark both token-bearing command blocks as sensitive, as the API example boxes already do.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7734d51: the Agents command and subagent setup command carry data-reload-snapshot-sensitive whenever they hold a fresh key, so reload-snapshot.js clears them.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 7734d51874

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shimmyshimmer
shimmyshimmer merged commit 3db27a2 into main Oct 29, 2026
28 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-api-token-commands branch October 29, 2026 05:52
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.

1 participant