Skip to content

Fix AI Coach reliability on iOS - #187

Closed
thedandano wants to merge 1 commit into
DuarteSantos8:mainfrom
thedandano:codex/fix-ai-coach-ios
Closed

thedandano wants to merge 1 commit into
DuarteSantos8:mainfrom
thedandano:codex/fix-ai-coach-ios

Conversation

@thedandano

@thedandano thedandano commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • fix iOS cutting off slow local AI Coach requests after 30 seconds
  • leave Android unchanged because it already uses separate connection and response timeouts
  • tighten the response schema to match the app's required fields
  • preserve support for replies that omit coach_contract
  • add timeout and response-schema tests

Platform behavior

This timeout bug affected iOS only.

  • iOS previously treated the 30-second connection timeout as the timeout for the entire request.
  • Android already uses a 30-second connection timeout and a separate 40-minute response timeout.
  • This change gives iOS enough time for local inference without changing Android.

Why

  • Slow local Ollama requests could fail on iOS even though listing models worked.
  • Some completed responses were valid JSON but lacked fields required by the app, such as an exercise ID or the changes array.

Testing

  • frontend: 106 test files and 1,469 tests passed
  • API: 184 tests passed
  • production frontend build passed
  • locale, source-string, fatigue, Coach asset, and Node-loadability checks passed
  • manually tested with a local Ollama endpoint

@thedandano
thedandano force-pushed the codex/fix-ai-coach-ios branch from b823cc7 to 98b64c1 Compare September 13, 2026 05:10
DuarteSantos8 pushed a commit that referenced this pull request Sep 28, 2026
… up after 30 seconds, and an answer that claims contract 0 or null is refused (#187, its iOS timeout and contract parts)

Taken from #187 (thedandano) without its review-schema rewrite. Capacitor iOS maps connectTimeout
to URLRequest.timeoutInterval and ignores readTimeout when both are set, so the 30-second connect
timeout cut off every job a local model took longer than that over; on iOS the single timer now
gets the whole transport budget, and the job timeout still races it through the AbortSignal.
contractOK takes only a missing coach_contract as "not said", and the review prompt's nochange
answer carries an empty changes list.

Left out: the oneOf/const REVIEW_SCHEMA and the ajv devDependency its test needs. schemas.js keeps
every schema flat on purpose (llama.cpp's grammar converter, ollama#8444), and that rule should
only change after a run against Ollama.
@DuarteSantos8

Copy link
Copy Markdown
Owner

Thanks @thedandano. Part of this is in v1.3.9 under your name: the iOS timeout fix (the Coach on an iPhone now waits out a slow local model), the check that refuses a reply claiming contract 0 or null, and changes: [] in the no-change prompt.

I left out the oneOf/const schema rewrite and its ajv dev dependency. schemas.js deliberately keeps every schema flat because llama.cpp's grammar converter chokes on oneOf/anyOf (ollama#8444). If you want to bring it back, a separate PR that's been run against Ollama would be the way. I'm closing this one since the rest has landed.

Released in v1.3.9: https://github.com/DuarteSantos8/openGym/releases/tag/v1.3.9

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.

2 participants