diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36df281de..4ab63354f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: working-directory: packages/genkit_llamadart run: | dart --version - dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.0 schemantic@1.0.0 + dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.7 schemantic@1.0.0 - name: Analyze and test minimum dependencies if: matrix.part == 'lower bounds and published' working-directory: packages/genkit_llamadart diff --git a/.github/workflows/publish_genkit_pubdev.yml b/.github/workflows/publish_genkit_pubdev.yml index a834d878e..fff8831dd 100644 --- a/.github/workflows/publish_genkit_pubdev.yml +++ b/.github/workflows/publish_genkit_pubdev.yml @@ -78,7 +78,7 @@ jobs: sdk: 3.12.0 - name: Resolve lower-bound runtime dependencies working-directory: packages/genkit_llamadart - run: dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.0 schemantic@1.0.0 + run: dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.7 schemantic@1.0.0 - name: Analyze and test working-directory: packages/genkit_llamadart run: | diff --git a/packages/genkit_llamadart/CHANGELOG.md b/packages/genkit_llamadart/CHANGELOG.md index f9e816c9f..01f15ec96 100644 --- a/packages/genkit_llamadart/CHANGELOG.md +++ b/packages/genkit_llamadart/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased + +- Structured output builds its thinking budget with llamadart's `ChatTemplateEngine.resolveThinkingBudget`, so a Qwen3.5 or Qwen3-Coder XML template closes a spent budget with `\n` instead of a bare ``. Requires llamadart 0.19.7. + ## 3.8.0 - 2026-11-08 - Upgrade to llamadart 0.19.0 and matching 0.19.x Apple companions. diff --git a/packages/genkit_llamadart/doc/migration.md b/packages/genkit_llamadart/doc/migration.md index 46d2bb259..41b66f045 100644 --- a/packages/genkit_llamadart/doc/migration.md +++ b/packages/genkit_llamadart/doc/migration.md @@ -2,7 +2,7 @@ ## Upgrading to llamadart 0.19 -The current plugin requires llamadart `^0.19.0`. Genkit 1.0, Schemantic 1.0, +The current plugin requires llamadart `^0.19.7`. Genkit 1.0, Schemantic 1.0, the Dart 3.12 minimum and the plugin API are unchanged. Flutter iOS and macOS apps must use matching `^0.19.0` runtime companions. See [llamadart's migration guide](https://github.com/leehack/llamadart/blob/main/MIGRATION.md). diff --git a/packages/genkit_llamadart/doc/tool-input-schemas.md b/packages/genkit_llamadart/doc/tool-input-schemas.md index c28258f3a..eb2f65d84 100644 --- a/packages/genkit_llamadart/doc/tool-input-schemas.md +++ b/packages/genkit_llamadart/doc/tool-input-schemas.md @@ -1,6 +1,6 @@ # Tool input schemas -The plugin requires llamadart `^0.19.0`. Genkit continues to own handlers, +The plugin requires llamadart `^0.19.7`. Genkit continues to own handlers, interrupts and message history. Tool input and tool-call argument roots must be JSON objects; scalar and array roots are unsupported. diff --git a/packages/genkit_llamadart/doc/usage.md b/packages/genkit_llamadart/doc/usage.md index bfca0ffb3..7fdbeade3 100644 --- a/packages/genkit_llamadart/doc/usage.md +++ b/packages/genkit_llamadart/doc/usage.md @@ -424,7 +424,9 @@ for model guidance and qualification limits. block; zero closes the block immediately. Enable thinking separately with `enableThinking: true`. Chat and constrained JSON both resolve omitted `startTag`/`endTag` from the selected template; custom delimiters and -`forcedMessage` pass through unchanged. Budgets need runtime support and cannot +`forcedMessage` pass through unchanged, except that on Qwen3-Coder XML +templates (Qwen3.5) with no `endTag` set, a `\n` is appended to `forcedMessage` +before ``. Budgets need runtime support and cannot be combined with media or speculative decoding. `reusePromptPrefix: false` disables native llama.cpp prefix reuse. It does not diff --git a/packages/genkit_llamadart/lib/src/integration/genkit/actions/model_action.dart b/packages/genkit_llamadart/lib/src/integration/genkit/actions/model_action.dart index 90a234987..4cf45faca 100644 --- a/packages/genkit_llamadart/lib/src/integration/genkit/actions/model_action.dart +++ b/packages/genkit_llamadart/lib/src/integration/genkit/actions/model_action.dart @@ -343,17 +343,9 @@ Future _runStructuredModel({ } final budget = params.thinkingBudget; - final tags = budget == null - ? null - : llama.ChatTemplateEngine.thinkingTagsFor(template.format); final resolvedBudget = budget == null ? null - : llama.ThinkingBudget( - maxTokens: budget.maxTokens, - startTag: budget.startTag ?? tags!.startTag, - endTag: budget.endTag ?? tags!.endTag, - forcedMessage: budget.forcedMessage, - ); + : llama.ChatTemplateEngine.resolveThinkingBudget(template.format, budget); final rawOutput = StringBuffer(); await for (final token in runtime.generate( template.prompt, diff --git a/packages/genkit_llamadart/pubspec.yaml b/packages/genkit_llamadart/pubspec.yaml index 5cbb079f3..d87dd272f 100644 --- a/packages/genkit_llamadart/pubspec.yaml +++ b/packages/genkit_llamadart/pubspec.yaml @@ -29,7 +29,7 @@ dependencies: crypto: ^3.0.7 genkit: ^1.0.0 http: ^1.6.0 - llamadart: ^0.19.0 + llamadart: ^0.19.7 schemantic: ^1.0.0 dev_dependencies: diff --git a/packages/genkit_llamadart/test/integration/genkit/actions/model_action/inference_controls_test.dart b/packages/genkit_llamadart/test/integration/genkit/actions/model_action/inference_controls_test.dart index c566447e2..25c6f8f99 100644 --- a/packages/genkit_llamadart/test/integration/genkit/actions/model_action/inference_controls_test.dart +++ b/packages/genkit_llamadart/test/integration/genkit/actions/model_action/inference_controls_test.dart @@ -156,6 +156,46 @@ void main() { }, ); + group('Qwen3-Coder XML thinking budget', () { + Future budgetFor(ThinkingBudget budget) async { + runtime.templateResult = llama.LlamaChatTemplateResult( + prompt: 'prompt', + format: llama.ChatFormat.qwen3CoderXml.index, + grammar: 'root ::= "{}"', + ); + await generate( + LlamaDartGenerationConfig(thinkingBudget: budget), + structured: true, + ); + return runtime.lastGenerationParams!.thinkingBudget!; + } + + test('appends the line break to the caller forced message', () async { + final budget = await budgetFor( + const ThinkingBudget(maxTokens: 8, forcedMessage: 'wrap up'), + ); + expect(budget.forcedMessage, 'wrap up\n'); + expect(budget.endTag, ''); + }); + + test('forces the line break alone without a forced message', () async { + final budget = await budgetFor(const ThinkingBudget(maxTokens: 8)); + expect(budget.forcedMessage, '\n'); + }); + + test('adds no line break when the caller sets an end tag', () async { + final budget = await budgetFor( + const ThinkingBudget( + maxTokens: 8, + endTag: '', + forcedMessage: 'wrap up', + ), + ); + expect(budget.endTag, ''); + expect(budget.forcedMessage, 'wrap up'); + }); + }); + test( 'typed speculation takes precedence over disabled default flag', () async { diff --git a/test/unit/tooling/ci_workflow_selection_test.dart b/test/unit/tooling/ci_workflow_selection_test.dart index 343cb493b..0ef2938c9 100644 --- a/test/unit/tooling/ci_workflow_selection_test.dart +++ b/test/unit/tooling/ci_workflow_selection_test.dart @@ -1107,7 +1107,7 @@ for event,flag,native,cancel,good,main in itertools.product(('push','pull_reques contains('crypto@3.0.7'), contains('genkit@1.0.0'), contains('http@1.6.0'), - contains('llamadart@0.19.0'), + contains('llamadart@0.19.7'), contains('schemantic@1.0.0'), ), ); diff --git a/website/docs/maintainers/genkit-package.md b/website/docs/maintainers/genkit-package.md index 8b1600166..afba97b17 100644 --- a/website/docs/maintainers/genkit-package.md +++ b/website/docs/maintainers/genkit-package.md @@ -76,7 +76,7 @@ selected lane participates in the existing truthful aggregate. The adapter CI job runs two parallel legs. The first checks lower bounds: on Dart 3.12.0, before Flutter is set up, it uses exact runtime dependency minima, -including published llamadart 0.19.0, then restores the package. It then +including published llamadart 0.19.7, then restores the package. It then resolves published dependencies and checks docs, tests and publication. The second creates an ignored `pubspec_overrides.yaml` to test against checkout core, analyzes/tests again, runs the real-model contracts and checks browser