Repository navigation
fix(question): let the model set custom on a question - #45236
Closed
harshil-mistry wants to merge 1 commit into
Closed
harshil-mistry wants to merge 1 commit into
harshil-mistry wants to merge 1 commit into
Conversation
custom was declared on Info but the tools accept Prompt, so it never reached the model-facing schema and nothing in the repo ever set it. The renderer's `question()?.custom !== false` guard was therefore always true and the "Type your own answer" input could not be turned off, despite the tool description presenting it as a default. Moving it into `base` reaches Prompt while leaving Info's shape unchanged. Closes anomalyco#45230
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #45230
Type of change
What does this PR do?
The
questiontool's "Type your own answer" input cannot be turned off, even though the renderer implements the switch and the tool description advertises it.customwas declared onQuestionV2.Info, but both tools acceptQuestionV2.Prompt, which isSchema.Struct(base)and does not include it:packages/opencode/src/tool/question.ts:7—Schema.mutable(Schema.Array(Question.Prompt))packages/core/src/tool/question.ts:26—Schema.Array(QuestionV2.Prompt)So
customnever appears in the JSON schema the model sees, and acustom: falseemitted anyway would be dropped as an excess property. Grepping the repo, nothing assignscustomanywhere — the only reader ispackages/tui/src/routes/session/question.tsx:38:The value is always
undefined, socustom !== falseis alwaystrueand the input is always shown.Info.custom, its description, and that!== falseguard are all live code for a state that cannot occur.Meanwhile
question.txttells the model:"(default)" implies a reachable alternative.
The fix moves
customintobaseso it reachesPrompt.Infospreadsbase, so its shape is unchanged and nothing that consumesInfoneeds to change — the field simply becomes settable by the party that creates questions. Both the v1 and v2 tools pick it up, since both build their input fromPrompt.The alternative was to delete
custom, the guard, and the sentence from both descriptions. I went the other way because the rendering side is already complete and correct; only the input schema was missing the field. If the intent was forcustomto be host-controlled rather than model-controlled, say so and I will send the removal instead.How did you verify your code works?
packages/schema/src/question.tsparses clean underbun build --no-bundle(bun 1.4.0).I traced the field end to end before changing anything:
Prompt. A repo-wide grep forcustom:outside unrelated identifiers (customBorderChars,CUSTOM_PROVIDER_OPTION_VALUE, formatter/LSP config namedcustom) returns no assignment to a question'scustom.QuestionV2.Request.questionsisSchema.Array(Info), which already carriescustom, so wideningPromptneeds no change there.Promptbecoming structurally equal toInfois fine becausecustomis optional.question.tsx:38reads it and defaults to shown, which is the behaviour that is preserved when the field is omitted.So the change is additive: omitting
custombehaves exactly as today, and supplyingfalsenow reaches the guard that was already written for it.Screenshots / recordings
No visual change unless a caller opts out, which was previously impossible.
Checklist