Skip to content

feat(email): expose search, pre-scan, archive/quarantine & calendar on the REST contract (schema 2.1) - #1883

Merged
itomek-amd merged 18 commits into
mainfrom
feat/email-rest-contract-2.1
Jun 29, 2026
Merged

itomek-amd merged 18 commits into
mainfrom
feat/email-rest-contract-2.1

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The Agent UI lost live inbox actions when the in-process email agent was ripped out (#1653) — search, pre-scan, archive/quarantine, and calendar all ran only inside the agent loop and disappeared from the package surface. This bundles four independently-built branches that put each one back on the REST contract (schema 2.0 → 2.1, additive — a 2.0 client keeps working), so the Agent UI drives them through @amd-gaia/agent-email instead. Every mutating call keeps the same /send-style confirmation-token gate (a missing/invalid token → 403 before any backend call); the read-only calls take no token.

Threads (each independently reviewable):

SCHEMA_VERSION is 2.1; openapi.email.json, specification.html, README/SPEC/SKILL/CHANGELOG, and the TS client/types are all regenerated/synced to match.

Integration notes (caught only because the suites were run together)

Two latent defects survived every per-branch green run and are fixed here:

Test plan

  • cd hub/agents/python/email && python -m gaia_agent_email.export_openapi --check → exit 0 (artifact up to date)
  • python -m pytest hub/agents/python/email/tests/test_rest_contract.py → 61 passed
  • python -m pytest tests/test_email_openapi_conformance.py tests/unit/agents/email/test_contract_schema.py → 77 passed
  • cd hub/agents/npm/agent-email && npm run build && npm test → tsc clean, 58 passed
  • black --check / isort --check / flake8 --select=F clean on all changed files
  • openapi.email.json documents all 16 /v1/email/* routes; info.version == 2.1

Restore the inbox pre-scan capability the Agent UI lost in the #1653
REST rip-out — over the packaged agent's REST contract, not the legacy
in-process path. New POST /v1/email/prescan lists recent inbox messages
from the connected mailbox and returns the triage-card envelope the
EmailPreScanCard renders (urgent / actionable / suggested-archive rows
plus an informational count), reusing the agent's own pre_scan_inbox_impl
classification path — no duplicated categorization.

Read-only; backend resolved by a fail-loud FastAPI dependency mirroring
get_send_backend (503 with no mailbox, 400 with 2+). Contract bumped to
SCHEMA_VERSION 2.1 with EmailPreScan{Request,Result,Response} models, the
OpenAPI artifact regenerated, the npm client gains a typed prescan()
method, and every doc surface (README/SPEC/SKILL/CHANGELOG/specification
.html/spec_html) updated in lockstep.
Follow-up gap fixes for the inbox pre-scan REST surface:
- README badge and specification.html footer still said SCHEMA_VERSION/
  spec 2.0 while the header and contract are 2.1 — synced both (and dates).
- lifecycle.ts VersionCheckOptions docstring said the default was "2.0";
  the default is the SCHEMA_VERSION constant, now "2.1".
- examples/demo.mjs now exercises prescan() (read-only; gracefully skips on
  503/400 when no single mailbox is connected), matching the demo's
  every-method coverage.
The Agent UI lost live inbox search in the #1653 in-process-agent rip-out:
the agent's search_messages capability runs in its agent loop but was never
on the REST contract, so the packaged email agent couldn't drive it. This
restores it through the package — no legacy in-process agent.

Adds POST /v1/email/search: a read-only endpoint that lists messages matching
a Gmail-style query / labels from the connected mailbox and returns inbox-list
metadata (id, thread, subject, from, snippet, labels) — not the body. The
mailbox is resolved by a FastAPI dependency mirroring get_send_backend
(fail-loud: 0 connected → 503, 2+ → 400), injectable in tests via
app.dependency_overrides. Header parsing reuses the agent's
_format_message_for_llm so the REST surface can't drift from the agent's own
search output. Pagination is real: next_page_token round-trips back as
page_token.

Contract bumped to SCHEMA_VERSION 2.1 (additive — no triage shape change, so
checkVersion's MAJOR-only gate still accepts 2.0 clients). npm client gains a
typed search() method + types. OpenAPI artifact regenerated; README/SPEC/
SKILL/CHANGELOG, the runtime /spec page, and specification.html all updated.
…#1781)

Review follow-up. Live Gmail's list_messages sends no labelIds when given
none, so an empty search (no query, no labels) returned ALL mail — but the
fake backend and the docs both said "lists the INBOX." Every test passed
against the fake while live Gmail diverged (the classic mock-masks-live trap).

The search route now forces label INBOX when neither a query nor labels is
given, so live Gmail, live Outlook, and the fake all agree on the documented
default. A query still searches all mail (Gmail search semantics / agent
parity). Tightened the contract field docs to state the exact precedence and
synced SPEC.md + specification.html; added tests asserting the route forces
INBOX on the empty path and does NOT inject a label when a query is present.
…ct (#1780)

After #1653 the Agent UI consumes the packaged email agent via its REST
contract (triage/draft/send only), so it lost the agent's calendar
capability. This restores view / create / respond through the package —
reaching whichever calendar (Google or Microsoft) the user connected — by
exposing the existing calendar backends on the contract; the backends are
unchanged.

- Routes: GET /v1/email/calendar/events (view, read-only),
  POST .../preview + POST .../events (create, gated by the same single-use
  confirmation-token handshake as /send), POST .../respond (RSVP).
- Contract: SCHEMA_VERSION 2.0 -> 2.1 (additive); new Calendar* models.
- npm client: listCalendarEvents / previewCalendarEvent / createCalendarEvent /
  respondToCalendarEvent + types; SCHEMA_VERSION 2.1.
- Fail loud: missing calendar.events scope -> 403 + reconnect CTA; ambiguous
  / zero connected accounts -> 400 / 503.
- Docs synced: npm README/SPEC/SKILL/CHANGELOG, python specification.html +
  /spec generator, docs/guides/email.mdx.
- Tests: REST contract + conformance (confirmation-gate, payload-binding,
  replay) and npm client tests.
The Agent UI lost archive and phishing-quarantine in the #1653 in-process
rip-out — they ran only in the agent loop, never on the package REST contract.
This restores them through the package: POST /v1/email/{archive,quarantine} and
their unarchive/unquarantine reversals, plus POST /v1/email/confirm to mint the
gate token.

Both mutating actions are confirmation-token-gated exactly like /send (the gate
fires first — a missing/invalid token returns 403 before any backend call), and
both are reversible inside the 30s undo window (the reversal endpoints are
ungated; they restore, never destroy). Archive returns a batch_id undo handle
and the post_archive_id so Outlook undo survives the folder-move id change
(#1738). Quarantine is Gmail-only — an Outlook mailbox is refused with 400
rather than shipping a folder move its label-based undo cannot reverse.

Backend ops are reused, not rewritten: archive_message_impl gains an optional
batch_id (+ surfaces post_archive_id) and quarantine_phishing_impl gains an
optional mailbox, both additive. SCHEMA_VERSION 2.0 -> 2.1 (additive; triage
shape unchanged). npm client gets confirmAction/archive/unarchive/quarantine/
unquarantine; OpenAPI, specification.html, spec_html, README/SPEC/SKILL/
CHANGELOG and the email guide are all updated in step.
…arantine

Review follow-up on #1779. The capability matrix in specification.html wrongly
listed archive/quarantine as MCP-exposed — MCPEmailServer only surfaces
triage_email/draft_reply/send_email, so the matrix now shows MCP "—" with the
agent-loop tools in the Agent column, and the intro sentence says REST (not MCP)
adds capabilities 8/9.

Also corrected stale "2.0" references now that SCHEMA_VERSION is 2.1: the
VersionCheckOptions doc default in lifecycle.ts, the version-check test
description (2.0 is accepted because it shares MAJOR 2 with the 2.1 default), and
a "Schema 2.1" line in the types.ts header documenting the additive bump.
… 2.1 (#1780)

Second review pass. The static spec's own header/footer still claimed "schema
1.0 implemented · 2.0 proposed" / "documents contract schema 1.0", which
contradicted the schema-2.1 calendar endpoint reference added in the first
commit. Corrected the authoritative version markers to "schema 2.1
implemented", tied the deliberate RSVP-not-gated decision into capability card
12 and SPEC.md, and made the capability→surface mapping precise (calendar
detect/conflicts stay agent-only; only view/create/respond are on REST).

Also typed the calendar connector-error helper `-> NoReturn` so the
always-raises contract the handlers depend on is explicit (a future
non-raising branch can't silently become an UnboundLocalError → opaque 500).
…scope-403 (#1780)

Third review pass. Closed a real test gap tied to issue #1780's acceptance
criterion AC2 ("Missing calendar.events scope still fails loud with the
reconnect CTA"): no test exercised the calendar connector-error → HTTP-status
ladder. Added two cases against injected backends — a ScopeMismatchError on
the view path asserts 403 + the reconnect CTA, and a ConfigurationError on the
gated create path asserts 503 (after the confirmation gate passes).

Also refreshed the npm version-check test name/comment that still said
"schema 2.0 default" — it now documents that a 2.0 sidecar is accepted under
the 2.1 default (same-MAJOR backward compatibility), which is what it proves.
# Conflicts:
#	hub/agents/npm/agent-email/CHANGELOG.md
#	hub/agents/npm/agent-email/README.md
#	hub/agents/npm/agent-email/SKILL.md
#	hub/agents/npm/agent-email/SPEC.md
#	hub/agents/npm/agent-email/src/client.ts
#	hub/agents/npm/agent-email/src/types.ts
#	hub/agents/python/email/gaia_agent_email/api_routes.py
#	hub/agents/python/email/gaia_agent_email/contract.py
#	hub/agents/python/email/gaia_agent_email/spec_html.py
#	hub/agents/python/email/openapi.email.json
#	hub/agents/python/email/specification.html
#	hub/agents/python/email/tests/test_rest_contract.py
# Conflicts:
#	hub/agents/npm/agent-email/CHANGELOG.md
#	hub/agents/npm/agent-email/README.md
#	hub/agents/npm/agent-email/SKILL.md
#	hub/agents/npm/agent-email/SPEC.md
#	hub/agents/npm/agent-email/src/client.ts
#	hub/agents/npm/agent-email/src/types.ts
#	hub/agents/npm/agent-email/test/client.test.ts
#	hub/agents/npm/agent-email/test/version-check.test.ts
#	hub/agents/python/email/gaia_agent_email/api_routes.py
#	hub/agents/python/email/gaia_agent_email/contract.py
#	hub/agents/python/email/gaia_agent_email/spec_html.py
#	hub/agents/python/email/specification.html
#	hub/agents/python/email/tests/test_rest_contract.py
#	tests/test_ui_email_router.py
#	tests/unit/agents/email/test_contract_schema.py
# Conflicts:
#	hub/agents/npm/agent-email/CHANGELOG.md
#	hub/agents/npm/agent-email/README.md
#	hub/agents/npm/agent-email/SKILL.md
#	hub/agents/npm/agent-email/SPEC.md
#	hub/agents/npm/agent-email/src/client.ts
#	hub/agents/npm/agent-email/src/types.ts
#	hub/agents/npm/agent-email/test/client.test.ts
#	hub/agents/python/email/gaia_agent_email/api_routes.py
#	hub/agents/python/email/gaia_agent_email/contract.py
#	hub/agents/python/email/gaia_agent_email/spec_html.py
#	hub/agents/python/email/openapi.email.json
#	hub/agents/python/email/specification.html
#	hub/agents/python/email/tests/test_rest_contract.py
…nce after 2.1 merge

The four-way merge of the schema-2.1 REST surfaces (#1778 #1779 #1780 #1781)
silently dropped two things the per-branch tests never re-ran together:

- api_routes lost `import json`, so the calendar create-event fingerprint
  raised NameError at request time (passed import, failed the 403-gate test).
- the OpenAPI conformance suite lost #1779's archive/quarantine/confirm tests
  and never gained a #1778 pre-scan test, so test_all_documented_paths_covered
  flagged six uncovered routes.

Restores the import and the conformance coverage so every documented
/v1/email/* route is exercised.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes labels Jun 26, 2026
@kovtcharov
kovtcharov requested review from itomek and itomek-amd June 26, 2026 23:16
@kovtcharov kovtcharov self-assigned this Jun 26, 2026
@kovtcharov kovtcharov added the agent::email Email agent changes label Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve ✅

This restores the four inbox capabilities (search, pre-scan, archive/quarantine, calendar) that were lost when the in-process email agent was removed, putting each back on the REST contract so the Agent UI can drive them through the package. The schema bump to 2.1 is genuinely additive — triage shapes are untouched, so existing 2.0 clients keep working.

The bottom line: this is clean and merge-ready. Every mutating call is gated behind the same single-use confirmation-token handshake as /send (no/invalid token → 403 before any backend call), the read-only calls correctly take no token, and every error path fails loudly with an actionable message rather than silently degrading. Coverage is excellent — the gate, token-binding, fail-loud resolution, conformance-to-spec, and the Outlook-quarantine refusal are all tested on both the Python and TS sides, and the "all documented paths covered" guard now lists all 16 routes. The two latent defects the PR calls out (the missing import json and the dropped conformance tests) are real catches that only surfaced because the suites were run together.

No blocking issues. One tiny optional note below.

🔍 Technical details

Strengths

  • Confirmation-gate consistency. Archive/quarantine/calendar-create all consume the token before resolving the backend (api_routes.py:1497, 1592, 1683, 1885), matching the existing /send ordering exactly — so the "token consumed even if backend resolution later 503s" behavior is intentional and uniform, not an oversight. Fingerprints bind the token to the exact payload (_action_fingerprint, _calendar_event_fingerprint), giving the same anti-bait-and-switch property /send gets from _payload_fingerprint.
  • Fail-loud everywhere. The 0-mailbox → 503 / 2+-mailbox → 400 resolution in get_search_backend / get_prescan_backend / get_calendar_backend / _resolve_mutate_backend never silently picks an inbox, and _raise_calendar_connector_http (typed NoReturn) cleanly maps connector errors to 403/503/502 — fully in line with the no-silent-fallback rule.
  • No logic duplicated. Search reuses _format_message_for_llm, pre-scan reuses pre_scan_inbox_impl, actions reuse the agent's archive_message_impl / quarantine_phishing_impl and the shared email_actions undo log — so the REST surface can't drift from the in-loop behavior.
  • Docs/types kept in sync. contract.py, types.ts, openapi.email.json, specification.html, README/SPEC/SKILL/CHANGELOG, and docs/guides/email.mdx are all updated together — exactly the bundled-doc discipline CLAUDE.md asks for. The Gmail-only quarantine constraint is documented on the endpoint, the model, and the guide.

🟢 Minor (optional)

  • CalendarCreateEventRequest.end is documented as "Event end (after start)" (contract.py:487, mirrored in types.ts), but there's no validator enforcing end > start — it's delegated to the backend (caught as ValueError → 400 at api_routes.py:1007). That's a reasonable fail-loud boundary, but a model_validator comparing the two endpoints when both are timed would reject an inverted window with a clearer contract-level 422 and is independent of backend behavior. Purely optional; the existing handling is acceptable.

Adds an agent::email rule to the PR auto-labeler so any change under
hub/agents/python/email, hub/agents/npm/agent-email, or the email guide
gets the label without a manual edit.
@github-actions github-actions Bot added the devops DevOps/infrastructure changes label Jun 26, 2026
Extends the email rule to the whole hub: one agent::<id> label per packaged
agent under hub/agents/python/<id> (+ the email npm client + each agent's
docs guide), with the three tutorial scaffolds grouped under agent::examples.
A PR touching a single agent's sources now gets that agent's label without a
manual edit.
Removes the code-agent / blender / jira rules that pointed at the pre-hub
src/gaia/agents/*.py paths (gone since the hub migration); their coverage is
now the agent::code / agent::blender / agent::jira rules. The standalone Jira
app (src/gaia/apps/jira) folds into agent::jira so it stays labelled. The
redundant code-agent/blender/jira labels are deleted from the repo.
The conformance test for the documented 503 is the only one that exercises
the real connected_mailbox_providers() path (no dependency override). Linux
CI runners have no system credential store, so the real keyring backend
raised ConnectorsError instead of reporting an empty mailbox state, turning
the expected 503 into a 500 and failing the Email Agent Tests workflow.
Request the in-memory keyring fixture so the empty-mailbox case resolves
deterministically on any host.
itomek-amd
itomek-amd previously approved these changes Jun 29, 2026
Reconciles the schema-2.1 REST surfaces (search, prescan, archive/quarantine,
calendar) with main's additive batch triage endpoint (#1893). Both feature sets
now coexist on the email contract: the package version is 0.3.0 and the contract
SCHEMA_VERSION is 2.1 (additive over 2.0 — no triage-shape change).

Conflict resolutions:
- contract.py: grafted main's Batch* models alongside the 2.1 models; restored
  MAX_BATCH_SIZE and added Annotated import; merged __all__.
- api_routes.py / spec_html.py / client.ts / types.ts: kept both endpoint sets,
  imports merged alphabetically.
- openapi.email.json + specification.html: regenerated/3-way-merged to carry all
  16 paths.
- Docs (README/SKILL/SPEC/CHANGELOG): merged both into a single 0.3.0 entry.
- test_batch_contract.py: the additive-version assertion now checks MAJOR==2
  (contract legitimately sits at 2.1, not 2.0) instead of the stale ==2.0.
@itomek-amd
itomek-amd added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit 7f52903 Jun 29, 2026
39 of 40 checks passed
@itomek-amd
itomek-amd deleted the feat/email-rest-contract-2.1 branch June 29, 2026 19:28
@itomek itomek mentioned this pull request Jun 30, 2026
8 of 9 tasks
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jul 2, 2026
…cess /v1/email) (amd#1910)

## Why this matters

Before this PR the Agent UI's email surface was split and the heavy
email agent ran inside the UI process: the `/v1/email/*` REST routes
were served by an **in-process mount of the email wheel by default**
(only by the sidecar when `GAIA_EMAIL_AGENT_MODE` was set), and the
in-app email chat agent (`agent_type=email`) loaded live Gmail/Outlook
backends, an action DB, and a memory store **into the UI backend**.
After this PR the out-of-process **sidecar is the sole, default backend
for both surfaces**. The core UI backend no longer imports the email
wheel — it stays lightweight, crash-isolated, and **dogfoods the exact
schema-2.1 product third-party integrators consume**.

This is the deferred cutover from epic amd#1767, on the foundations from
amd#1884 and the now-complete REST 2.1 contract from amd#1883 (design: amd#1882).

### What changed (three threads a reviewer should evaluate
independently)

- **Proxy ungated → full contract.** `EmailSidecarProxy` now forwards
the full schema-2.1 surface (prescan, search, archive/unarchive,
quarantine/unquarantine, confirm, batch triage, calendar
view/preview/create/respond) returning the sidecar's envelopes
unchanged. The UI router exposes the full contract, so removing the
in-process mount does **not** shrink the external `/v1/email` surface.
- **Sidecar is the sole + default `/v1/email` surface.** The in-process
`gaia_agent_email.api_routes` mount is removed from the UI server; unset
`GAIA_EMAIL_AGENT_MODE` now defaults to **user mode** (frozen binary,
lazy-fetched + SHA-verified). No in-process fallback — a
missing/unpublished binary fails loudly with a remedy. (The separate
`gaia api` / `openai_server` mount is intentionally out of scope.)
- **`agent_type=email` flipped to the sidecar.** New `EmailProxyAgent`
keeps the local-LLM tool loop in the UI backend, but every tool is a
thin HTTP call to the sidecar. `pre_scan_inbox` returns the
**identical** `email_pre_scan` envelope so the triage card renders
unchanged. Its tool surface is the subset the REST contract serves today
(inbox pre-scan, search, calendar view, archive + undo); the unmapped
in-process tools
(labels/stars/move/trash/delete/summarize/profile/preferences/forward/send)
are not exposed in chat until their REST routes land — the agent product
still implements them, they're just not reachable over the contract yet.

## Test plan

- [x] `python -m pytest tests/unit/test_email_sidecar_*.py` — 91 pass
(proxy, router, server-wiring, manager, fetch, platform, devmode-app,
**new** proxy-agent).
- [x] `python util/lint.py --black --isort --flake8` — all pass.
- [x] Chat-path regression: `pytest
tests/unit/test_session_mail_provider.py tests/unit/test_agents_split.py
tests/unit/test_chat_preflight.py tests/unit/chat/ui/test_server.py` —
141 pass.
- [x] **End-to-end card property (no Gmail):** the proxy agent's real
`pre_scan_inbox` output, fed through the real `SSEOutputHandler`,
injects an `email_pre_scan` render payload (test
`test_pre_scan_envelope_triggers_real_sse_card_injection`).
- [x] **Live dev-mode round-trip:** spawned the dev sidecar
(`apiVersion=2.1 agentVersion=0.3.0`), drove the proxy agent's real
`pre_scan_inbox`/`search_messages` tools against live `/prescan` and
`/search`; with no mailbox connected they fail loudly with the sidecar's
verbatim "No mailbox connected…" detail (full chain: proxy agent →
shared manager → sidecar → REST → fail-loud passthrough). Clean
tree-kill on shutdown.
- [x] `create_app()` with `GAIA_EMAIL_AGENT_MODE` unset → manager mode
`user`, full contract routes mounted, no in-process mount.

To exercise locally with a connected Gmail:
```bash
uv pip install -e hub/agents/python/email
GAIA_EMAIL_AGENT_MODE=dev gaia chat --ui   # email session → "what's in my inbox" → pre-scan card via the sidecar
```

### Notes for the reviewer
- **Eval:** no `gaia eval agent` run — the change touches neither the
in-core ChatAgent prompts nor the wheel's `EmailTriageAgent`; the eval
harness targets the wheel agent (unchanged), and there is no eval path
for the new `EmailProxyAgent`. Its behavior is covered by the
integration + live tests above.
- **Reduced chat tool surface** is a deliberate, maintainer-approved
product decision (sidecar-mapped tools only) — backwards compat for
*other* Agent-UI agents (chat/code/browser/…) is untouched.
- **Follow-up:** the registry gate still requires the email wheel for
the `email` id to resolve, so a no-wheel install can use the REST
surface but not the chat agent. Decoupling that (registering proxy-agent
metadata without the wheel) is a separate change.
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jul 2, 2026
…amd#1604) (amd#1920)

Mailbox search became a first-class REST capability in amd#1883 (`POST
/v1/email/search`, schema 2.1) — but nothing proved a query actually
*filters*. The existing REST tests inject a stub that ignores the query,
so a query-handling regression, or drift between the REST route and the
agent's in-loop `search_messages` tool it restores, would pass CI
silently. This PR closes that verification gap with tests against the
real `FakeGmailBackend` (mbox store + Gmail-query matcher) and frames
"find past mail" as a capability in the email guide — the last unmet
acceptance criteria of amd#1604/amd#1781.

- **Unit** — keyword / `from:` / `subject:` queries return exactly the
expected message ids; each hit carries the documented metadata (id,
from, subject, date, snippet) and never a message body.
- **Parity** — the REST path returns the same ids, order, and header
metadata as `search_messages_impl` (the in-agent tool), so the two
surfaces can't drift unnoticed.
- **Guide** — "What it does" now names search (chat tool + REST route);
endpoint spec, OpenAPI, and npm docs already cover it since amd#1883, so no
contract or version change here.

Closes amd#1604, closes amd#1781.

## Test plan

- [x] `python -m pytest tests/unit/agents/email/test_rest_search.py` —
12 passed
- [x] `python -m pytest tests/unit/agents/email/
hub/agents/python/email/tests/ tests/test_email_openapi_conformance.py`
— 476 + 151 passed, no regressions
- [x] `python util/lint.py --black --isort` — clean
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Aug 17, 2026
Release notes had grown into long blocks of prose with a marketing-toned
paragraph on top. They now generate as short bullets grouped by section,
with a word cap on the narrative part. Nothing informational is lost —
every PR link, contributor credit, and changelog entry is preserved; the
prose around them is cut.

Two generators write `docs/releases/<tag>.mdx` and they had drifted
apart. The `gaia-release` skill told the model GAIA's notes "read dry"
and to make them "engaging"; the `release-notes` job in `claude.yml`
asked for "comprehensive" notes with an `## Overview` paragraph and
emoji headings. Fixing one alone would have been overwritten by the
other on the next tag, so both now share one spec.

Closes amd#2961

## What it looks like now

Regenerated from the last two releases — same facts, same PR numbers,
new template. Narrative words (the capped part, excluding
bug-fix/contributor/changelog lists):

| Release | Published | Regenerated | Cap |
|---|---|---|---|
| v0.22.0 (minor) | 1705 | **538** | 600 |
| v0.23.0 (minor) | 1119 | **280** | 600 |

<details>
<summary>Example 1 — v0.23.0 regenerated</summary>

```markdown
---
title: "v0.23.0"
description: "Install and run agents from the terminal, add capabilities as skills, and connect a Microsoft account without a secret."
---

# GAIA v0.23.0 Release Notes

Agents are now installable from the terminal, and the confirmation gate that pauses an agent before a consequential action works everywhere, not just in the Agent UI.

## Breaking Changes

- **`GAIA_MICROSOFT_TENANT` is gone** — the Microsoft connector split into Personal and Work/School, each with its own tenant. Drop the variable and pick the matching connector. (PR [amd#2729](amd#2729))

## What's New

- **Install and run agents from the terminal** — `gaia hub list`, `gaia hub install <agent> --trust`, `gaia hub uninstall <agent>`. `--trust` is required for an unverified agent. (PRs [amd#2484](amd#2484), [amd#2530](amd#2530), [amd#2708](amd#2708))
- **Every agent asks before it acts** — the confirmation gate for sending mail, writing files, and running commands now fires from the terminal, the local API, and MCP tool calls, not only the Agent UI. Set `GAIA_AUTO_APPROVE_TOOLS=1` to opt out. (PRs [amd#2475](amd#2475), [amd#2544](amd#2544), [amd#2846](amd#2846), [amd#2854](amd#2854))
- **Safer by default** — the MCP bridge binds to localhost and enforces `--auth-token`; the local API refuses credentialed cross-origin requests from non-allow-listed sites; MCP servers launch without a shell; agents cannot write to `~/.gaia` or pass crafted SQL to the database agent. (PRs [amd#2246](amd#2246), [amd#2238](amd#2238), [amd#2344](amd#2344), [amd#2844](amd#2844), [amd#2847](amd#2847), [amd#2860](amd#2860))
- **Add capabilities as skills** — `gaia skill create|import|list|info` gives an agent a new capability from a folder and a manifest. Skills are signed with trust tiers, audited before publish, and opt-in. (PRs [amd#2669](amd#2669), [amd#2692](amd#2692), [amd#2702](amd#2702), [amd#2693](amd#2693))
- **Connect a Microsoft account without a secret** — Personal and Work/School are separate connectors with device-code sign-in. (PRs [amd#2718](amd#2718), [amd#2364](amd#2364))
- **Lemonade Server 11.5.0.**

## Bug Fixes

- **Triage paginates large inboxes and reports truncation** (PR [amd#2646](amd#2646)) — mail past a hidden limit is no longer dropped without saying so.
- **Thread messages come back sorted and numbered** (PR [amd#2570](amd#2570)) — "reply to 3" hits the message shown at position 3.
- **The inbox pre-scan reports uncertainty as uncertainty** (PR [amd#2587](amd#2587)).
- **An email conversation survives its turns** (PR [amd#2837](amd#2837)) — a follow-up keeps session context.
- **A bare reconnect keeps existing grants** (PR [amd#2733](amd#2733)).
- **Restore from Trash anytime** (PR [amd#2542](amd#2542)) — no time window on undo.
- **Sender priority no longer overrides content classification** (PR [amd#2774](amd#2774)).
- **The agent survives an OpenMP double-init** (PR [amd#2508](amd#2508)).
- **Large tool results truncate to valid JSON** (PR [amd#2645](amd#2645)).
- **A missing model surfaces as a real 404** (PR [amd#2245](amd#2245)).
- **GPU is detected on all platforms and `default_device` is honoured** (PR [amd#2244](amd#2244)).
- **A sidecar that is alive but not serving is detected** (PR [amd#2707](amd#2707)).
- **The model-slot lease is held across inference** (PR [amd#2394](amd#2394)) — a second agent can't evict the model mid-generation.
- **A browser that never launched is surfaced** (PR [amd#2507](amd#2507)).
- **Stop aborts in-flight streaming** (PR [amd#2166](amd#2166)).

## Known Issues

- **The email agent is beta and CLI-first** — treat its output as a draft to review.
- **A full inbox triage can time out on larger mailboxes.**
- **Email autonomy is experimental** and not wired up in the packaged sidecar.

## Contributors

- [@handle](https://github.com/handle) — <contribution> (PR [#NNN](https://github.com/amd/gaia/pull/NNN))
  <!-- generated from the commit log; v0.23.0's list is unchanged from the published notes -->


## Full Changelog

**N commits** since v0.22.0:

- `<sha>` — <subject>

Full Changelog: [v0.22.0...v0.23.0](amd/gaia@v0.22.0...v0.23.0)
```
</details>

<details>
<summary>Example 2 — v0.22.0 regenerated (the largest recent
release)</summary>

```markdown
---
title: "v0.22.0"
description: "The email agent tracks follow-ups and action items, drafts in your voice, and runs as its own process. Plus a cron scheduler and Word document support in RAG."
---

# GAIA v0.22.0 Release Notes

A large release built around the email agent, which now tracks what you're waiting on instead of forgetting it after triage.

## Breaking Changes

- **Triage returns a reply scaffold, not an empty draft** — `POST /v1/email/triage` and `/triage/batch` now return a `DraftScaffold` without `body`. Code reading `result.draft.body` gets a missing key instead of `""`; use `POST /v1/email/draft` for composed prose. (PR [amd#1984](amd#1984))
- **RoutingAgent and DocumentQAAgent moved to standalone packages** — install `gaia-agent-routing` and `gaia-agent-docqa`. The old imports fail; there is no deprecation shim. (PR [amd#1455](amd#1455))

## What's New

- **An inbox agent that keeps track** — `gaia email` scans Sent folders across every connected mailbox and flags threads still waiting on a reply past a window you set (default 3 days). Detection only; it never nudges anyone for you. (PRs [amd#1922](amd#1922), [amd#1917](amd#1917), [amd#1919](amd#1919), [amd#1918](amd#1918))
- **Drafts in your own voice** — the agent derives greeting, sign-off, length, and formality from your Sent history and composes against that. Only the derived characteristics are stored, never old mail content. (PR [amd#1925](amd#1925))
- **Attachments work end to end** — triage surfaces each attachment's name, type, and size, and drafting and sending accept real attachments as Gmail multipart MIME or Outlook Graph attachments. (PRs [amd#1921](amd#1921), [amd#1883](amd#1883))
- **Email runs as its own process in the Agent UI (beta)** — install it from the Agent Hub panel and the UI talks to it over HTTP, instead of loading the email stack into the UI process. (PRs [amd#1884](amd#1884), [amd#1910](amd#1910), [amd#2100](amd#2100), [amd#2101](amd#2101), [amd#2105](amd#2105))
- **Run prompts on a cron from the terminal** — `gaia schedule add --name digest --cron "0 9 * * *" --prompt "summarize my inbox" --sink stdout`, then `gaia schedule daemon`. Schedules live in a hand-editable `~/.gaia/schedules.toml`; sinks are `stdout`, `file:<path>`, `notification`, or `telegram`. (PR [amd#1371](amd#1371))
- **Agents learn from work they repeat** — after enough successes on the same shape of goal, an agent distills the tool sequence into a reusable procedure and recalls it next time. Runs inside the existing memory pass; nothing to install. (PR [amd#1794](amd#1794))
- **Pick your model once** — `gaia config set default_model <id>` persists across `gaia chat`, `gaia llm`, and `gaia prompt`. An explicit `--model` still wins for a one-off. (PR [amd#1863](amd#1863))
- **RAG reads Word documents** — `.docx` files index like PDF and PPTX, including table cells, nested tables, content controls, hyperlinks, and textboxes, so filled-in form values get indexed. (PR [amd#1866](amd#1866))
- **A new default embedder** — the previous default cannot be loaded by current llama.cpp builds, which broke indexing, code search, and memory embedding on an up-to-date Lemonade. The default is now EmbeddingGemma 300M at the same 768 dimensions. (PRs [amd#1952](amd#1952), [amd#1761](amd#1761), [amd#1748](amd#1748))
- **The Agent Hub shows what an agent is worth** — an agent's page now carries its eval scorecard with a score badge and a code-derived capability matrix. (PRs [amd#1985](amd#1985), [amd#2020](amd#2020), [amd#2066](amd#2066))
- **Lemonade Server 10.10.0** — adds an audio-generation endpoint, lets Windows reuse system ROCm, and inhibits suspend during inference. Two upstream breaking changes are Linux-specific. (PR [amd#1969](amd#1969))

## Bug Fixes

- **`gaia init` said a working Lemonade wasn't installed** (PR [amd#1940](amd#1940)) — modern Lemonade (10.7+) dropped the `lemonade-server` CLI that GAIA probed for.
- **Installing the email agent from the Hub failed on every platform** (PR [amd#2086](amd#2086)).
- **Bulk triage broke on any real inbox** (PR [amd#2088](amd#2088)) — 60 emails overflowed the 16K context window; the result envelope is now condensed.
- **RAG silently indexed nothing** (PR [amd#1979](amd#1979)) — a failed `sentence-transformers` import made every indexing call a no-op.
- **Email bodies were truncated at 4,000 characters with no override** (PR [amd#2036](amd#2036)) — MFA codes and precise replies lost content past the cutoff.
- **Long threads overflowed the model's context** (PR [amd#2076](amd#2076)).
- **A disabled device was treated as usable** (PR [amd#2081](amd#2081)) — a device reporting `available: false`, such as an unpowered NPU, was misread as ready.
- **A newly connected mailbox was skipped** (PR [amd#1808](amd#1808)) — mailboxes connected mid-session were not picked up.
- **JSON with a `}` inside a string was dropped** (PR [amd#1824](amd#1824)).
- **Outlook users were told to reconnect Google** (PR [amd#1757](amd#1757)) — `AGENT_NOT_GRANTED` named the wrong provider.
- **The Agent UI hard-crashed on a recoverable GPU crash** (PR [amd#1799](amd#1799)) — it now falls back to software rendering.
- **A user-edited memory could be silently downgraded and then wiped** (PR [amd#1958](amd#1958)).
- **The builder agent ignored an agent name you had already given** (PR [amd#1981](amd#1981)).
- **The landing and hub pages scrolled sideways on phones** (PR [amd#1959](amd#1959)).

## Known Issues

- **Inbox pre-scan needs a single mailbox for now** — with both Gmail and Outlook connected, an Agent UI pre-scan errors. Disconnect one in Settings → Connectors; triage itself still spans every mailbox. ([amd#2127](amd#2127))
- **Spam detection under-flags over the REST API** — `/v1/email/triage` uses a narrow sender check rather than the model's reading. The agent's own inbox scanning is unaffected. ([amd#2124](amd#2124))
- **The email agent is beta** — treat its output as a draft to review. It never sends without your confirmation.

## Contributors

- [@alexey-tyurin](https://github.com/alexey-tyurin) — skill auto-synthesis / procedural memory (PR [amd#1794](amd#1794))
- [@TravisHaa](https://github.com/TravisHaa) — the `gaia schedule` CLI and cron-based dispatch (PR [amd#1371](amd#1371))
- [@Rohithmatham12](https://github.com/Rohithmatham12) — refresh resolved email backends before multi-mailbox triage (PR [amd#1808](amd#1808))
- [@Osamaali313](https://github.com/Osamaali313) — fix `extract_json_from_text` dropping JSON containing `}` (PR [amd#1824](amd#1824))
- [@eeee2345](https://github.com/eeee2345) — offline model-endpoint guard-proxy integration guide (PR [amd#1809](amd#1809))
- [@somo9909](https://github.com/somo9909) — prerequisites section for the memory guide (PR [amd#1665](amd#1665))

## Full Changelog

**N commits** since v0.21.2:

- `<sha>` — <subject>

Full Changelog: [v0.21.2...v0.22.0](amd/gaia@v0.21.2...v0.22.0)
```
</details>

<details>
<summary>What changed in the templates</summary>

- The narrative overview paragraph and the `**Why upgrade:**` block are
gone — the latter restated `What's New` verbatim.
- `What's New` entries are bullets, not `###` prose blocks.
- Tone guidance is no longer restated in the skill; it points at
CLAUDE.md § How You Communicate.
- The skill's embedded example now shows the old prose block as **bad**
and the bullet form as **good**.
- Emoji removed from the CI prompt (it asked for 🚀 / 🎯 / 🐛 headings
against the skill's own no-emoji rule).
- Both generators now emit the same sections in the same order, so the
file's shape no longer depends on which one ran.
- The cap excludes `Bug Fixes` / `Known Issues` / `Contributors` / `Full
Changelog`. Those are reference lists sized by how many fixes shipped —
capping them would hide work. This was caught by regenerating v0.22.0,
which overflowed a whole-file cap purely on its 14 bug-fix bullets.

**Follow-up, not in this PR:** the cap lives in prompt text, so it is
advisory. Making it a hard check in `util/validate_release_notes.py`
would enforce it in CI.
</details>

## Test plan

- [ ] `python util/validate_release_notes.py <regenerated sample> --tag
v0.23.0` exits 0 — passes unmodified, no validator changes in this PR
- [ ] `awk '/^## (Bug Fixes|Known Issues|Contributors|Full
Changelog)/{exit} {print}' <file> | wc -w` is under 350 (patch) / 600
(minor-major)
- [ ] `.github/workflows/claude.yml` parses as valid YAML and its
release-notes prompt contains no emoji
- [ ] `.claude/skills/gaia-release/SKILL.md` is under 500 lines (498)
- [ ] Both generators list the same sections in the same order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent::email Email agent changes devops DevOps/infrastructure changes documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants