Skip to content

docs(plans): adaptive memory and nightly benchmark plans - #4392

Merged
kovtcharov-amd merged 11 commits into
amd:mainfrom
kovtcharov:docs/plans-adaptive-memory-nightly-bench
Sep 26, 2026
Merged

kovtcharov-amd merged 11 commits into
amd:mainfrom
kovtcharov:docs/plans-adaptive-memory-nightly-bench

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The agent repeats its mistakes across sessions and never learns which approach worked, and the benchmark numbers that would catch a regression are produced by hand on a developer machine, so a 20% cost increase or a dropped task goes unnoticed until someone reruns the suite weeks later. These two plans say how to close both gaps: an outcome-record → attributed-lesson → plan-time-recall loop grounded on the memory and verification code that ships today (memory.py, verification.py), and a nightly CI matrix over the everyday, TheRock and Jan suites on one open model with a two-consecutive-nights regression rule that files a bug issue for the existing auto-fix path. Both are proposals; nothing here changes runtime behaviour.

  • Adaptive memory — cites the extraction ops, reconcile_memory, consolidate_old_sessions, update_memory/forget, the self-healing error store and the per-turn verification record; names what is view-only today (TUI /memory, CLI status/bootstrap), and ends with a seed → avoid → unlearn benchmark series and a four-phase rollout.
  • Nightly benchmarks — a reusable bench_suite.yml + nightly_benchmarks.yml matrix on the harness in feat(eval): reproducible harness × model benchmarks (Claude Code harness, TheRock tier, metering) #4335, per-cell metering, a nightly budget cap that skips loudly, a rolling min–max band over seven nights, and the Jan tier's disk / file:// clone / APFS baseline lessons.

Test plan

The agent repeats mistakes across sessions and never learns which approach
worked, and the benchmark numbers that would show it are produced by hand on a
developer machine. Two plan documents: one grounds an outcome-record → attributed
lesson → plan-time recall loop on the memory and verification code that exists
today; the other specifies a nightly CI run of the everyday, TheRock and Jan
suites on one open model with a two-night regression rule that files a `bug`
issue for the existing auto-fix path to pick up.
@github-actions github-actions Bot added the documentation Documentation changes label Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This adds two proposal docs: one on how the agent could learn from what worked and what failed across sessions, and one on running the benchmark suites every night in CI and filing regressions for the existing auto-fix job. Nothing at runtime changes. I spot-checked the code references against main and they hold up, including the line numbers, the CLI memory subcommands, the UI memory routes and the TUI view. The two pages link to each other and are both registered in the docs nav.

Nothing blocks merge. The one thing worth fixing: the adaptive-memory rollout says eval "baselines stay byte-identical" and names the rag_quality and tool_selection baselines as gates. No baselines are committed today, so someone implementing Phase 1 or Phase 3 would go looking for files that don't exist. Rewording those gates to "no drop against a pre-change flagship run" fixes it.

Real-world evidence

N/A: docs-only PR (two plan pages plus a nav entry). There is no runnable surface to exercise, so this verdict rests on static review alone. The author's unchecked Mintlify preview item is still open.

🔍 Technical details

🟢 Minor

  1. Rollout gates cite eval baselines that don't exist (docs/plans/adaptive-memory.mdx, Phase 1 and Phase 3). tests/fixtures/eval_baselines/ is absent on main, and CLAUDE.md says the old baselines were deleted and no flagship baseline has been committed yet. "byte-identical" also reads as a file comparison, when the real claim is that the prompt doesn't change.

    memory eval category (`gaia eval agent --category memory` and `--category gaia_memory`), which must score no worse than a pre-change flagship run because the prompt is unchanged.
    

    Phase 3 would need the same kind of rewording: "no drop in rag_quality / tool_selection against a pre-change flagship run (or the committed gaia-flagship baseline once one exists)".

  2. Meter lag reads as a contradiction (docs/plans/nightly-benchmarks.mdx §3.3). "trails by ~90 s (DEFAULT_METER_LAG_S = 150)" puts two different numbers side by side. If 150 is 90 plus a safety margin, say so in a few words, e.g. "trails by ~90 s; the harness waits DEFAULT_METER_LAG_S = 150 to be safe".

  3. Retired-lesson wording (adaptive-memory.mdx §3.3). "Below 0.2 the row is superseded by nothing (status-style…)" is hard to parse. §4 already defines superseded_by = 'retired:<reason>', so pointing to it here (e.g. retired:decayed) would keep the two sections consistent.

Strengths

  • The citations are real, and I checked several: _forget_errors_for_operation at memory.py:2841, the +0.02 recall bump in memory_store.py, verification_record / unsupported_test_claim at verification.py:747/785, and the CLI having only status / bootstrap. The plan builds on code that actually ships.
  • The nightly plan follows the fail-loudly rule: a budget cap skips with a visible ::warning:: and the night counts as "did not measure", never as a pass. The two-consecutive-nights rule and the reset on judge-model change are sound defences against noise.
  • The Jan-tier notes (file:// clone to honour --depth, disk sizing, the TZ=UTC pin) are concrete, hard-won details that will save whoever implements it a rediscovery.

kovtcharov and others added 10 commits September 26, 2026 08:30
`docs/reference/eval.mdx` spent ~1,400 lines walking through `gaia
generate`, `groundtruth`, `batch-experiment`, `visualize`, and
`create-template` — every one removed from the CLI in v0.18 — before the
eval commands that actually exist. A reader following the page from the
top hits a dead command in the Quick Start, and the deprecation banner
asked them to read past all of it to reach the parts that still work.

The page now leads with the three live commands (`gaia eval sessions`,
`gaia eval agent`, `gaia eval tasks`) and keeps only the sections
describing running code: session replay, the agent eval benchmark
pointer, and the flagship task gate. Deleted content is in git history.

Overlaps open PR amd#3812 ("docs(core): retire legacy plans and refresh
harness and TUI docs"), which only swaps `lemonade-server serve` → `gaia
init` on this page and doesn't touch the legacy sections this PR
removes.

## Test plan
- [x] `python util/check_doc_links.py --internal-only` — 1012/1012 OK
- [x] `pytest tests/unit/test_doc_code_validation.py
tests/unit/test_check_doc_links.py -q` — 58 passed
- [x] Verified live subcommands against `gaia eval` subparsers in
`src/gaia/cli.py` (`agent`, `benchmark`, `sessions`, `code`, `tasks`)

Fixes amd#4247

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
`gaia talk` heard itself: the microphone stayed live while it spoke, so
its own voice came back as the next request. It also accepted `--model`,
`--max-tokens`, `--use-claude`, `--use-chatgpt`, `--claude-model`,
`--base-url` and `--stats`, then ran without them. Now capture pauses
for the whole of playback and every flag reaches the component that uses
it.

Outside voice, an Agent UI chat turn could hang forever on an `input()`
prompt printed to the server's own terminal — a server-side console now
never prompts, while the CLI still does — and `import gaia` crashed in
any process without a resolvable home directory. Also fixes the wrong
port in `.env.example` and a length mismatch that could misalign RAG
chunks with their embeddings.

Fixes amd#124

## Test plan

- [ ] `python -m pytest tests/unit/test_audio_recorder_sd.py
tests/unit/test_cli_talk_flags.py
tests/unit/test_logger_home_unresolvable.py
tests/unit/test_rag_encode_alignment.py tests/unit/test_talk_config.py
tests/unit/test_talk_playback_mute.py
tests/unit/test_ui_no_stdin_prompts.py` — 63 passed; the two of these
files that exist on `main` pass 16/16 there
- [ ] `python -m pytest hub/agents/chat/python/tests` — 14 passed in
1.70s
- [ ] The `ChatAgent` wiring test fails if the validator's
`interactive_check` hook is removed — checked by removing it
- [ ] `gaia talk --help` lists every flag, and `gaia talk --use-chatgpt`
refuses and exits 1
- [ ] `import gaia` in a subprocess with the home-directory variables
removed succeeds
- [ ] With a real microphone and speaker: talk over playback and confirm
it is not transcribed (not run on the author's machine)
- [ ] Agent UI started from a terminal: a turn that needs a path outside
the allowlist is denied without prompting the server's stdin (not run
end to end)

---------

Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
…md#4186)

The website, the Agent UI, and the terminal each carried their own
palette, so GAIA's copper appeared as three near-but-unequal golds and
the same assistant looked like three products. All three now implement
one set of colour roles from one set of literals, and each surface has a
test that fails when a component writes a hex inline instead of asking
for a role. `docs/spec/gaia-design-language.mdx` is the source of truth
for what the roles are, what contrast each owes the reader, and why the
light copper is not a darkening of the dark one.

Implements milestone 0 of the redesign plan in amd#3803, plus the theming
half of milestone 5. The shell simplification (milestone 2) stacks on
top of this in a follow-up.

## What it looks like

The welcome headline used to keep a cursor blinking at a sentence
nothing was writing to — the first thing every new user saw. The chat
transcript had the same defect. Both now go quiet the moment the text
stops.

| Before | After |
| --- | --- |
| ![Welcome headline with a cursor still blinking after the subtitle
finished](https://raw.githubusercontent.com/amd/gaia/7aeb753343094ff46dfaf4fa7140336b558dbad3/evidence/02_agentui_light.png)
| ![Same headline, settled, no
cursor](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/02_agentui_light.png)
|
| ![Chat answer ending in a blinking cursor after the turn
completed](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/03a_chat_light_before.png)
| ![Same answer, settled, no
cursor](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/03_chat_light.png)
|

Dark mode on the same palette — copper is the only accent; green and
amber appear solely as status, never decoration:

![Agent UI welcome screen in dark
mode](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/01_agentui_dark.png)

![Dark chat transcript with tool-call
results](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/04_chat_dark.png)

The agent-picker grid under the headline is the surface milestone 2
removes — the shell is being rebuilt around the flagship agent, not a
hub of them.

## The other threads

- **The website now offers both downloads.** It advertised the desktop
app only, so the terminal build — which ships six platform targets to
the desktop's three — was invisible to anyone who did not already know
it existed. Both are presented side by side, and asymmetric platform
coverage raises an actionable error instead of rendering an empty card.
- **Three controls had no visible keyboard focus at all**, light-theme
status badges read below 4.5:1, and picking an agent then clicking a
welcome chip quietly opened a session on a different one. All three
shipped green because the guards meant to catch them each matched
exactly one spelling of the mistake.

## Two design calls worth a second opinion

Both change what users see, so please push back if you disagree rather
than let them ride in:

- **Tools in the activity list no longer have their own colours.**
Green, amber, red, and blue carry status meaning, so they are not
available for decoration — keeping the per-tool table meant a green tool
badge sitting directly beside a red failure icon in the same row. Tools
are now told apart by their icon.
- **The animated starfield and constellation backgrounds on the website
are gone.** The design language rules out decorative motion; nothing
else referenced them.
- **Inline code keeps the accent in the terminal renderer.** A code span
is a different kind of token rather than a louder one, and the accent is
what makes it findable — but a paragraph with six `` `flags` `` in it
does speckle, so it is worth a second read.

## What catches the next regression

Guards, each written because a real defect got past the previous one:
token contrast per surface in both themes, no colour literal outside the
token file, and call-site pairing — the fg/bg pair a component actually
ships is measured, not just the pairing the tokens intended. That last
one matters most: token-level assertions rated a hover state fine that
shipped at 4.15:1.

**Two of these guards were green while broken**, and neither was found
by reading them. A focus-ring regex backtracked to zero width, so
`outline: none` counted as "paints an outline"; an Electron assertion
matched a type annotation instead of the default it was pinning. Every
guard here is now mutation-proven — the mistake it exists to reject is
re-injected and observed to fail it. That is the argument for the
mutation step, not a footnote to it.

## Known non-conformance

`--accent` on `--bg-active` reads 4.15:1 against a 4.5 floor, and is
excluded deliberately. The copper is pinned across all three surfaces,
and lightening the active surface enough to clear the floor pushes it
past `--bg-hover`, inverting the depth ramp. It needs a cross-surface
accent decision, which is larger than this PR.

## Test plan

- [x] `cd src/gaia/apps/webui && npx vitest run` — 637 pass, 59 files
- [x] `cd src/gaia/apps/webui && npx tsc --noEmit` — clean
- [x] `cd src/gaia/apps/webui && npm run build` — clean
- [x] `cd tests/electron && npx jest test_electron_chat_app.js` — 196
pass
- [x] `cd website && npx vitest run` — 213 pass
- [x] `cd website && npx astro check` — 0 errors, 0 warnings
- [x] `cd website && HUB_CATALOG_URL=https://hub.amd-gaia.ai npm run
build` — completes (needs network; the build has no fixture fallback by
design. Behind a TLS-inspecting proxy add
`NODE_OPTIONS=--use-system-ca`.)
- [x] `cd tui && go vet ./... && go test -count=1 ./internal/ui/...` —
clean, all packages pass
- [x] `python util/check_doc_links.py` — 2496 links, 0 broken
- [x] Toggle light/dark in the Agent UI and on the website; confirm code
panels stay dark in both and the `>` prompt, focus ring, and primary
button are the only coloured things on screen
- [x] Tab through the file browser, activity filters, and update chip in
both themes; every control shows a ring

`Test Agent SDK on Windows (Lemonade Integration)` is red here for
amd#4281, a self-hosted-runner bug unrelated to this PR — a leftover state
file points the tests at a dead port. It fails the same way on unrelated
branches and is fixed by amd#4284.

---------

Co-authored-by: f <f@f>
GAIA needed you to run `lemonade-server serve` before anything worked —
a command Lemonade removed in 10.7, so on any current install it fails
with "command not found" and the user is left with no path forward. Now
the daemon starts the local model server itself, supervises it as a
child, and reaps it on shutdown. Launch the TUI, or run `gaia chat` /
`gaia llm`, on a machine with nothing running: it comes up working, with
nothing typed.

The daemon owning the process is what makes "one server per machine"
real rather than a race that usually works. Front-ends ask over the
authenticated loopback channel they already use (`POST
/daemon/v1/lemonade/start`, host API 1.2); nothing else spawns a server.
A server the daemon did *not* start — one launched from the tray — is
attached to and left running, including when the daemon stops.

Failures stay loud: not installed, port held by something else, the
server died on launch, the daemon unreachable — each names what failed,
what to do, and where to look. Nothing degrades quietly to "no LLM".

<details>
<summary>🔍 Technical details</summary>

- `LemonadeSupervisor` (`src/gaia/llm/lemonade_supervisor.py`) probes,
starts the server in its own process group, polls `/health`, and
tree-kills on shutdown — tree-kill because Lemonade spawns
`llama-server` children, and an orphan still holds the port and the GPU
memory the next start needs. No new locking scheme: the daemon is
already single-instance, so its in-process lock is the whole story.
- `ensure_lemonade_running` (`src/gaia/llm/lemonade_service.py`) is the
one verb. Inside the daemon it uses the supervisor directly; everywhere
else it start-or-attaches the daemon and asks.
- Launch resolution is unchanged and untouched: everything goes through
`resolve_lemonade()` / `build_start_command()` and treats
`StartSpec(argv, env)` as opaque. The embeddable `lemond ./ --port N`
form (PR amd#3117) takes a working directory and port the others do not, so
nothing here inspects or rebuilds argv — bundled-lemond support arrives
behind the same seam for free.
- `LemonadeClient.health_check` gained an optional `timeout`. The client
default (900s) is right for generation and catastrophic for a liveness
probe: a socket that accepts and never answers would block one for 15
minutes.
- The stale-command sweep covers runtime messages (`readiness.py`, the
email sidecar's `/init` and `/query`, the playground), hub agent docs,
and ~45 doc-site pages. `--ctx-size` went with it — GAIA pins the window
per device profile, so telling a user to set one is wrong advice that
looks like it works.

Not in scope, worth a follow-up: `gaia init` still starts a server
directly (`installer/init_command.py`), so it can leave an unsupervised
one the daemon will attach to and never reap.
</details>

## Test plan

- [x] Cold start, nothing running: `gaia daemon stop && taskkill /F /IM
LemonadeServer.exe && rm ~/.gaia/host/instance.json`, then `gaia llm
"..."` — answers, having started the daemon and the server itself.
- [x] Cold start through the TUI's readiness gate: `gaia-tui run email
--query "..."` from a stopped server — answers; daemon log shows
`lemonade: starting supervised server` then `lemonade_routes.start`.
- [x] Go client against a live daemon: cold 9.8s, warm 26ms (one probe).
- [x] `gaia daemon stop` reaps the server it started; a tray-launched
server survives it (`/daemon/v1/lemonade/status` reports `supervised:
false`).
- [x] Daemon boot alone does not start a server — it is on demand.
- [x] `python -m pytest tests/unit/test_lemonade_{supervisor,service}.py
tests/unit/test_daemon_lemonade_routes.py
tests/unit/test_lemonade_manager_autostart.py` — 40 new tests pass.
- [x] `cd tui && go test ./...` — 3 failures, all reproduced on a
stashed tree (`TestKeysDriveTheRightActions`,
`TestHubCatalogLoadSurvivesTheChatView`,
`TestASubprocessAgentIsNotGated`).
- [x] Wider Python suites match their pre-existing baseline exactly (40
failures, all reproduced with the branch stashed — Windows path
assumptions and the unit-test socket guard blocking `TestClient`).
- [ ] Reviewer: `grep -rn "lemonade-server serve" docs/ src/ hub/`
returns only comments explaining why the command is dead.

---------

Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
…ormed reply (amd#4031)

When the model sent a malformed tool call, GAIA could end the turn with
"I had trouble formatting my tool call. Could you rephrase…" without
retrying once. The give-up counted every failed tool call toward its
limit of three, including refused commands and failing or timed-out test
runs. In a benchmark run the agent had tracked down a hanging test,
three commands had failed along the way, and its first malformed reply
threw the whole answer away. Malformed replies now have their own budget
of three; ordinary debugging no longer spends it.

## Test plan
- [ ] `python -m pytest tests/unit/agents/test_parse_error_recovery.py`
passes. On main, `test_a_malformed_reply_after_failing_tools_is_retried`
fails: the loop stops after 4 model calls instead of retrying.
- [ ] Three malformed replies still end the turn with the friendly
message (`test_three_malformed_replies_still_give_up`, and the existing
`test_three_consecutive_parse_errors_give_up_gracefully`).

<details>
<summary>🔍 Technical details</summary>

`_process_query_impl` keeps `error_count` for everything else it feeds,
and adds `parse_failures`. It is incremented only where a reply fails to
parse (the tool-call path and the plan path), and those are the two
give-up thresholds that now read it. Per turn, same threshold of 3.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
…checks (amd#4387)

A JavaScript, Go or Rust project's test run was invisible to the agent's
verification record: `npm test`, `go test ./...` and `cargo test` were
recognised as checks, but their output was only ever read for a pytest
or unittest summary. A failing run behind a pipe (`npm test | tail`)
passed on exit code alone, a passing run still drew the "verify your
change" reminder, and the flagship eval's judge could not count it as a
verified test run. One runner table now knows each runner's own summary
line, and the verification footer, the answer seam, and the eval
consumer all read through it; pytest and unittest behave exactly as
before.

## Test plan

- [ ] `python -m pytest tests/unit/agents/test_unsupported_test_claim.py
tests/unit/agents/test_answer_quality_checks.py
tests/unit/agents/test_verification_scope.py
tests/unit/eval/test_flagship_tasks.py -q` — per-runner pass/fail cases
for pytest, unittest, jest, vitest, mocha, `go test`, `cargo test`; a
piped failure fails; a coloured vitest summary reads; `[no tests to
run]` and `--collect-only` do not count
- [ ] `python -m pytest tests/unit/agents tests/unit/eval -q` (2346
passed locally)
- [ ] `python util/lint.py --black --isort --pylint`

<details>
<summary>🔍 Technical details</summary>

- `checks.py`: `_RUNNERS` table (label, summary regex, ran regex,
`per_target`); `runner_summary` picks the summary printed last across
runners, ANSI-stripped; for `go test` / `cargo test` any failing package
or target line decides the run. `_REPORTED_FAILURE_RE` gains `N
failing`, `^FAIL`, `test result: FAILED`.
- `verification.py`: `summary_reports_failure` and
`has_test_run_summary` now go through `runner_summary` instead of a
duplicated pytest/unittest pair of regexes (removed).
- `flagship_tasks.py`: `_test_run_passed` uses the shared table;
`tests_verified` accepts any test-kind check label instead of only
`"pytest"`.
- `docs/sdk/core/agent-system.mdx`: the fallback-classification sentence
names the runners.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
…#3335)

Asking GAIA to triage GitHub issues on a machine without the GitHub CLI
used to end the conversation: the agent told you to install `gh` and run
`gh auth login`, and you went and did it by hand. It now offers to do
both itself — it installs the CLI with your machine's package manager
after showing you the exact command, then starts the browser sign-in and
hands you the one-time code to enter. You approve every step; nothing is
installed or signed in silently.

Three tools (`check_cli_setup`, `install_cli`, `sign_in_cli`) driven by
data on the binary policy, so a second CLI is a table entry rather than
new code. Two details worth a reviewer's attention:

- **`check_cli_setup` reports five states, not "works / doesn't".** The
one that matters is `env_token`: `gh` authenticated from `$GH_TOKEN`
works fine and *refuses* to store a credential while that variable is
set, so reporting it as "logged out" would send you to run a command
`gh` rejects. Signing in is offered only where signing in is the fix.
- **Sign-in waits on the CLI's own exit, not on a second approval
prompt.** That observes GitHub actually completing the grant instead of
you reporting that it did, and it avoids stranding a polling `gh`
process behind a confirmation that either expires in a minute or blocks
forever.

This also narrows the `gh auth` grant: `gh auth token` was already
refused as a credential surface, but `gh auth status --show-token`
prints the same token and ran at the tier that asks nobody.

Scopes requested are `repo` and `read:org` — what the triage skill's
command table can actually reach. GAIA never reads, logs, or stores the
token or the one-time code.

## Test plan

- [ ] `python -m pytest tests/unit/test_binary_setup.py
tests/unit/test_cli_setup_tools.py -q` — 114 tests: all five detection
states, the approval gate, command-echo verification, secret scrubbing,
and child-process reaping.
- [ ] `python -m pytest tests/unit/test_skill_binary_grants.py
tests/unit/test_shell_guardrails.py tests/unit/test_starter_skills.py
-q` — no regression in the existing grant/shell policy (453 passed
locally).
- [ ] Confirm the approval gate cannot be bypassed:
`install_cli`/`sign_in_cli` are in `TOOLS_REQUIRING_CONFIRMATION`,
`grant_scope` returns `None` for both (no "always"), and a loaded skill
grant exempts only read-only `run_shell_command`.
- [ ] Ask the agent "is the GitHub CLI installed and signed in?" — it
should call `check_cli_setup` and report the state without offering a
sign-in when the credential comes from `$GH_TOKEN`.
- [ ] On a machine with `gh` logged out (`GH_CONFIG_DIR` set to an empty
directory, `GH_TOKEN` unset), ask it to sign in — it should show a
one-time code and `https://github.com/login/device`, then confirm the
scopes afterwards.
- [ ] `gh auth status --show-token` is refused; `gh auth status` and `gh
pr view 1 --template x` still run.

### Verified locally

All four reachable detection states were exercised against a real `gh`
2.90.0 (isolated `GH_CONFIG_DIR`, so no developer session was touched),
and the device flow was driven end to end — real code captured, real
child killed on cancel, verified dead by PID. Tool selection was checked
against a live Gemma-4-E4B: "capital of France" takes no tool, "list the
files" still picks `list_files`, and the GitHub question picks
`check_cli_setup`.

**Not verified, needs a reviewer's machine:** a real `winget`/`brew`
install (nothing was installed on the test box), a completed browser
sign-in (needs a human at a browser), and `insufficient_scopes` (needs a
deliberately under-scoped token).

**The eval still needs a run on a quiet machine before merge.** `gaia
eval agent --category tool_selection` could not be completed here — two
attempts stalled in the scenario driver with zero turns recorded:
scenarios that take 180-240s in the committed baseline ran past 1600s,
and a retry against a healthy Lemonade sat 22 minutes on the first
scenario without emitting a turn. `claude -p` answers normally on its
own, so this looks like load on the box rather than anything in this
change, but that is unproven. The three live queries above are
supporting evidence, not a substitute.

---------

Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
amd#4021)

When the agent loaded a skill partway through a turn, the skill's
instructions reached the prompt but its tools didn't reach the tool list
until the next turn. After loading github-triage, whose recipe is "run
every GitHub command through `run_shell_command`", the agent had no
shell tool. It ran `gh` through `run_python` instead, in all 3 benchmark
tasks that loaded the skill (9 calls). For a user, that means an
approval prompt for every GitHub read, where the skill's grant needs
none. Loading a skill now makes its tools callable on the very next
step.

## Test plan
- [ ] `python -m pytest tests/unit/test_skill_tools_same_turn.py`
passes. On main the two reproducing tests fail.
- [ ] Agents without a per-turn tool subset are unchanged
(`test_no_tool_subset_stays_no_tool_subset`).
- [ ] A required tool the agent doesn't have is not added
(`test_a_required_tool_this_agent_lacks_is_not_invented`).

<details>
<summary>🔍 Technical details</summary>

`Agent.load_skill` now adds the skill's `tools_required` and its own
namespaced tools to an active `_active_tool_filter`. It goes through
`_apply_tool_filter`, the same path the `load_tools` escape hatch uses
mid-turn, so both render paths pick it up on the next model call. This
covers a fresh load and a reload of an already-loaded skill. amd#3903
admits active skills' `tools_required` at the next turn's selection.
This PR covers the turn the skill was loaded in, and the two compose.
The helper is module-level because five test stubs borrow
`Agent.load_skill` onto plain classes.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
…4035)

An agent that finished a task and then re-ran the same check a few times
used to have its answer thrown away: the user got "I stopped after
calling `run_python` 3 times in a row without making progress, so I
can't confirm the task is finished" on runs where the code had been
changed, documented, and pytest had passed — the verification line on
that same answer said "verified — pytest ran and passed". A judge scored
one of those tasks 3.00 against Claude Code's 4.75, the largest quality
gap left in the suite. The agent now answers from the work it actually
did; repeats that failed or were refused still report the failure,
because there the failure is what the user needs to hear.

Stacked on amd#4028 and amd#3908, merged in that order (main → amd#4028 → amd#3908 →
this), so the diff here includes both until they land. Together the
guard corrects once in place of the repeated call and only ends the turn
on the next identical call — that closing turn is what this PR changes.

## Test plan

- [ ] `python -m pytest tests/unit/agents/test_loop_break_answer.py
tests/unit/agents/test_loop_guard_correction.py
tests/unit/agents/test_step_cap_final_answer.py
tests/unit/agents/test_loop_break_truthful.py -q` — closing answer on
both tool paths after the correction round, error/refused repeats
unchanged, failure and cancel handling
- [ ] `python -m pytest tests/unit/agents -q` (1056 passed locally on
the merged tree)
- [ ] `gaia eval agent --category tool_selection` shows no regression
against the committed baseline — not run here

<details>
<summary>🔍 Technical details</summary>

- The step-limit closing call was generalised to
`_closing_answer(messages, conversation, instruction, step)`; the
step-limit and loop-guard paths differ only in the instruction they
pass. Both loop-guard call sites (native fan-out and legacy
embedded-JSON) go through `_answer_after_repeated_calls`, which returns
`(answer, steps_taken)` and `(None, …)` when the user pressed Stop.
- Merge resolution at both call sites: `if current_call not in
loop_corrected_calls: … continue` first, then
`print_repeated_tool_warning()` followed by
`_answer_after_repeated_calls(...)` with `consecutive_count - 2` — the
calls that actually ran, the same number `_build_loop_break_summary`
reports.
- The gate is `_repeats_carry_a_failure`: an errored or `status:
"denied"` last result keeps `_build_loop_break_summary`, so amd#3908's
rate-limited / not-permitted / dead-service wording is untouched.
`_build_loop_break_summary` now calls that predicate instead of
repeating the condition.
- The guard stops mid-fan-out, which leaves an assistant tool-call turn
with no result for the call it stopped — Anthropic and other spec-strict
providers reject that outright. `_unanswered_tool_call_messages` answers
every dangling id with "Not run — the turn stopped before this call"
before the closing request goes out, and a test asserts the outgoing
message list accounts for every id (the correction message answers its
own id, so only the stopping call needs sealing).
- On failure the behaviour mirrors the step-limit path: warn, and return
the existing notice with one line saying why the summary couldn't be
written. A reply that asks for a tool instead of answering counts as a
failure.
- The extra call counts as a step and its stats land in `conversation`,
so tokens are aggregated as usual. The verification-scope line is still
appended once, post-loop.
- Both call sites pass `recent_results` (from `previous_outputs`), never
`step_results`, which error recovery clears before every retry — a
legacy-path test fails if that is swapped back.
- amd#3908's own `test_repeat_after_the_correction_ends_the_turn` needed no
change: its repeats return an error, which stays on the summary branch.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: probe <probe@local>
Co-authored-by: Kalin Ovtcharov <[email protected]>
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
@github-actions github-actions Bot added dependencies Dependency updates devops DevOps/infrastructure changes talk Talk agent changes llm LLM backend changes audio Audio (ASR/TTS) changes cli CLI changes eval Evaluation framework changes tests Test changes electron Electron app changes security Security-sensitive changes performance Performance-critical changes website GAIA website (amd-gaia.ai) agents agent::email Email agent changes tui Go terminal UI (gaia-tui) labels Sep 26, 2026
@github-actions github-actions Bot added daemon Daemon supervisor / sidecar control plane sidecar Agent sidecar contract / harness labels Sep 26, 2026
Merged via the queue into amd:main with commit f45f621 Sep 26, 2026
19 of 22 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the docs/plans-adaptive-memory-nightly-bench branch September 26, 2026 17:32
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 audio Audio (ASR/TTS) changes cli CLI changes daemon Daemon supervisor / sidecar control plane dependencies Dependency updates devops DevOps/infrastructure changes documentation Documentation changes electron Electron app changes eval Evaluation framework changes llm LLM backend changes performance Performance-critical changes security Security-sensitive changes sidecar Agent sidecar contract / harness talk Talk agent changes tests Test changes tui Go terminal UI (gaia-tui) website GAIA website (amd-gaia.ai)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants