Improve Qwen3.6 coding agent and inference defaults#300
Merged
Conversation
Contributor
|
Chat app preview removed for |
There was a problem hiding this comment.
Pull request overview
This PR updates llamadart’s defaults and examples to better support a Qwen3.6-focused, sequential tool-loop coding-agent workflow, while aligning native batching and sampling behavior with upstream llama.cpp and tightening ChatSession context budgeting for agent turns.
Changes:
- Aligns native decoder/generative batching defaults to
n_batch <= 2048andn_ubatch <= 512, while preserving full-context defaults for encoder-only models and WebGPU’s architecture-agnostic fallback. - Adds native llama.cpp presence-penalty support via
GenerationParams.presencePenalty, explicitly rejecting unsupported backends (WebGPU, LiteRT-LM). - Reworks the TUI coding-agent example into a small single-screen, four-tool, strict JSON-envelope loop with streaming thinking/final channels and compact Markdown + syntax highlighting.
Reviewed changes
Copilot reviewed 66 out of 69 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/guides/performance-tuning.md | Documents new native batching defaults and presence penalty guidance. |
| website/docs/guides/embeddings.md | Clarifies encoder throughput batching vs decoder defaults and WebGPU behavior. |
| website/docs/examples/tui-coding-agent.md | Updates the example guide to the new small Pi-style agent loop and flags. |
| website/docs/configuration/runtime-parameters.md | Updates runtime parameter docs to reflect model-aware batching and presence penalty semantics. |
| website/docs/changelog/recent-releases.md | Adds an Unreleased entry summarizing the behavioral and example updates. |
| test/unit/core/models/inference/model_params_test.dart | Adds/updates tests for new default batching constants and resolution policy. |
| test/unit/core/models/inference/generation_params_test.dart | Adds tests ensuring presencePenalty is stored and copied. |
| test/unit/core/models/chat/chat_message_test.dart | Tests continuesPreviousTurn metadata behavior and JSON serialization exclusion. |
| test/unit/core/engine/engine_test.dart | Adds regression test ensuring cancelled downloads don’t proceed to model load. |
| test/unit/core/engine/chat_session_test.dart | Adds coverage for new context budgeting/trimming and continuation-turn handling. |
| test/unit/backends/webgpu/webgpu_backend_test.dart | Updates tests for WebGPU batching defaults and presence-penalty rejection. |
| test/unit/backends/llama_cpp/llama_cpp_service_test.dart | Adds tests for presence-penalty mapping and updated batch-size resolution. |
| test/unit/backends/litert_lm/litert_lm_service_test.dart | Updates unsupported-parameter reporting to include presence penalty. |
| test/unit/backends/litert_lm/litert_lm_backend_web_test.dart | Adds web backend test rejecting non-zero presence penalty. |
| test/integration/backends/llama_cpp/native_symbol_integration_test.dart | Verifies batch constants match pinned llama.cpp defaults. |
| lib/src/core/models/inference/model_params.dart | Introduces default batch constants and a model-aware batch resolution policy hook. |
| lib/src/core/models/inference/generation_params.dart | Adds presencePenalty to the public generation parameter surface. |
| lib/src/core/models/chat/chat_message.dart | Adds continuesPreviousTurn as internal metadata for trimming coherence. |
| lib/src/core/engine/engine.dart | Adds cancellation checks during loadModelSource resolution/download flow. |
| lib/src/core/engine/chat_session.dart | Reworks context budgeting to reserve output/tool-schema space and compact completed exchanges. |
| lib/src/backends/webgpu/webgpu_backend.dart | Preserves full-context WebGPU auto-batching and rejects presence penalty explicitly. |
| lib/src/backends/llama_cpp/llama_cpp_service.dart | Detects encoder-only models for full-context defaults and maps presence penalty to sampler penalties. |
| lib/src/backends/litert_lm/litert_lm_service.dart | Adds presence-penalty to unsupported-parameter validation. |
| lib/src/backends/litert_lm/litert_lm_backend_web.dart | Adds presence-penalty to unsupported-parameter validation (web). |
| example/tui_coding_agent/test/workspace_tools_test.dart | Expands tests for the new four-tool surface, bounds, cancellation, and confinement rules. |
| example/tui_coding_agent/test/workspace_guard_test.dart | Adds tests for canonicalization and symlink escape prevention. |
| example/tui_coding_agent/test/tool_usage_policy_test.dart | Removes tests for deleted tool-usage heuristics (simplified agent loop). |
| example/tui_coding_agent/test/tool_call_gate_test.dart | Removes tests for deleted per-round tool-call gating. |
| example/tui_coding_agent/test/text_tool_call_parser_test.dart | Replaces permissive parsing tests with strict single-envelope JSON parsing tests. |
| example/tui_coding_agent/test/session_event_coalescer_test.dart | Adds tests for frame-coalesced streaming event batching. |
| example/tui_coding_agent/test/runner_tool_regression_test.dart | Removes regression tests tied to the old inline-tag parsing and tool set. |
| example/tui_coding_agent/test/model_source_resolver_test.dart | Removes tests for deleted fuzzy HF resolver/downloader (now uses loadModelSource). |
| example/tui_coding_agent/test/coding_agent_tui_test.dart | Adds UI regressions for the TurboVision shell, badges, and lazy transcript behavior. |
| example/tui_coding_agent/test/coding_agent_markdown_test.dart | Adds coverage for compact Markdown + fenced-code highlighting and styling. |
| example/tui_coding_agent/test/coding_agent_config_test.dart | Adds tests for Qwen presets, cache delegation, and tool-round defaults. |
| example/tui_coding_agent/test/assistant_text_stream_test.dart | Adds tests for streaming text gating around tool-call marker splits. |
| example/tui_coding_agent/test/assistant_draft_rows_test.dart | Adds tests for resetting assistant draft rows when a tool-call attempt is detected. |
| example/tui_coding_agent/README.md | Rewrites README to match the new small agent design, presets, limits, and trust boundary. |
| example/tui_coding_agent/pubspec.yaml | Updates dependencies for Markdown rendering and syntax highlighting; bumps nocterm. |
| example/tui_coding_agent/lib/tui_coding_agent.dart | Narrows the library export surface to the intended public API. |
| example/tui_coding_agent/lib/src/workspace_guard.dart | Hardens workspace confinement and symlink resolution semantics. |
| example/tui_coding_agent/lib/src/tool_usage_policy.dart | Removes old heuristic “tool usage policy” implementation. |
| example/tui_coding_agent/lib/src/tool_call_gate.dart | Removes old tool-call gating implementation. |
| example/tui_coding_agent/lib/src/text_tool_call_parser.dart | Replaces permissive parser with strict single-envelope JSON tool-call parser. |
| example/tui_coding_agent/lib/src/session_event.dart | Expands event types to support thinking/final channels, warnings, and draft resets. |
| example/tui_coding_agent/lib/src/session_event_coalescer.dart | Adds frame-based coalescing for high-frequency stream deltas. |
| example/tui_coding_agent/lib/src/model_source_resolver.dart | Removes old custom resolver/downloader in favor of LlamaEngine.loadModelSource. |
| example/tui_coding_agent/lib/src/coding_agent_theme.dart | Adds a consolidated TurboVision-inspired theme and Markdown style sheets. |
| example/tui_coding_agent/lib/src/coding_agent_syntax_highlighter.dart | Adds fenced-code highlighting via Highlight.js grammars with size bounds and aliasing. |
| example/tui_coding_agent/lib/src/coding_agent_markdown.dart | Adds a compact Markdown renderer with solid code backgrounds and table/list support. |
| example/tui_coding_agent/lib/src/coding_agent_config.dart | Adds Qwen3.6 presets, cache override semantics, and config validation. |
| example/tui_coding_agent/lib/src/assistant_text_stream.dart | Adds streaming gate to prevent tool-call JSON from flashing as assistant prose. |
| example/tui_coding_agent/lib/src/assistant_draft_rows.dart | Tracks assistant/thinking draft rows for safe reset when tool markers appear. |
| example/tui_coding_agent/bin/tui_coding_agent.dart | Updates CLI flags to startup-only configuration, --thinking, and --read-only. |
| example/README.md | Updates repository example overview to match the new TUI coding-agent behavior. |
| example/basic_app/lib/services/sqlite_vector_cli_options.dart | Updates CLI help strings to reflect model-aware batching defaults. |
| example/basic_app/bin/llamadart_embedding_example.dart | Updates CLI help strings to reflect model-aware batching defaults. |
| CHANGELOG.md | Adds Unreleased entries for batching defaults, TUI agent rework, presence penalty, and ChatSession trimming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read,write,edit, andbash.LlamaEngine.loadModelSource, delegating the default cache and resumable downloads to llamadart.--thinking, compact Markdown rendering, fenced-code syntax highlighting, solid code-block backgrounds, and a single-window TurboVision theme.n_batch <= 2048,n_ubatch <= 512), add nativepresencePenalty, and makeChatSessioncontext compaction reserve output/tool-schema space while retaining coherent agent turns.Production-readiness scope
hf://model-source paths; existing WebGPU and LiteRT-LM paths retain their documented behavior.bashis deliberately unsandboxed and documented as such. WebGPU and LiteRT-LM reject non-zero presence penalty until their runtimes expose an equivalent control. Qwen reasoning is honestly exposed as on/off; no synthetic low/medium/high effort control is claimed.Completeness checklist
PR type guidance
Test Plan
dart format --output=none --set-exit-if-changed .— 507 files, 0 changed. The unfetched Flutter chat example emitted only its existing localflutter_lintsresolution warning.dart analyze— rootlib testand the TUI package report no issues.dart test -p vm -j 1 --exclude-tags local-only— 1,289 passed; 66 expected fixture/model skips. The repository's small native llama.cpp smoke model loaded and generated successfully.dart test -p chrome --exclude-tags local-only— 724 passed; 1 expected skip.ChatSessiontargeted suite: 13 passed; 1 existing native-template skip.10,542 / 14,081lines), above the 70% gate.npm auditreports 19 moderate development-server transitive advisories with no available fix, and no high/critical advisories.--helpsmoke passed.Matrix Evidence
static-format-analyzeroot-vmroot-chromecoverage-liblib/coveragedocs-siterelease-doc-version-consistencyexamples-testsnative-hook-bundlesgguf-chat-features-smokenative-inference-benchmarkweb-bridge-smokelitert-lm-engine-smokelinux-x64-ci-runtimewindows-x64-ci-runtimeReview Notes
dart fix --dry-runreport nothing to fix.e4d8c3a4f.