Skip to content

fix(acp): show questions that only mention secrets - #62187

Open
neriousy wants to merge 2 commits into
devfrom
acp-question-secrets
Open

neriousy wants to merge 2 commits into
devfrom
acp-question-secrets

Conversation

@neriousy

@neriousy neriousy commented Nov 5, 2026

Copy link
Copy Markdown
Member

What was wrong

With opencode acp and a client that supports elicitation.form, the question tool silently held back any question whose key, title, description or option labels mentioned a password, token, secret, API key or credential. That happened even when the user could only pick from fixed choices, for example "Which API token should I use?" with options Alpha and Beta. The model then got the generic "couldn't be shown in this client" message. It read that as the client being unable to show questions, so it didn't rephrase.

Root cause

requestedSchema in packages/cli/src/acp/elicitation.ts ran the credential regex over every field's prose and dropped the whole form on any match. It didn't check whether a field could actually take a typed answer. Questions from the question tool always allow a typed answer (custom: true, sent as an extra <key>_custom string property). So the only part of those forms that could collect a secret was that typed field, not the choices.

Fix

  • When a field with choices looks like it's about a secret, OpenCode sends it with only its choices and drops the typed <key>_custom property. A closed set of choices can't collect a secret.
  • A free-text field that looks like it asks for a secret (no options, or an empty option list) still keeps the whole form from being sent, as before.
  • Boolean and number fields are no longer blocked because of how they're worded.
  • When a question is held back for this reason, the model now gets SecretQuestionMessage. It explains why the question wasn't shown and tells the model to reword the question, offer fixed choices, or ask in its reply. Clients that can't show forms still get the existing generic message.
  • The ACP docs now describe this behavior.

No feature flag: this is a bug fix that narrows an existing guard. The guarantee in the docs still holds: OpenCode never sends a field that can take a typed answer when that field looks like it's asking for a secret.

Verification

  • New tests in packages/cli/test/acp/elicitation.test.ts failed on dev and pass with this change:
    • A required single-select with custom answers ("Which API token should I use?"), a multiselect whose description and option label mention secrets and tokens, a boolean and an integer field are all sent. The q0_custom / q1_custom properties are left out.
    • Over the ACP wire, a free-text question asking for an API key isn't sent as elicitation/create, and the form is cancelled with SecretQuestionMessage.
  • Existing tests still pass: free-text credential fields are still held back, including a credential-like custom select with no options.
  • bun test test/acp/elicitation.test.ts test/acp/turn.test.ts test/acp/session.test.ts test/acp/prompt.test.ts and bun typecheck in packages/cli.

Visual

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 72" width="240" height="72" fill="none" stroke="currentColor" font-family="ui-sans-serif,system-ui,sans-serif" font-size="9">
  <style>
    .typed{animation:typed 4s ease-in-out infinite}
    .pick{animation:pick 4s ease-in-out infinite}
    @keyframes typed{0%,25%{opacity:.5}45%,85%{opacity:0}100%{opacity:.5}}
    @keyframes pick{0%,45%{fill-opacity:0}60%,90%{fill-opacity:.35}100%{fill-opacity:0}}
    @media (prefers-reduced-motion:reduce){.typed,.pick{animation:none}.typed{opacity:0}}
  </style>
  <rect x="20" y="6" width="200" height="60" rx="8" stroke-opacity=".4"/>
  <text x="32" y="22" fill="currentColor" stroke="none" fill-opacity=".85">Which API token should I use?</text>
  <rect class="pick" x="32" y="30" width="56" height="14" rx="7" fill="currentColor" fill-opacity="0" stroke-opacity=".6"/>
  <text x="47" y="40" fill="currentColor" stroke="none" fill-opacity=".8">Alpha</text>
  <rect x="94" y="30" width="56" height="14" rx="7" stroke-opacity=".6"/>
  <text x="111" y="40" fill="currentColor" stroke="none" fill-opacity=".8">Beta</text>
  <g class="typed">
    <rect x="32" y="49" width="176" height="12" rx="3" stroke-dasharray="3 2"/>
    <text x="38" y="58" fill="currentColor" stroke="none">Type your own answer</text>
  </g>
</svg>

Closes #61283

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. I checked it with the ACP tests: the PR's new elicitation tests fail on dev and pass here, and the ACP elicitation, turn, session and prompt test files and tsc -b in packages/cli all pass. The guard still holds: a field that mentions a secret and has no choices still keeps the whole form from being sent. Questions from the question tool are never required, so dropping <key>_custom only takes away the typed answer. websearch.provider forms already use custom: false, so they're unaffected.

Public API: unchanged. SecretQuestionMessage is a new export inside packages/cli only. The visible changes are which ACP elicitation schemas get sent and the message the model gets back, and the docs now describe both.

No blocking concerns.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new commit only adds an end-to-end test, and I have no concerns. It runs the real opencode acp subprocess: a choice question that mentions an API token is now sent with only q0, and a typed API-key question is held back with SecretQuestionMessage. The test fails on dev and passes here. It passed 3 runs in a row, and all of test/acp/ (103 tests) and tsc -b in packages/cli pass. The helper now answers requests from the agent through onRequest, or with a -32601 error when there's no handler, and none of the other subprocess tests are affected.

Public API: unchanged.

My earlier review had no open points.

This branch has not been deployed

No deployments
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.

ACP question tool silently drops questions whose text merely mentions "token"/"secret"/"API key"

1 participant