Skip to content

fix: suppress misleading "Did you mean" suggestions - #17

Open
anmarhindi wants to merge 2 commits into
openai:mainfrom
anmarhindi:fix-suggest-threshold
Open

anmarhindi wants to merge 2 commits into
openai:mainfrom
anmarhindi:fix-suggest-threshold

Conversation

@anmarhindi

Copy link
Copy Markdown

Summary

suggestCommand previously printed a suggestion for every unknown subcommand, even when the best jaro-winkler match was barely related. Two visible failure modes:

$ openai responses zzzzz
No help topic for 'zzzzz'. Did you mean ''?

$ openai totallybogus
No help topic for 'totallybogus'. Did you mean 'openai completions'?

Add a minimum similarity threshold below which suggestCommand returns "". The upstream urfave/cli error formatter already omits the suggestion clause when the function returns an empty string, so the user just sees No help topic for 'X'. cleanly.

After

$ openai responses zzzzz
No help topic for 'zzzzz'

$ openai totallybogus
No help topic for 'totallybogus'

$ openai responses creat
No help topic for 'creat'. Did you mean 'openai responses create'?

$ openai chat:completion
No help topic for 'chat:completion'. Did you mean 'openai chat:completions'?

Why 0.7

I measured jaro-winkler scores against the real top-level commands. Real typos score 0.78-1.00 (e.g. creat -> create = 0.97, comp -> completions = 0.87, lst -> list = 0.93). Unrelated input scores at most 0.557 (totallybogus -> completions). A threshold of 0.7 sits in the gap, and conveniently matches the existing boostThreshold constant inside jaroWinkler itself — the prefix boost only kicks in past 0.7, so it's a natural "plausibly the same word" cutoff.

Verification

  • go test ./pkg/cmd/ -run TestSuggest — new table-driven coverage of close typos, exact matches, unrelated input, low-similarity input, empty input, and empty command lists.
  • Manually exercised the four cases above against a freshly built binary.

Closes #16

@anmarhindi
anmarhindi requested a review from a team as a code owner May 14, 2026 15:26
@markstuart-oai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 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-09-06T01:31:21.775405Z d33f1b3 Manual request
🔒 Security Review Completed 2026-09-06T01:30:51.084094Z d33f1b3 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

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: d33f1b3c9d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: d33f1b3c9d

ℹ️ 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".

Comment thread pkg/cmd/suggest.go
if provided == "" {
return ""
}
distance := suggestionThreshold

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 Preserve suggestions for short command typos

For short command names, a normal one-character omission can score below this fixed threshold because the Jaro match window becomes zero. For example, openai fine-tuning:alpha:graders rn compares rn with the real run subcommand at only 0.611, while validate scores 0, so this change returns no suggestion even though the previous implementation unambiguously suggested run. Use a length-sensitive threshold or an edit-distance exception so ordinary typos of short commands are not suppressed.

Useful? React with 👍 / 👎.

@saioai saioai 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.

requesting changes. short typos like rn and rnu still lose the correct run suggestion. please preserve those hints and add tests using the real command tree.

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.

Unknown-command suggestions are empty or misleading

3 participants