Repository navigation
fix(ui): honor custom agent model_id when session is at DB default - #842
Conversation
) Previously, _chat_helpers.py always passed model_id=<session model> explicitly to registry.create_agent(), defeating kwargs.setdefault("model_id", ...) in custom agents — which only fires when the key is absent. Fix: build create_kwargs conditionally, omitting model_id when the session is at the DB default so the agent's __init__ setdefault governs. Also use agent.model_id (post-construction) for both _store_agent cache key and the pre-flight _maybe_load_expected_model call. Three-branch precedence: custom_model setting > session-explicit > omit kwarg. Closes #841
62722de to
00b343a
Compare
…N_DEFAULT_MODEL Addresses code review feedback on PR #842: - Export SESSION_DEFAULT_MODEL from database.py (single source of truth) instead of duplicating the string literal in _chat_helpers.py - Extract _build_create_kwargs() helper to eliminate the duplicate three-branch create_kwargs logic across non-streaming and streaming code paths - Extract _effective_model() helper using explicit None check (not `or`) to safely read agent.model_id post-construction without treating empty string as missing - Fix static regression guard regex to use [^()]* so nested helper calls inside create_agent() are not falsely flagged - Update unit test to import SESSION_DEFAULT_MODEL instead of hardcoding
00b343a to
4acfd40
Compare
…ion (#842) _store_agent was changed by the #842 fix to use _effective_model(agent, model_id) as the cache key — the post-construction value set by kwargs.setdefault. _get_cached_agent still looks up using the pre-construction model_id variable. For custom agents whose setdefault model differs from the session model, the keys never match and the agent is rebuilt on every turn. Revert the two _store_agent call sites to use model_id (the pre-construction intent key), matching what the lookup uses. _effective_model stays at the two _maybe_load_expected_model sites (Lemonade pre-flight needs the actual model) and in log statements (observability). Add two regression guards: - test_cache_hit_on_second_turn_for_setdefault_agent: two-turn cache-hit test with four assertions (call count, object identity, stored-key equality, agent.model_id). Covers the builder/template.py setdefault pattern. - test_no_effective_model_in_store_agent_calls: static grep guard that asserts _store_agent never receives _effective_model(...) as a positional arg, preventing this pattern from silently returning in a future cleanup pass.
SummaryThis PR fixes #841 cleanly by refactoring the UI→registry call site so The most important thing to know: the three-branch logic in Issues Found🟢 Minor —
|
#817) ## Summary One-line fix: swap the failing `www.cs.cmu.edu/~tom/EMNLP2004_final.pdf` URL in `docs/plans/email-triage-agent.mdx:2601` for the canonical ACL Anthology record at [W04-3240](https://aclanthology.org/W04-3240/). The CMU URL fails DNS resolution in CI (see [recent run](https://github.com/amd/gaia/actions/runs/24595902571/job/72072156929)), breaking the ``Verify external URLs`` check for every open PR that touches docs. ACL Anthology is the permanent archive for ACL/EMNLP papers — stable URL, no more link rot. Also restored the paper's actual full title ("Learning to Classify Email into 'Speech Acts'") for consistency with the other full-title citations in the same references list. ## Test plan - [x] `curl -sI https://aclanthology.org/W04-3240/` returns 200 - [ ] After merge, `Verify external URLs` check should go green on downstream PRs
SummaryTargeted, well-tested fix for #841. The core insight — The single most important thing to know: the follow-up commit that reverted Issues Found🟢 Minor —
|
# GAIA v0.17.4 Release Notes
GAIA v0.17.4 is a patch release covering two correctness fixes in the
Agent UI custom-agent path, a null-safety fix in the C++ library for
smaller LLMs, and a broken docs citation.
**Why upgrade:**
- **Custom agents use their declared model** — If a custom agent sets a
model via `kwargs.setdefault("model_id", ...)`, the Agent UI now
respects that setting when the session is at the DB default, instead of
falling back to the session model.
- **Compatibility with smaller LLMs in the C++ library** — The C++ JSON
parser now tolerates `null` values in `"tool"` and `"content"` fields,
which some smaller models emit in place of omitting the field.
---
## What's New
### Custom Agent `model_id` Respected in the Agent UI
`_chat_helpers.py` previously passed `model_id=<session model>`
explicitly to `registry.create_agent()`, which defeated
`kwargs.setdefault("model_id", ...)` in custom agents — `setdefault`
only fires when the key is absent (PR
[amd#841](amd#841)). The Agent UI now builds
`create_kwargs` conditionally, omitting `model_id` when the session is
at the DB default so the agent's `__init__` setdefault governs.
Three-branch precedence is now explicit: `custom_model` setting >
session-explicit model > agent's own `setdefault`.
A follow-up fix (PR [amd#842](amd#842))
restored the pre-construction `model_id` as the agent-cache key. The
initial PR amd#841 landing had switched `_store_agent` to use the
post-construction `_effective_model(agent, model_id)` while
`_get_cached_agent` still looked up with `model_id`, so keys never
matched for custom-model agents and the agent was rebuilt on every turn.
A two-turn cache-hit regression test and a static guard on
`_store_agent` call sites were added alongside the fix.
Supporting refactor: extracted `_build_create_kwargs()` and
`_effective_model()` helpers in `src/gaia/ui/_chat_helpers.py` to
deduplicate the three-branch logic across streaming and non-streaming
paths, and exported `SESSION_DEFAULT_MODEL` from `database.py` as the
single source of truth.
---
### C++ Library: Null-Safety in LLM Response Parsing
`parseLlmResponse()` in `cpp/src/json_utils.cpp` now guards
`.get<std::string>()` calls on the `"tool"` and `"answer"` JSON fields
with `.is_string()` / `.is_null()` checks (PR
[amd#780](amd#780)). This fixes a crash
(`json.exception.type_error.302: type must be string, but is null`) when
smaller LLMs (for example `qwen3.5:9b`) return `null` for those fields
instead of omitting them. `json.contains()` returns `true` for `null`
values, so the existing presence checks were insufficient.
---
## Bug Fixes
- **Email-triage agent plan: broken CMU citation link** (PR
[amd#817](amd#817)) — Swapped the failing
`www.cs.cmu.edu/~tom/EMNLP2004_final.pdf` URL in
`docs/plans/email-triage-agent.mdx` for the canonical ACL Anthology
record at [W04-3240](https://aclanthology.org/W04-3240/). The CMU URL
was failing DNS resolution in CI, breaking the `Verify external URLs`
check on every open docs PR. Restored the paper's full title ("Learning
to Classify Email into 'Speech Acts'") for consistency with other
citations in the same references list.
---
## Full Changelog
**5 commits** since v0.17.3:
- `8fc43f3f` — fix(cpp): add null-safety checks for JSON string fields
in LLM response parsing (amd#780)
- `62722de2` — fix(ui): honor custom agent model_id when session is at
DB default (amd#841)
- `4acfd400` — fix(ui): extract _build_create_kwargs/_effective_model,
import SESSION_DEFAULT_MODEL
- `8f5c7621` — fix(ui): restore intent-key for agent cache store to fix
miss regression (amd#842)
- `a0fdb109` — docs(plans): fix broken CMU link to EMNLP 2004 Email
Speech Acts paper (amd#817)
Full Changelog:
[v0.17.3...v0.17.4](amd/gaia@v0.17.3...v0.17.4)
---
## Release checklist
- [x] `util/validate_release_notes.py docs/releases/v0.17.4.mdx --tag
v0.17.4` passes
- [x] `src/gaia/version.py` → `0.17.4`
- [x] `src/gaia/apps/webui/package.json` → `0.17.4`
- [x] Navbar label in `docs/docs.json` → `v0.17.4 · Lemonade 10.0.0`
- [x] All 5 commits in the range (v0.17.3..HEAD) are represented in the
notes
- [ ] Review from @kovtcharov-amd addressed
---------
Co-authored-by: Tomasz Iniewicz <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
…865) ## Summary Gemma-4-E4B-it-GGUF becomes GAIA's default model for all roles (LLM, VLM, installer profiles, CLI, Agent UI, eval, EMR). Simultaneously inverts the tool-call priority chain so native OpenAI `tool_calls` is the primary path, with embedded-JSON format falling back only for legacy non-tool-calling models. Also bumps the minimum Lemonade version to v10.1.0 (which moved its default port from 8000 → 13305 and is where Gemma 4 support was added). This ships on top of the existing UI model-resolution fixes (#841, #842). Resolves #863. ## What changed and why - **Universal Gemma default** — Gemma 4 E4B is natively multimodal (~4.5B effective params, 128K context, Apache 2.0), making it the right single default across the LLM/VLM split that previously required two different models. Footprint drops 19.7 GB → 5 GB. - **Native tool_calls path** (Lemonade v10.1.0+ `--jinja`) — GAIA now passes `tools=[...]` to Lemonade for tool-capable models. The response comes back as native `tool_calls`; `LemonadeProvider.chat()` encodes them as a sentinel JSON string (`{"__tool_calls__": ...}`) so no callers need a type change. `_parse_llm_response` detects the sentinel and returns the unified `{"tool": ..., "tool_args": ...}` dict. - **System-prompt gating** — The embedded-JSON format block (`_PLANNING_FORMAT`/`_CONVERSATIONAL_FORMAT`) is excluded from the composed system prompt for tool-calling models; it actively prevented native `tool_calls` in prior testing. - **Startup validator** — `_validate_profile_model_registry()` raises at import time if any `AGENT_PROFILES` entry references a model key not in `MODELS`. - **Lemonade v10.1.0+ / port 13305** — `DEFAULT_PORT` flipped from 8000 to 13305 (Lemonade's [spring-cleaning release](https://github.com/lemonade-sdk/lemonade/wiki/Migration#v10x---v101) changed the default). 75 files updated (agents, UI, MCP bridge, RAG SDK, VLM, CLI, tests, docs). `min_lemonade_version = 10.1.0` everywhere `INIT_PROFILES` is declared. - **Eval baselines** — Pre-swap Qwen3.5-35B baseline at commit `3b51ca92` and post-swap Gemma-4-E4B baseline both committed under `tests/fixtures/eval_baselines/`; Gemma outperforms Qwen 14/15 vs 13/15 (see comment below for per-scenario breakdown). ## Test plan - [x] `python -m pytest tests/unit/ --ignore=tests/unit/chat/ui/ -q` → 928 passed, 16 skipped - [x] `python -m pytest tests/unit/test_tool_call_priority.py -v` → 23 passed (sentinel detection, native branch parsing, edge cases, prompt gating, startup validator) - [x] `python util/lint.py --black --isort --flake8` → all pass - [x] Eval against Gemma-4-E4B on Lemonade v10.2.0, Sonnet judge → 14/15 scenarios pass, beats Qwen baseline (see comment) - [x] Verified `claude -p --model claude-sonnet-4-6` was actually the judge (not Opus) via `modelUsage` in test subprocess ## Open follow-ups (not blockers for this PR) - `tool_selection/known_path_read` regression: Gemma doesn't discover indexed-internal-copy fallback path in Turn 1 after Access-Denied on the original. Prompt-engineering candidate. - `/api/system/status` reports the catalog `ctx_size` even when Lemonade loaded the model with a smaller window. Surface a warning when they diverge; a whole eval run was wasted due to this mask. --------- Co-authored-by: Tomasz Iniewicz <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
Bring this branch up to date with the v0.17.4 release window on main, including the model-id resolution fixes (#841/#842) that overlap our Settings Active-Model thread. Conflict resolution (single file, two call sites in _chat_helpers.py): both branches changed the registry.create_agent() invocation. Main introduced _build_create_kwargs() to handle custom_model + DB-default model omission for #841/#842; this branch added _session_agent_kwargs() to forward rag_documents/library_documents/allowed_paths/ui_session_id into registry-built agents. The two helpers have disjoint key sets, so the resolution is to expand both: model_id/silent_mode/debug from _build_create_kwargs, session context from _session_agent_kwargs. The regex shape-test in test_chat_helpers.py was anchored on the old "model_id=model_id, streaming=True" prefix; reanchored to the streaming=True ... _session_agent_kwargs( pattern to track the new call-site shape.
Fixes #841 — Agent UI ignores custom agent model choice.
Summary
_chat_helpers.pyunconditionally passedmodel_id=<session model>toregistry.create_agent(), defeatingkwargs.setdefault("model_id", ...)in custom agents.setdefaultonly fires when the key is absent — an explicit kwarg, even if it equals the default, silences it.SESSION_DEFAULT_MODELfromdatabase.py— single source of truth replacing a duplicate string literalcreate_kwargsconditionally via_build_create_kwargs(): omitmodel_idwhen the session is at the DB default so the agent's__init__setdefault governscustom_modelsetting > session-explicit (≠ DB default) > omit kwarg_effective_model(agent, fallback)(explicitNonecheck, notor) for_maybe_load_expected_modelpre-flight — Lemonade warm-up targets the agent's actual effective model after construction; log statements use it for observability_store_agentcache key uses the pre-constructionmodel_id(session intent) to match_get_cached_agent's lookup key — keeping store/lookup keys in sync regardless of what setdefault choosesThe initial implementation used
_effective_modelfor the cache store key too, which caused a cache miss every turn for custom agents (e.g. those scaffolded frombuilder/template.py) whose setdefault model differs from the session default. A follow-up commit fixes that regression.Test plan
pytest tests/unit/chat/ui/test_agent_model_override.py— registry mechanism: custom agent withsetdefaultgets its own model when UI omits kwargpytest tests/unit/chat/ui/test_chat_helpers_model_resolution.py— 10 unit tests: three-branch precedence, pre-flight contract, two static regression guards (bug: GAIA AgentUI ignores custom agent model choice #841 antipattern + cache-key divergence), cache-hit on second turn, ChatAgent bypasspytest tests/integration/test_chat_ui_integration.py::TestCustomAgentModelChoice— end-to-end HTTP pathpytest tests/unit/ --ignore=tests/unit/chat/ui/test_sse_confirmation.py— full unit suite