Skip to content

feat(gaia): add a fast conversational path to the flagship agent - #4114

Closed
kovtcharov-amd wants to merge 11 commits into
mainfrom
kalin/gaia-fast-mode
Closed

kovtcharov-amd wants to merge 11 commits into
mainfrom
kalin/gaia-fast-mode

Conversation

@kovtcharov-amd

@kovtcharov-amd kovtcharov-amd commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Saying "hi" to the flagship agent used to cost as much as asking it to search a repository. Its whole tool surface — documents, files, the web, the skill library — is re-read by the model on every call of a turn, and a turn is two to five calls. A session that was only ever going to be conversation paid for all of it: 17,955 tokens of fixed prompt against the 1,484 the Chat agent charged for the same greeting.

Fast mode gives that back. GAIA_FAST=1 (or GaiaAgentConfig(fast=True)) runs the session as a plain conversational agent: 2,176 tokens, 1.47× Chat — inside the 2× bar #4103 set. It's opt-in and session-scoped; a default agent is byte-identical to before. The personality and honesty rules stay, so it still sounds like GAIA.

This unblocks #3923: retiring the chat agent id no longer costs conversational users their speed.

Closes #4103.

⚠️ The eval scenario has not been run

eval/scenarios/personality/small_talk_stays_small.yaml is written and validated — it parses and find_scenarios() loads it — but it was never executed. The CI judge's Anthropic org is out of monthly spend until Sep 23 (#4080). It also guards ordinary-session behaviour, not the fast path, which has no agent_type of its own to select. A reviewer should treat the behavioural half as unverified until #4080 clears.

There is also no tests/fixtures/eval_baselines/gaia-flagship baseline, and none can be generated without running the eval.

Test plan

  • pytest hub/agents/gaia/python/tests/ -q → 353 passed, 3 skipped
  • pytest tests/unit -k project_map -q → 84 passed
  • pytest tests/unit -k scenario -q → 47 passed (includes scenario validation of the new YAML)
  • python util/lint.py --black --isort → clean on the changed files
  • GAIA_FAST=1 on a real session answers a greeting and cannot reach documents or files
  • Once ci(eval): every eval gate dies in preflight — the judge org is out of monthly spend #4080 clears: gaia eval agent --category personality --agent-type gaia
🔍 Technical details

Measured, not estimated. tiktoken cl100k_base, one agent per process (Agent._TOOL_REGISTRY is module-global and accumulates), memory disabled so the numbers reproduce off a dev box — the same conditions that produced #4103's published chat reference. All five rows were taken in a single pass on the merged tree; the default flagship's prompt drifts a few dozen tokens with ambient memory state, so rows from different sittings should not be mixed.

config prompt tok tools tool tok fixed prefill × chat
chat agent 889 3 595 1,484 1.00
gaia default 3,282 75 14,673 17,955 12.10
gaia prompt_profile="chat" before 1,986 20 4,318 6,304 4.25
gaia prompt_profile="chat" after 1,986 3 595 2,581 1.74
gaia fast=True 1,581 3 595 2,176 1.47

Two mechanisms, in hub/agents/gaia/python/gaia_agent/agent.py:

  • _apply_fast_mode rewrites the config to prompt_profile="chat" — the one ProfileSpec with no tool_groups, so every downstream read already behaves and nothing needs a fast-mode special case. It also clears the enable_* flags, which add prompt text and register no tools; left on, the session would describe filesystem, scratchpad and browser tooling it cannot call. Skill selection goes off too, which pins gaia-voice: a greeting is exactly the turn a semantic chooser scores too low to render.
  • _profile_registers_tools gates this agent's own registrations behind the same early-return ChatAgent applies. Rows 3 and 4 of the table are that one guard: prompt_profile="chat" alone still leaked 17 tools (skill library, skill learning, code index, email) because the extras ran before super()._register_tools() and never read the profile. That's a real fix for anyone who set the profile by hand, independent of fast mode.

GAIA_FAST wins over the config field in both directions, matching GAIA_DYNAMIC_TOOLS, and the resolved value is written back so config.fast never disagrees with how the agent was built.

One unrelated correctness fix. ProjectMapMixin._code_index_status is now guarded on index_codebase being registered. Every line it emits advises calling a code-index tool — the same guard _maybe_start_background_index already applies to the trigger. Latent before this change; fast mode is the first config that makes it reachable.

Not fixed, deliberately: the file-editing and vision mixins render their prompt blocks unconditionally (~172 tokens), so a fast session still describes edit_file. That predates this change, the chat agent carries it today, and fixing it edits a prompt every shipped agent sees — which needs an eval run this change could not have. Noted in the test docstring.

Merged with origin/main, not rebased. One conflict, in hub/agents/gaia/python/tests/test_gaia_agent.py — both sides appended a section; both kept. Main had since added read_tool_output to the bare conversational surface, so the fast-mode surface assertion was re-pinned to the three-tool list and the invariant that actually matters (none of this agent's 17 extras come back) is now asserted separately.

Local suite is not green on this machine, on either branch. pytest tests/unit/ reports 567 failed / 542 errors on untouched origin/main and 669 / 542 on this branch, all Windows-environment noise (missing gaia-* console scripts, /fake/home vs \fake\home goldens, a locally-running Lemonade that 401s). The 542 errors are identical between the two, and every test failing here but not on main passes when re-run in isolation — those extra rows came from running two full suites concurrently.

Ovtcharov and others added 3 commits September 17, 2026 15:06
The scorecard refresh ran the full eval 3x purely to compute a variance band.
That cost 346 of the 384 minutes of the only FULL run that has ever completed
(250 emails x 3 = 750 sequential classifications). The committed card shows what
it bought: within-one-bucket stdev 0.0023 (cv 0.27%), and urgent_recall /
personal_recall identical to the digit across all three runs.

Dropping to one run is not a one-line change. At experiments=1 the harness
records stdev 0.0 rather than omitting it, so the gate's k*stdev band collapses
to zero and the comparison silently becomes a strict '<' -- stricter than
before, tripping on sub-noise wobble. The band is now
max(k*stdev, --regression-floor-pp) with a 1.5pp default floor, sized against
the 1.16pp stdev this workflow's own comment cites from an earlier basis.
Absolute bars are unchanged and still enforce independently of the band.

Also adds a blocking LLM-coverage assert. EmailTriageAgent has a heuristic path
that classifies without calling the model, and on that path llm_classified_count
is absent from the scorecard rather than zero -- so a rules-only run produces a
complete, green, meaningless card. A PR-profile run triaged 20 messages in 14s
(0.7s/message) against the full profile's 27.7s/message, which is what prompted
looking. The assert runs before the judge steps so a void run costs no judge
spend.

Re-derives the timeout budget against measured numbers (benchmark ceiling
620 -> 210 min) and restores the tool-timeout-fires-first ordering on both
profiles. Corrects the "~10h" wall-clock figure repeated across four files: it
was a padded budget ceiling, never a measurement.

The committed card still records n_runs=3, so the basis guard will reject the
new 250/1 default until one deliberate rebaseline=true dispatch re-cuts it. The
guard's remediation text now leads with that path instead of steering back to
experiments=3.

Test file IO gains explicit utf-8: tests/unit/eval/test_scorecard_gate.py was
unrunnable on Windows (cp1252 vs the scorecard's sigma), which hid 29 failures.
The step that proves the eval actually reached the model had no timeout-minutes in the PR-gate workflow, while the identical step in email_scorecard_refresh.yml caps at 10. An infra hang (unresponsive filesystem, missing eval-out) would have burned the scarce serial Lemonade slot until the 90-minute job cap killed it anonymously, instead of failing at a named step.
A session spent entirely on conversation paid the flagship's full tool
surface on every LLM call — 17,194 tokens of fixed prefill against the
1,227 the chat agent charged for the same greeting, re-read two to five
times per turn. Retiring the chat agent id would have cost those users
real latency.

GAIA_FAST=1 (or GaiaAgentConfig(fast=True)) composes the session as the
bare conversational profile: 1,919 tokens, 1.56x chat, inside #4103's 2x
bar. Opt-in and session-scoped — a default agent is byte-identical to
before.

Two mechanisms, measured rather than argued:

- _apply_fast_mode rewrites the config to prompt_profile="chat" and
  clears the enable_* flags, which add prompt text but register no
  tools; left on they would describe filesystem, scratchpad and browser
  tooling the session cannot call.
- _profile_registers_tools gates this agent's own registrations behind
  the same early-return ChatAgent applies. Without it, prompt_profile=
  "chat" still leaked 17 tools (skill library, skill learning, code
  index, email) and cost 5,850 instead of 2,236.

Also guards ProjectMapMixin._code_index_status behind the presence of
index_codebase: every line it emits advises calling a code-index tool,
which a narrow agent does not have.

The personality scenario is the behavioral half and has NOT been
executed — the CI judge's Anthropic org is out of monthly spend (#4080).
It parses and loads via find_scenarios(); it does not exercise fast mode.
@github-actions github-actions Bot added documentation Documentation changes devops DevOps/infrastructure changes eval Evaluation framework changes tests Test changes performance Performance-critical changes agents agent::email Email agent changes sidecar Agent sidecar contract / harness labels Sep 22, 2026
# Conflicts:
#	hub/agents/gaia/python/tests/test_gaia_agent.py
…ol_output

The bare conversational profile gained a third tool on main, so the fast-mode
surface assertion failed on the merge. Pinning the exact list is still the
clearest way to show the collapse, but the invariant that actually matters is
that none of this agent's own 17 extras come back — that is now asserted
separately, so a future ChatAgent change is a one-line pin update rather than
an ambiguous failure.

Measurements re-taken on the merged tree: chat 1,484 · flagship default 17,867
· prompt_profile="chat" before the fix 6,216 · fast mode 2,176. Fast mode is
1.47x chat, still inside the 2,500 ceiling. Docs and docstrings carry the new
numbers.
The default flagship's prompt drifts by a few dozen tokens with ambient
memory state, so the doc line and the docstring were quoting rows taken at
different moments. Both now cite the same run: chat 1,484 · default 17,955 ·
prompt_profile="chat" before the tool gate 6,304 · fast 2,176.
Resolves a conflict in _register_tools(): keeps this branch's
profile-gating (skip registering 17 tools on a profile whose spec
already early-returns) while adopting main's skill-catalog rework,
which replaced the discovery-based _maybe_build_skill_discovery with
_resolve_skill_catalog_enabled after that method was deleted upstream.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The fast mode implementation is clean. _apply_fast_mode is a one-way config rewrite with no special cases; _profile_registers_tools correctly gates GaiaAgent's extras using ChatAgent's existing early_return signal rather than adding a separate fast-mode branch; the ProjectMapMixin._code_index_status guard is the right fix for the latent tool-mismatch. Tests cover the budget ceiling, tool registration, env override in both directions, and voice persistence — this is a well-exercised change.


🟡 The hub package ships with docs that don't know about GAIA_FAST. hub/agents/gaia/npm/SPEC.md and SKILL.md both document comparable env toggles (GAIA_DYNAMIC_SKILLS, GAIA_SKILL_SET, GAIA_DYNAMIC_TOOLS) but say nothing about GAIA_FAST or GaiaAgentConfig(fast=True). CHANGELOG.md has no entry for this feature. An integrator reading the published package docs has no way to discover the one switch that drops prefill from 18K to 2K tokens — exactly the audience who cares most.

Per CLAUDE.md's "update EVERY doc that describes it" rule, the SPEC, SKILL, and CHANGELOG need entries alongside the docs/guides/gaia.mdx update already in this PR.

🟢 eval/scenarios/personality/small_talk_stays_small.yaml pins agent_type: gaia. CLAUDE.md says "scenarios no longer pin their own" — the default is already gaia, so this is redundant and inconsistent with the convention. Remove the field so the scenario composes naturally with --agent-type overrides.

🔍 Technical details

Missing SPEC.md coverage. hub/agents/gaia/npm/SPEC.md:311-312 is the right place — it already documents the GAIA_DYNAMIC_SKILLS family. Add a short paragraph on GAIA_FAST there.

Missing SKILL.md coverage. hub/agents/gaia/npm/SKILL.md:438-459 covers GAIA_DYNAMIC_SKILLS and GAIA_SKILL_SET with token-cost context. GAIA_FAST belongs in the same section — it is the largest single token-cost knob the integrator can turn.

Missing CHANGELOG.md entry. hub/agents/gaia/npm/CHANGELOG.md has an unreleased [0.1.1] section. Add a line to Added: for fast mode.

Eval scenario. eval/scenarios/personality/small_talk_stays_small.yaml:6 — drop the agent_type: gaia line.

wait_for_condition (#3402) ships in the same shell bundle as
run_shell_command, so it now reaches the bare chat profile fast mode
composes as. Pin and ceiling updated to the new, intentional baseline
-- still under a quarter of the default profile's cost.

Also drops a stray agent_type key from a scenario this branch owns:
the eval runner no longer honors per-scenario pins.
itomek added a commit that referenced this pull request Sep 28, 2026
One conflict: main's #4376 added `_workspace_core_tools` at the same anchor
where #4114 added `_profile_registers_tools`. Unrelated methods, both kept.

Re-verified rather than assumed after the merge: the generator still derives
94 tools (CORE 16 + 24 bundles), fast prefill is still 2,860, and the default
moved 17,652 -> 17,620, which the guide and CHANGELOG now say.

main's 4a0a069 raised the tool-description budget to 500 chars, so the
read_tool_output overage this branch inherited is gone — `util/lint.py --all`
is now fully green.
@itomek

itomek commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Folded into #4407 with #3721 and #4114, so the three can be tested as one story
instead of one PR at a time. Nothing here is dropped — every commit on this branch
is an ancestor of the combined branch (git rev-list --count <combo>..<this> is 0),
and the branch is left in place.

Closing rather than re-basing: GitHub refuses to repoint the base because there are
no new commits between the two, which is the same fact stated the other way round.

🔍 What changed on the way in

The three PRs each moved the flagship's tool count, which is pinned in six files, and
main had moved underneath all of them. Neither 81 → 89 nor main's 86 was right;
the merged registry is 94 (CORE 16 + 24 bundles), derived by running
packaging/capability_matrix.py rather than by arithmetic.

Several numbers were re-measured on the combined tree because the merge invalidated
them — fast mode registers 8 tools rather than 4, and its prefill is 2,860 against a
2,800 ceiling. Full conflict-by-conflict notes are in #4407's description, and the
evidence run (live Chromium, live Agent UI HTTP, unit differential against a real
main worktree) is in its first comment.

@itomek itomek closed this Sep 28, 2026
@itomek itomek self-assigned this Sep 28, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Sep 29, 2026
…ip's tool surface (#4407)

Three open PRs that change what the flagship agent offers a new user,
folded into one
branch so the story can be tested end-to-end instead of a PR at a time.
Separately,
each was unmergeable: the flagship's tool count is a single integer
pinned in six
files, and all three moved around it while `main` moved underneath them.
Together they
answer one question — **what is a new user offered, and how fast does it
answer** —
with the browser reaching pages that were invisible, the picker no
longer showing four
agents where one is the product, and a fast path so "hi" costs a fifth
of a repo search.

Supersedes #3721, #4108 and #4114. Closes #4103.

## What a reviewer should check

- **The agent can drive a real browser.** Eight tools open a real
Chromium, read it,
click and type, and sign in — the password goes to the human, never the
model, and
the session is stored encrypted. Acting inside a session you signed in
to asks
first. Optional `[browser]` extra; without it none of the eight
register.
- **`chat`, `doc` and `file` are no longer selectable.** Hidden, not
deleted — every
id still resolves, so stored sessions, `*-lite` aliases and eval
scenarios are
  unaffected, and `ChatAgent` remains the flagship's base class.
- **Fast mode.** `GAIA_FAST=1` drops the flagship to a plain
conversational surface
for a whole session: 2,860 tokens of fixed prompt instead of 17,652,
measured.

## The number that forced the grouping

`main` had moved the tool count to 86 and #3721 was still moving 81 →
89. Neither is
right: the merged registry is **94**. It is set here in all six places
that state it,
and `CAPABILITY_MATRIX.md` is regenerated from the code rather than
hand-edited.

<details>
<summary>🔍 Technical details — conflict resolutions and what was
re-measured</summary>

**Merge order** `main` → #3721 (184 commits stale) → #4108 (76) → #4114
(73), one merge
commit each, so all three branches are ancestors and the member PRs show
an empty diff.

**Tool count.** 94 = CORE 16 + 24 bundles, confirmed by executing
`hub/agents/gaia/python/packaging/capability_matrix.py` against the
merged tree, not by
arithmetic. Pinned in `gaia-agent.yaml`, `gaia_agent/__init__.py`,
`test_capability_matrix.py`, `CAPABILITY_MATRIX.md`, `npm/SKILL.md` and
`docs/guides/gaia.mdx`.

**`readiness.pull_model`** — both sides were right and neither was
complete. `main`'s
`is_cloud_model` early raise now runs first (a gateway model must never
reach payload
construction), then #3721's `user.`-prefix checkpoint/recipe branch.
`provision_progress`
also catches `RuntimeError`, which `main`'s guard raises and #3721's
widened `except`
did not cover — it would have escaped a generator that contracts to
yield a failure line.

**`chatStore.ts`** — kept `main`'s `readPref`/`writePref` helpers and
expressed #4108's
two semantic changes through them. Also consolidated
`FLAGSHIP_AGENT_ID`: `main` added
`utils/newTask.ts` exporting it after #4108's base, so the naive merge
left two exported
constants that must change in lockstep.

**Re-measured rather than merged.** Fast mode registers **8** tools, not
the 4 #4114
pinned — #3335 put the three `cli_setup` tools inside ChatAgent's
chat-profile early
return. `FAST_PREFILL_CEILING` 2800 → 3100 (measured 2,860; the
cli_setup schemas are
497 of it). The pin is now a subset plus a size bound, because
`search_documentation`
(needs `npx`) and `search_web` register conditionally and an exact list
flaps between
CI and a dev box.

**Three CI lanes the PRs left asymmetric.** `release_agent_gaia.yml`
froze the binary
without the `browser` extra while its test step claimed to use "the same
extras" — a
released artifact would have registered 86 tools against a manifest
claiming 94.
`test_unit.yml`'s Windows lane and `claude.yml`'s auto-fix lane both run
the full
`tests/unit/` suite but lacked `playwright`.

**`docs/guides/terminal-hub.mdx`** — dropped #3721's "Choosing where
inference runs"
section; `main` now ships `guides/ai-providers.mdx` covering the same
panel, so it would
have said it twice and frozen a second copy of the Lemonade-11.8.1
claim. Cross-reference
added instead.

**Known scope boundaries**, deliberately not fixed here:
- The streaming chat path still special-cases `chat` with a direct
`ChatAgent`
construction where the non-streaming path now goes through the registry
(`_chat_helpers.py`), and `agent_loop.py`'s autonomous tick keeps the
same carve-out.
Making them symmetric is a change to the UI's hot path that needs its
own live-stream
  evidence.
- `read_tool_output` is 69 chars over the tool-description budget. That
docstring is
byte-identical to `origin/main`'s (same SHA) and main's lint lane is
already red at
`6494a1ce` for it. It is a description the model reads, so changing it
is an
  LLM-affecting edit that needs its own eval run.

</details>

## Test plan

- [ ] `pytest hub/agents/gaia/python/tests/
hub/agents/chat/python/tests/` — the tool-count
gates (94 / CORE 16 / 24 bundles), fast-mode pins, and `hidden=True`
registration
- [ ] `pytest tests/unit` — full unit suite
- [ ] `python hub/agents/gaia/python/packaging/capability_matrix.py
--check` — the
      generated matrix matches the code
- [ ] `python util/lint.py --all`
- [ ] `pytest tests/integration/test_browser_use_live.py` — real
Chromium, newly wired
into the offline-integration lane rather than allowlisted out of CI
- [ ] Real-world: Agent UI shows only the flagship in the picker; a
session created
with no `agent_type` lands on `gaia`; a historical `chat` session still
reads
      "Chat" in the sidebar
- [ ] Real-world: `GAIA_FAST=1` answers a greeting, with
`query_documents` /
      `index_codebase` / `list_inbox` absent from the surface

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent::email Email agent changes agents devops DevOps/infrastructure changes documentation Documentation changes eval Evaluation framework changes performance Performance-critical changes sidecar Agent sidecar contract / harness tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retiring the chat agent loses fast conversation: the flagship costs 5-14x its prefill

3 participants