Skip to content

Share one question-form translator for ACP and Codex and support optional questions - #6476

Closed
ymichael wants to merge 8 commits into
mainfrom
bb/swing-2c-question-forms-thr_yvchv5bwp9
Closed

ymichael wants to merge 8 commits into
mainfrom
bb/swing-2c-question-forms-thr_yvchv5bwp9

Conversation

@ymichael

@ymichael ymichael commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

ACP and Codex each translated MCP-style requestedSchema forms into bb questions with their own code, and both mapped onto a question type that could not say a field is optional. ACP split "Other" free-text companions into separate required questions (#6031), ignored requestedSchema.required (#6131), counted the 4-question cap before folding and reported unsupported forms to the agent as a user decline (#6266).

What changed

One translator in @bb/provider-bridge-protocol/bridge-kit/elicitation-form now normalizes and validates these forms for both the ACP bridge and the Codex plugin (Codex reaches it through a new internal_DO_NOT_USE_ SDK subpath, recorded in docs/api_to_audit.md; plugin SDK bumped to 0.6.98). Questions gain required (default true), and the shared question UI and CLI label optional ones.

Wire change: HOST_DAEMON_PROTOCOL_VERSION 257 → 258. A 257 daemon would strip required: false and the server would default it back to true, so daemons must update before connecting.

Visible behaviour changes:

  • ACP folds a choice field <name> and an optional plain-text <name>__other or <name>_other field into one question with free text, for every agent; no dialect is involved. When the choice has an exact other value, that option is hidden and typed text selects it (Droid); otherwise typed text goes only to the companion (omp). A required choice without an other value, a required companion, or a formatted companion stays separate. Option labels are never matched, so the old English “Other” label matcher is gone.
  • ACP honors requestedSchema.required. Unanswered optional questions are omitted; the shared UI and CLI label them Optional. Existing non-ACP questions remain required through the domain parse default and explicit provider construction.
  • ACP counts the four-question cap after folding, and reports unsupported forms as errors with reasons. Cancellation remains a distinct path.
  • ACP uses the same schema normalization as Codex, but does not validate answers against formats, lengths, bounds or item counts: the generic question form cannot show those errors, so a failed check would reach the agent as a user decline. Answers are converted to their types (choices, Yes/No, numbers) and passed through for the agent to check, and prompts state the constraints (for example "Enter a whole number, between 1 and 5."). Codex keeps strict validation, since its own form shows errors next to each field.
  • Codex now renders supported flat forms carrying otherwise unknown schema keywords, rather than rejecting those keywords. Unknown keywords such as pattern are ignored; this is not a general JSON Schema validator. The common parser also accepts the ACP choice variants described above.
  • Daemons below protocol 258 must update before connecting.

How you verified

The three issue bodies and comments in the Swing 2 storage were compared against fetched main's planner and bridge.

acp-main.log: 7 failures / 4 passes when the new planner tests run against main's production planner. Several failures cover the issue regressions; the diagnostic wording assertion also changes intentionally.

Passed:

  • After switching to shape-based folding and pass-through answers: full ACP suite 562 passed / 4 skipped; ACP lint and typecheck passed. Planner tests cover both suffixes, the cases that stay separate, pass-through answers and constraint hints; bridge integration folds both the omp and Droid shapes in a generic session.
  • Full domain suite: 294 tests.
  • Full host-daemon-contract suite: 76 tests.
  • Full provider-bridge-protocol suite: 340 tests.
  • Full ACP suite: 550 passed, 4 skipped, before the final choice-preservation correction.
  • Full Codex suite: 512 tests, before that correction.
  • After that correction: ACP elicitation 13, shared elicitation 28, Codex elicitation 114 tests.
  • Shared question UI and pending banners: 57 tests.
  • Public server interactions: 27 tests (real migrated SQLite).
  • CLI interaction output/answers: 24 tests.
  • Claude interaction adapter: 25 tests.
  • SDK export contract: 1 test; SDK declaration generation passed.
  • Lint/typecheck: 29 tasks across changed packages and consumers; focused checks and SDK types repeated after the final parser correction (13 tasks). Existing app lint warnings, zero errors.
  • ACP recorded parity against main: 9 replayable cells passed, model-list skipped as process-scoped. The repository allowlist fails on stale expected differences; an empty local allowlist gives exact parity. Repository allowlist unchanged.
  • git diff --check; targeted formatting; final code/style review.

Limits: no live omp/Droid session, browser journey, or iOS verification was run. UI verification is component-level. The verification inventory preflight reports an existing unmapped diagnostics CLI family; no unrelated inventory rewrite was made. Recorded ACP parity uses Cursor recordings, so it supplements rather than replaces the omp/Droid planner regressions.

The shared translator replaces the Codex-local copy; no sibling implementation is retained.

Fixes #6031
Fixes #6131
Fixes #6266

🤖 Generated with Claude Code

AGENT GENERATED

ymichael and others added 7 commits October 28, 2026 14:55
…elds

Move Codex's requestedSchema normalizer and content validator into the
bridge kit so the ACP bridge and the Codex plugin use one copy, exposed to
Codex through @get-bb/plugin-sdk/provider-bridge/elicitation-form.

The ACP planner now reads requestedSchema.required, folds a choice field
and its <name>__other / <name>_other text field into one question with free
text, counts questions after folding against the 4-question limit, and
answers a form bb cannot show with a JSON-RPC error that names the reason
instead of a decline.

User questions gain a required flag (default true at the parse boundary).
The server, the shared question form, and bb thread interactions answer
accept a blank answer only for an optional question.

Fixes #6031, #6131, #6266.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shared requestedSchema parser came from the Codex renderer, which
rejected any key it did not know. ACP's old planner ignored them, and
omp's ask tool puts a description on every choice, so the strict parser
refused omp's real forms outright. Unknown keywords (option and field
descriptions, pattern, additionalProperties) are now stripped for both
providers; a Codex form with such a keyword renders instead of being
refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/swing-2c-question-forms-thr_yvchv5bwp9 branch from 9899e1c to b855da1 Compare October 28, 2026 21:56
Fold an optional plain-text <name>__other or <name>_other field into its
choice for every ACP agent instead of only omp and Droid dialect sessions,
so Droid launched by a plugin that sets no dialect gets the fix. A required
choice without an "other" value keeps its companion separate, since typed
text alone could not fill it. The droid dialect and its docs are removed.

The bridge no longer validates answers against format, length, bounds or
item counts before replying. The generic question form cannot show those
errors, so a failed check reached the agent as a user decline. Prompts now
state the constraints, and the agent checks the values it receives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael closed this Oct 28, 2026
ymichael added a commit that referenced this pull request Oct 29, 2026
… folding, 10-question cap, long titles (#6518)

## Human comments

## What was wrong

bb's user question could not say that a question is optional, and it
allowed at most 4 questions. Several paths also turned "bb could not
show this" into a statement about the user:

- **ACP (`packages/provider-bridge-acp/src/elicitation.ts`).** The ACP
parser ignored `requestedSchema.required` and planned one question per
form field. omp (`qN` + `qN__other`) and Droid (`question_N` +
`question_N_other`) each send a choice plus an optional "Other" text
field, so one question became two required questions (#6031, #6131).
Because the parser counted fields rather than questions against the cap,
a two-question omp form or a four-question Droid form was refused
(#6266, #6508). A refused form went back to the agent as `{action:
"decline"}`, i.e. a user decline (#6266).
- **ask-user-question.** The plugin capped a call at 4 questions, so
larger planning rounds were split across several interruptions (#3264).
- **Pi and Codex async questions.** Core rejects interaction titles over
160 characters. Pi accepted titles up to 200 characters and answered
both its own validation failure and core's rejection with `{ cancelled:
true }`, so the extension reported that the user declined. Codex async
questions used the raw question as the title, so any question over 160
characters never opened a card (#4264).

This replaces #6476 with a smaller scope: no shared Codex/ACP form
translator, no new plugin-SDK subpath, and Codex's form parser is
unchanged.

## What changed

1. **Optional questions** (`6dbd15064b`).
- `PendingInteractionUserQuestionQuestion` gains `required`; questions
persisted before this change parse as required.
- The shared question form labels optional questions "Optional" and lets
you submit without them.
- The server accepts a missing or empty answer only for optional
questions.
- The CLI's `bb thread interactions show` prints `Optional: may be left
unanswered`, and `answer` accepts answers that skip optional questions.
The guide template is updated.
   - Existing providers set `required: true` explicitly.
- **Wire change:** `HOST_DAEMON_PROTOCOL_VERSION` 257 → 258, because an
older daemon parses interaction payloads with the old schema and would
drop `required: false`.
- **Plugin SDK** 0.6.97 → 0.6.98, because the SDK's bundled types
include the user question type.
2. **ACP fixes, in ACP's own parser** (`04514cb8af`).
- Fields not listed in `requestedSchema.required` become optional
questions; unanswered ones are left out of `content`.
- A choice field `X` absorbs an optional plain-text `X__other` or
`X_other` field into one question with free text. If the choice has an
`other` value, that option is hidden and typed text selects it (Droid).
Otherwise typed text goes only to the companion field (omp). A required
choice without an `other` value keeps its companion as a separate
question. Option labels are never matched.
   - The question cap is counted after folding.
- A form bb cannot show is answered with a JSON-RPC error (`-32602`, `bb
cannot show this form: <reason>`) instead of a decline.
3. **Cap raised to 10 questions** (`030c89be6c`):
`USER_QUESTION_MAX_QUESTIONS`, plus the ask-user-question tool's schema,
description and overview.
4. **Long titles shortened, not rejected** (`8d247d87c1`).
- **Pi:** accepts long extension dialog titles, shortens the card
heading to 160 characters, and carries the full title in the payload
(`fullTitle`), which the card shows.
- **Codex async questions:** shortens the heading; the card already
shows the full question.
5. **Question tabs on narrow cards** (`771e53b6f1`). With more
questions, the tab row ran off phone-width cards.
- Whenever the current question changes, only the tab row scrolls, so
the current tab sits clear of the edge.
- Each edge with more tabs past it fades into the card's
`surface-recessed-solid` background; nothing fades when every tab fits.
   - `OverflowFade` gains a `surface-recessed` tone.

### Still reported as a cancel or decline

- **omp 18.0.5:** bb now sends the error, and omp's log shows it
received `RequestError: bb cannot show this form: bb shows at most 10
questions and this form has 11` (code -32602). But this omp version
treats an error, a decline and a cancel the same way and tells its model
"Ask tool was cancelled by the user". Fixing what the model sees needs a
change in omp.
- **Pi:** Pi's RPC protocol has no error response. A malformed request,
a failed hand-off to bb, or an error coming back from bb still reaches
the extension as `{ cancelled: true }`. Shortening titles removes the
common cause.
- **ACP, failed hand-off:** a question that fails to reach bb after
planning, including a daemon interrupt, still answers the agent with
`cancel`.
- **ACP, unreadable answer:** a typed answer that does not fit its field
(for example "abc" for a number) still declines the whole form, as
before.
- **ask-user-question:** a question header over 160 characters makes the
tool call fail with an error that reaches the agent as a tool error, not
a decline.

## How you verified

**Regression tests (each fails on main, passes here):**
- ACP planner: omp and Droid folding, `required` handling, the cap
counted after folding, and Other labels not treated as the `other`
value.
- ACP bridge, through a fake ACP agent: both folding conventions end to
end, and an unshowable form answered with an error.
- Server public interactions route: optional answers.
- CLI `answer` with an optional question skipped.
- Shared question form: optional submit and the tab scrolling and fades.
- ask-user-question: tool schema and a seven-question call.
- Pi coordinator: titles of 160, 161, 200, 201 and 4096 characters.
- Codex async questions: a long title.
- Daemon contract: rejects 257, accepts 258.

**Suites:**
- `pnpm exec turbo run lint typecheck --filter='...[origin/main]'`
passes (153 tasks).
- Full suites pass for `@bb/server` (3726), `@bb/app` (6414),
`@bb/provider-bridge-acp`, `@bb/domain`, `@bb/host-daemon-contract`,
`@bb/cli`, `@bb/shared-ui`, `@bb/thread-view`, `@bb/plugin-registry`,
and the plugins `provider-codex`, `provider-pi`, `provider-claude-code`,
`ask-user-question` and `push-notifications`.

**Live, against `pnpm start:worktree` for this branch and for
`origin/main`, with real agents:**

| Issue | Agent | Main | This branch |
|---|---|---|---|
| #6031 | omp 18.0.5 `ask`, 1 question | 2 questions; `bb thread
interactions answer` with only the choice fails: `Missing answer for
question 'q0__other'` | 1 optional question. Typed "gamma-hotfix" via
Other in the UI; omp replied `You picked: gamma-hotfix` |
| #6508 / #6266 cap | omp, 5 questions (10 fields) | No card; "The agent
asked a question bb could not show" | One card, 5 tabs. Answers
(including custom text and a skipped question) reached omp |
| #6266 error | omp, 11 questions | Declined | bb sends the error (see
omp caveat above) |
| #3264 | Pi + AskUserQuestion, 7 questions | The model sent only D1–D4
because of the 4-question limit | One card, D1–D7; all 7 answers reached
Pi |
| #4264 Pi | Pi 1.4.0 extension `ui.select` with a 239-character
approval title | No card; the extension got `CANCELLED` | Shortened
heading with the full title in the card; the extension got `Allow for
session` |
| #4264 Codex | codex-cli 0.164.0 `request_user_input_async` (model
`gpt-6.1-terra`), 212-character question | `{"accepted":true}` but no
card; server log: `ui.requestInput title must be 1-160 characters` |
Card opened; the answer went back and Codex continued |

The tab strip was checked at 390px with 5 and 10 omp questions (first,
middle and last question) and at 1280px. Screenshots were taken in light
mode at desktop and phone widths.

**Not run live:** Droid (#6131), because it is not installed on the test
machine. Its `question_N` / `question_N_other` shape is covered by the
planner and bridge tests only.

Fixes #6031
Fixes #6131
Fixes #6266
Fixes #6508
Fixes #3264
Fixes #4264

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant