Skip to content

feat: improve error resilience, add provider presets, boxed report outtput, and enhanced README - #6

Closed
tejasprasad2008-afk wants to merge 3 commits into
ni5arga:mainfrom
tejasprasad2008-afk:fix/error-handling-and-improvements
Closed

feat: improve error resilience, add provider presets, boxed report outtput, and enhanced README#6
tejasprasad2008-afk wants to merge 3 commits into
ni5arga:mainfrom
tejasprasad2008-afk:fix/error-handling-and-improvements

Conversation

@tejasprasad2008-afk

Copy link
Copy Markdown
  • Fix crash when OpenAI-compatible providers return non-standard error payloads (e.g. OpenRouter 504s missing the choices array)
  • Add automatic model fallback: when a retryable error (429/504/timeout) occurs, the client transparently retries with a known-good fallback model for the same provider
  • Add provider presets for 9 backends: anthropic, openai, openrouter, gemini, ollama, groq, together, nvidia, mistral — each with auto- configured base URLs, default models, and fallback models
  • Make LLM request timeout configurable via --timeout CLI flag (default: 70000ms primary, ~45500ms compressed fallback)
  • Wrap each finding in a colored box border (red for HIGH, yellow for MED, gray for LOW) for improved terminal readability
  • Expand README with Quick Start guide, Supported Providers table with setup examples, model fallback docs, and Troubleshooting section
  • Add tests for undefined choices, OpenRouter error payloads, automatic model fallback, and new provider preset resolution

istg vro its good . trust me.

…tput, and enhanced README

- Fix crash when OpenAI-compatible providers return non-standard error
  payloads (e.g. OpenRouter 504s missing the choices array)
- Add automatic model fallback: when a retryable error (429/504/timeout)
  occurs, the client transparently retries with a known-good fallback
  model for the same provider
- Add provider presets for 9 backends: anthropic, openai, openrouter,
  gemini, ollama, groq, together, nvidia, mistral — each with auto-
  configured base URLs, default models, and fallback models
- Make LLM request timeout configurable via --timeout CLI flag
  (default: 70000ms primary, ~45500ms compressed fallback)
- Wrap each finding in a colored box border (red for HIGH, yellow for
  MED, gray for LOW) for improved terminal readability
- Expand README with Quick Start guide, Supported Providers table with
  setup examples, model fallback docs, and Troubleshooting section
- Add tests for undefined choices, OpenRouter error payloads, automatic
  model fallback, and new provider preset resolution
@ni5arga

ni5arga commented Jun 3, 2026

Copy link
Copy Markdown
Owner

istg vro its good . trust me.

epic comment - will review soon.

Copilot AI 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.

Pull request overview

This PR strengthens the tool’s robustness and usability by improving handling of OpenAI-compatible provider quirks, adding provider presets + automatic model fallback, making timeouts configurable, and enhancing the human-readable report/README experience.

Changes:

  • Add provider presets for multiple OpenAI-compatible backends and extend provider parsing/validation accordingly.
  • Improve OpenAI-compatible client resilience (non-standard error payloads, retryable errors) and add fallback-model retry behavior with tests.
  • Add configurable LLM request timeouts and expand README documentation (quick start, provider setup, troubleshooting).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/report.ts Adds “boxed” rendering for findings with severity-colored borders/badges.
src/llm/types.ts Expands the Provider union to include additional backends.
src/llm/openai.ts Adds retryable-error detection, fallback model retry, and better handling for missing choices.
src/llm/openai.test.ts Adds coverage for undefined choices and fallback behavior.
src/llm/index.ts Introduces provider presets and improves provider normalization/error messages.
src/llm/config.test.ts Adds tests for new provider names and preset resolution.
src/index.ts Adds --timeout CLI flag and wires it into analysis options.
src/analyze.ts Makes timeouts configurable and derives a compressed-pass timeout from the primary.
README.md Adds Quick Start, Supported Providers, fallback docs, and Troubleshooting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/report.ts Outdated
Comment thread src/report.ts
Comment on lines +60 to +62
const boxed = contentLines.map((line) => {
return color("│") + " " + line;
});
Comment thread src/llm/index.ts
env.OPENAI_MODEL ??
preset?.defaultModel ??
"gpt-4o-mini";
const fallbackModels = preset?.fallbackModels ?? [];
Comment thread src/llm/openai.ts
Comment on lines 41 to 45
readonly label: string;
readonly model: string;
private readonly fallbackModels: string[];
private activeModel: string;
private readonly client: OpenAI;
Comment thread README.md
known-good fallback model for that provider. You'll see a warning like:

```
⚠ Model "openrouter/free" failed, falling back to "google/gemini-2.0-flash-exp:free"
tejasprasad2008-afk and others added 2 commits June 4, 2026 18:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tejasprasad2008-afk

Copy link
Copy Markdown
Author

still dont wanna check it out @ni5arga

@ni5arga

ni5arga commented Jun 5, 2026

Copy link
Copy Markdown
Owner

It becomes hard for me to review large PRs and this is a very medium to large sized PR (+/- 600 LoC). I'll recommend you to close this PR and make new PRs in chunks, so it'll be easier for me to review them in a proper manner.

I'll just end up running Claude Code review or Copilot on PRs of this size and merge them - that'll just degrade code optimization and I don't want to push code which I haven't manually reviewed.

Hope this makes sense.

@ni5arga

ni5arga commented Jun 5, 2026

Copy link
Copy Markdown
Owner

> deanonymizer@0.1.0 format:check
> prettier --check "src/**/*.ts"

Checking formatting...
[error] src/llm/index.ts: SyntaxError: Argument expression expected. (89:3)
[error]   87 |   throw new Error(
[error]   88 |     `Unknown LLM provider "${value}". Supported: ${[...KNOWN_PROVIDERS].join(", ")}.`,
[error] > 89 |   if (p === "anthropic" || p === "openai" || p === "claude-code") return p;
[error]      |   ^
[error]   90 |   throw new Error(
[error]   91 |     `Unknown LLM provider "${value}". Use "anthropic", "openai", or "claude-code".`,
[error]   92 |   );
[error] src/report.ts: SyntaxError: ':' expected. (14:7)
[error]   12 |   medium: pc.bgYellow(pc.black(pc.bold("  MED "))),
[error]   13 |   low: pc.bgBlack(pc.dim(" LOW  ")),
[error] > 14 | const CONF_TAG = {
[error]      |       ^
[error]   15 |   high: pc.red(pc.bold("HIGH")),
[error]   16 |   medium: pc.yellow(pc.bold("MED")),
[error]   17 |   low: pc.dim(pc.bold("LOW")),
Error occurred when checking code style in 2 files.
Error: Process completed with exit code 2.

Also, tests are failing - you might want to check that.

@tejasprasad2008-afk

Copy link
Copy Markdown
Author

Also, tests are failing - you might want to check that.

I mean it worked on my system when i ran it but def checking it rn

@ni5arga

ni5arga commented Jun 5, 2026

Copy link
Copy Markdown
Owner

It becomes hard for me to review large PRs and this is a very medium to large sized PR (+/- 600 LoC). I'll recommend you to close this PR and make new PRs in chunks, so it'll be easier for me to review them in a proper manner.

Also, please try to take this into consideration. Thanks.

@tejasprasad2008-afk

Copy link
Copy Markdown
Author

Closed in favor of breaking this down into smaller, easier-to-review PRs as requested! I'll be opening them shortly.

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.

3 participants