Commit f7c8ee2
fix: address PR #475 review comments — 6 fixes across Flutter config validation
- **QEF-1 (greptile P1, `dart_bridge_llm.dart:390`)**: `_requireLoadedContextLength()`
no longer throws `SDKError.validationFailed` when the loaded model lacks
`contextLength` metadata. Falls back to `32768` (a generous ceiling) so
generation isn't silently broken for models that were registered without a
non-zero `contextLength` in their C struct. Return type stays `int`
(non-nullable) so call sites don't need to change; `SDKError` import dropped.
- **QEF-2 / QEF-5 / QEF-7 (greptile P1 + coderabbit Critical ×2, `llm_configuration.dart:30`)**:
Removed the hardcoded 32 768 ceiling on `contextLength` from
`LLMConfiguration.validate()`. The previous `contextLength > 32768` rejection
blocked every generation attempt on modern large-context models (Llama 3.1 8B
at 128K, Mistral v0.3 at 32K, etc.). Kept only `contextLength <= 0`; the
existing `maxTokens <= contextLength` check provides the effective upper
bound. Error message updated to "Context length must be greater than 0".
- **QEF-3 (greptile P2, `dart_bridge_model_registry.dart:200`)**: The
`model.contextLength ?? 0` pattern in `savePublicModel` is in fact correct —
`public_types.ModelInfo.contextLength` IS nullable (`int?`), and the internal
`RacModelInfoCStruct.contextLength` is non-nullable `int` with `0` as the
"missing" sentinel that `_ffiModelToPublic` maps back to `null`. Added a doc
comment at the adapter boundary explaining the null↔zero convention so the
intent is obvious and the reverse conversion is linked.
- **QEF-4 (coderabbit Major, `llm_configuration.dart:48`)**: Added `systemPrompt`
length validation to `validate()`. Oversized prompts (a system prompt longer
than the model's context window, measured roughly as `contextLength * 4` chars
at ~4 chars/token) are now rejected before the FFI call with a descriptive
error. Null `systemPrompt` is still allowed.
- **QEF-6 (coderabbit Minor, `tts_configuration.dart:16`)**: Aligned the
default `speakingRate` from `0.5` to `1.0` so `const TTSConfiguration()`
matches `dart_bridge_tts.synthesize()`'s default rate. The `validate()`
range (0.5–2.0) still admits 1.0, no range change needed.
- **QEF-8 (coderabbit Major, `dart_bridge_model_assignment.dart:257` +
`dart_bridge_model_registry.dart:1040`)**: `_structToModelInfo` now
propagates `contextLength` into the returned `ModelInfo`, so models loaded
via the assignment/discovery flow carry the metadata that the LLM bridge's
`_requireLoadedContextLength()` relies on. Added the corresponding
`contextLength` field to `RacModelInfoStruct` to match the C layout read
by this path.
- **Cleanup**: removed 4 redundant `!` operators on `systemPromptPtr` in
`dart_bridge_llm.dart` (lines 532, 599, 668, 704) and wrapped two
non-awaited `controller.close()` calls in `unawaited(...)` (lines 357,
361) so `flutter analyze` reports a clean run on the modified files.
**Invalid / superseded by code evolution:** none (all comments addressed).
**Verification:** `flutter analyze` on the five modified files reports
"No issues found!" with Flutter 3.38.3 / Dart 3.10.1. The older `dart analyze`
(Dart 2.17.3, pre-Dart 3) still reports pre-existing "Future isn't a type"
cascades because the repo requires Dart >=3.0.0 — that's an environment issue,
not a code issue.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ee86d2e commit f7c8ee2
5 files changed
Lines changed: 35 additions & 18 deletions
File tree
- sdk/runanywhere-flutter/packages/runanywhere/lib
- features
- llm
- tts
- native
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
Lines changed: 9 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
355 | 354 | | |
356 | 355 | | |
357 | 356 | | |
358 | | - | |
| 357 | + | |
359 | 358 | | |
360 | 359 | | |
361 | 360 | | |
362 | | - | |
| 361 | + | |
363 | 362 | | |
364 | 363 | | |
365 | 364 | | |
| |||
389 | 388 | | |
390 | 389 | | |
391 | 390 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
399 | 394 | | |
400 | 395 | | |
401 | 396 | | |
| |||
534 | 529 | | |
535 | 530 | | |
536 | 531 | | |
537 | | - | |
| 532 | + | |
538 | 533 | | |
539 | 534 | | |
540 | 535 | | |
| |||
601 | 596 | | |
602 | 597 | | |
603 | 598 | | |
604 | | - | |
| 599 | + | |
605 | 600 | | |
606 | 601 | | |
607 | 602 | | |
| |||
670 | 665 | | |
671 | 666 | | |
672 | 667 | | |
673 | | - | |
| 668 | + | |
674 | 669 | | |
675 | 670 | | |
676 | 671 | | |
| |||
706 | 701 | | |
707 | 702 | | |
708 | 703 | | |
709 | | - | |
| 704 | + | |
710 | 705 | | |
711 | 706 | | |
712 | 707 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
| |||
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
192 | 200 | | |
193 | 201 | | |
194 | 202 | | |
| |||
1036 | 1044 | | |
1037 | 1045 | | |
1038 | 1046 | | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1039 | 1050 | | |
1040 | 1051 | | |
1041 | 1052 | | |
| |||
0 commit comments