# \# \[Bug\] BYOK Gemini app/complete has model mismatch, intermittent 502s, and truncated structured output

**URL:** <https://forum.anna.partners/t/bug-byok-gemini-app-complete-has-model-mismatch-intermittent-502s-and-truncated-structured-output/345>\
**Category:** Developers\
**Created:** [September 25, 2026, 4:43am UTC](https://forum.anna.partners/t/bug-byok-gemini-app-complete-has-model-mismatch-intermittent-502s-and-truncated-structured-output/345 "2026-09-25T04:43:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![echen](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@echen](https://forum.anna.partners/u/echen)\
**Post date:** [September 25, 2026, 4:43am UTC](https://forum.anna.partners/t/bug-byok-gemini-app-complete-has-model-mismatch-intermittent-502s-and-truncated-structured-output/345/1 "2026-09-25T04:43:18Z")

</div>

Hi Anna team,

I found a reproducible BYOK issue while testing an Anna App using `anna.llm.complete`.

**## Environment**

- App: YourTurn

- App slug: `yourturn`

- App version: `0.1.7`

- Anna CLI: `0.1.47`

- Node: `22.19.0`

- Provider: Gemini BYOK

- Test date: September 23, 2026

- Endpoint: `/api/v1/copilot/app/complete`

- Dev session kind: `complete`

BYOK is enabled and Anna is successfully reaching the Gemini provider.

**## Request configuration**

The app requested:

```json

{

“modelPreferences”: {

```
"hints": \[

  {

    "name": "google/gemini-3.1-flash-lite-preview"

  }

\]

```

},

“maxTokens”: 4096

}

```

**## Actual routing**

Anna returned:

- Requested model: `google/gemini-3.1-flash-lite-preview`

- Actual model: `byok:gemini/models/gemini-3-flash-preview`

- Provider: `byok:gemini`

Could you confirm whether this model substitution is expected for Gemini BYOK?

**## Results**

**### Test 1**

CREATE succeeded:

- Structured response valid: yes

- Client/server latency: approximately 18.94 seconds

- No repair needed

The following TURN request failed three times with HTTP 502 Bad Gateway. Cloudflare reported Browser and Cloudflare working, with the Anna host failing.

Relevant timestamps and Ray IDs:

- 13:15:23 UTC — `a3f9d1125a63868c`

- 13:15:29 UTC — `a3f9d1672b09b64b`

- 13:15:33 UTC — `a3f9d18a78c4a6df`

**### Test 2**

A repeated CREATE returned truncated JSON:

- Actual model: `byok:gemini/models/gemini-3-flash-preview`

- Latency: approximately 39.59 seconds

- Response length: 6,407 characters

- Validation category: `truncated_json`

- Reported usage: 1,776 input tokens and 1,842 output tokens

The automatic repair request then failed with HTTP 502:

- 13:16:41 UTC

- Ray ID: `a3f9d321684b0883`

**### Test 3 — fixed persisted TURN**

The same fixed story state and action were tested independently without creating a new story.

Result:

- JSON valid: yes

- Schema valid: yes

- Application semantic validation: yes

- Repair needed: no

- Response length: 3,090 characters

- Client latency: 55.99 seconds

- Server latency: 55.36 seconds

- Actual model: `byok:gemini/models/gemini-3-flash-preview`

**## Expected behavior**

1. `app/complete` should reliably return a completion through BYOK.

2. If the requested model is substituted, the documented mapping or supported BYOK model hint should be clear.

3. Structured CREATE and TURN requests should not intermittently return host-level 502 errors.

4. Repair requests should remain available after truncated model output.

**## Impact**

Successful BYOK responses are structurally compatible with the app, but the intermittent 502 errors and 39–56 second latency currently make BYOK unreliable for full-story testing.

The application correctly preserves canonical story state when these requests fail, so no persisted story corruption occurred.

Could you please confirm:

1. Is the requested-to-actual model mapping expected?

2. Are these 502 responses a known BYOK routing issue?

3. Which model hint should be used to target the configured Gemini BYOK model?

4. Are there additional request or provider IDs you would like us to capture?

This may be related to the previously fixed BYOK `app/complete` routing issue:

> [@App/complete returns HTTP 500 for every BYOK provider (GLM / DeepSeek / MiniMax) while the non-BYOK path stays healthy](https://forum.anna.partners/t/app-complete-returns-http-500-for-every-byok-provider-glm-deepseek-minimax-while-the-non-byok-path-stays-healthy/256):
>
> Summary: With BYOK enabled, `POST /api/v1/copilot/app/complete` consistently returns `HTTP 500 Internal Server Error`, regardless of provider or model. The non-BYOK path is healthy. The Anna team has confirmed this is a platform-side bug and a fix is in progress — posting here so the context and fix updates live in one thread (as Jiao suggested by email). Environment: - Account: [qingyu\_ge@foxmail.com](mailto:qingyu_ge@foxmail.com) (user\_id 368) - App slug: anna-truman-director - BYOK providers registered (all show “verifi…

Thanks!
