Skip to content

fix(openai): pin model to gpt-5.4-nano (probe-verified) - Devvit 400 round 7#38

Merged
ComBba merged 1 commit into
mainfrom
fix/openai-400-nano-model
May 13, 2026
Merged

fix(openai): pin model to gpt-5.4-nano (probe-verified) - Devvit 400 round 7#38
ComBba merged 1 commit into
mainfrom
fix/openai-400-nano-model

Conversation

@ComBba
Copy link
Copy Markdown
Contributor

@ComBba ComBba commented May 13, 2026

Round 7. body chars now 4279 (well under probe(f)), content has no JSON syntax. Only untested variable left: model. probe(b)(d)(e)(f) all used gpt-5.4-nano and were 200 in production. callOpenAI defaults to gpt-5.4-mini, never tested in production. This PR pins to nano + logs resolved model.

🤖 Generated with Claude Code

…ound 7

PR #32-#37 all shipped, production still HTTP 400. body chars now down to
4279 (well under probe(f)'s 5610 B 200-OK), content has no JSON syntax,
all known shape variables aligned with probe(f) -- yet 400 persists.

Only untested variable left: model. probe(b)(d)(e)(f) all hardcoded
`gpt-5.4-nano` and returned 200 in production. callOpenAI defaults to
`gpt-5.4-mini` via settings.get, never tested in production. Pinning to the
probe-verified model isolates whether the model selection itself is what
differs between probe-success and callOpenAI-failure.

Plus: log resolved model + settings.get value so subsequent rounds can see
what the user has stored for openaiModel.

Gates: `npm run check` 4/4 PASS.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@ComBba has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 46 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d240a7e9-ddf7-4e8c-b742-c31aba479317

📥 Commits

Reviewing files that changed from the base of the PR and between c8f4ed6 and 09d1d61.

📒 Files selected for processing (1)
  • src/server/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openai-400-nano-model

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request hardcodes the OpenAI model to 'gpt-5.4-nano' for debugging and adds logging for the model configuration. Feedback highlights that this bypasses user-configured settings and introduces a metadata inconsistency, as the stored RuleBundle may incorrectly report the model used for compilation.

Comment thread src/server/index.ts
Comment on lines +1273 to +1282
const model = 'gpt-5.4-nano';
let settingsModel: string | null = null;
try {
model = ((await settings.get('openaiModel')) as string) || 'gpt-5.4-mini';
settingsModel = ((await settings.get('openaiModel')) as string) || null;
console.log('[vibe-mod] callOpenAI: settings.get(openaiModel) =', JSON.stringify(settingsModel));
} catch (err) {
console.warn('[vibe-mod] callOpenAI: settings.get(openaiModel) threw — using default:', describeErr(err));
console.warn('[vibe-mod] callOpenAI: settings.get(openaiModel) threw — using nano default:', describeErr(err));
}
void settingsModel;
console.log('[vibe-mod] callOpenAI: model resolved =', model);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The openaiModel setting is currently fetched and logged, but its value is ignored because the model variable is hardcoded to 'gpt-5.4-nano'. While the PR description notes this is a temporary measure for debugging, it introduces a regression where user-configured models are bypassed.

Additionally, this creates a metadata inconsistency: the RuleBundle (created in the compose-rule-submit handler) still resolves the model from settings to populate its llmModel field. Consequently, the stored bundle will incorrectly report the model used for compilation. Consider ensuring that the llmModel metadata in the bundle accurately reflects the hardcoded model being used, or allowing the setting to override the pin if present.

@ComBba ComBba merged commit b2cc1c1 into main May 13, 2026
2 checks passed
@ComBba ComBba deleted the fix/openai-400-nano-model branch May 13, 2026 15:51
ComBba added a commit that referenced this pull request May 15, 2026
fix(openai): pin model to gpt-5.4-nano (probe-verified) - Devvit 400 round 7
ComBba pushed a commit that referenced this pull request May 15, 2026
…use of HTTP 400

# Root cause

`settings.get('openaiModel')` returns the value of a Devvit SELECTION
schema field. SELECTION fields return a `string[]` -- even for single
selection. We were passing the raw array straight into the request body
as `"model": ["gpt-5.4-mini"]`, which OpenAI rejected as unparseable
JSON for the `model` field. OpenAI's error wording masked the underlying
problem: it said `We could not parse the JSON body of your request`,
which sounds like a structural JSON error but is actually a type
mismatch on a single field. Production log proof from v0.0.39:

  [vibe-mod] callOpenAI: openaiModel raw = ["gpt-5.4-mini"]

This single bug accounts for PR #32-#37 all returning HTTP 400 with
seemingly unrelated changes. PR #38 (v0.0.39) worked around it by
hardcoding `gpt-5.4-nano` (a string), which made the request body
valid -- callOpenAI succeeded, the toast became
`The compiled rule contained an action this app does not support`
(a downstream issue, not a transit one).

# Fix

* Unwrap the SELECTION result: if `Array.isArray(raw)`, take `raw[0]`.
* Log both the raw and unwrapped values for diagnostic visibility.
* Honour the user-configured model (default `gpt-5.4-mini`).

# Restore proper few-shot examples

PR #37 had stripped JSON syntax from message content (`flattenExample`,
output as `key=value; key=value`) on a false hypothesis. With JSON
syntax removed, the model learned a non-schema output shape -- v0.0.39
emitted `{"modqueue":{"note":"..."}}` instead of `{"action":"modqueue",
"params":{"note":"..."}}`. Restoring `JSON.stringify(ex.assistant)` for
each example re-teaches the schema.

Single-user composition (PR #32) is preserved -- it's a sensible
packaging choice and was never causing the 400; the model array was.

# Tests

* `npm run check` 4/4 PASS.
* Local POST of the new body to OpenAI returns 200 with a valid
  compiled rule conforming to the SAFE-action schema.
* After merge: `devvit upload` -> v0.0.40 -> Chrome verify -> production
  callOpenAI returns 200 -> toast shows compile success.

# Why probe(b)/(d)/(e)/(f) all worked

The probes hardcoded `'gpt-5.4-nano'` (a string literal) -- so they
sent a valid `model` field and OpenAI parsed their requests fine. Only
callOpenAI used `settings.get(...)` and got hit by the array bug.
ComBba pushed a commit that referenced this pull request May 15, 2026
…branch cleanup record

Records the 7-round speculative-fix loop that PR #32-#38 went through,
the actual root cause (PR #39: SELECTION-typed setting returning string[]
not string), and the end-to-end verification: production toast 'Compiled
rule "New-account posts to mod queue". Dry-run started -- check Dashboard
in 30s.' captured via Chrome on v0.0.41.

Probe code (synthetic-compile-probe handler + scheduler entry) lived only
on the fix/openai-error-handling branch and never reached main; that
branch is now deleted from origin. grep -c synthetic-compile-probe across
src/server/index.ts and devvit.json: 0 + 0.

No code change. Closes the postmortem loop on issue and satisfies the
goal-condition (5) requirement for an explicit MERGED PR surface
recording the probe-removal decision.
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.

1 participant