Skip to content

docs(claude): sync agent/tool tables with code; fix convention checker + add missing agent tests - #1340

Merged
kovtcharov-amd merged 6 commits into
mainfrom
claudia/task-28958bcc
Jun 3, 2026
Merged

kovtcharov-amd merged 6 commits into
mainfrom
claudia/task-28958bcc

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

GAIA's onboarding doc had quietly drifted from the code: seven shipped agents (DocumentQA, Analyst, Browser, FileIO, EmailTriage, ConnectorsDemo) and four tool mixins were missing from the CLAUDE.md tables, browse/analyze/email weren't in the CLI list, and one agent class was named wrong — so anyone (human or AI) onboarding from CLAUDE.md got a stale map of the codebase. This syncs the tables to reality, fixes the agent-convention checker that was crying wolf, and closes the test-coverage holes that hid behind it.

The convention checker (check_agent_conventions.py) was emitting 12 false-positive warnings: it didn't recognize the modern _snapshot_tools() isolation pattern (so it flagged correctly-isolated agents as registry leaks) and discovered tests with a non-recursive glob (so it missed every test under tests/unit/, tests/integration/, tests/mcp/). With both fixed, the checker drops from 25 → 9 warnings, and the 9 that remain are accurate — genuine tool-registry leak debt in non-isolating agents.

Four of those agents (Analyst, Docker, DocumentQA, FileIO) also had zero test coverage; this adds real unit suites for them (20 tests). The remaining 9 leak warnings are deliberately left for follow-up because fixing them changes each agent's tool schema and requires gaia eval agent runs per the repo's eval policy.

Test plan

  • python util/check_agent_conventions.py → 0 error(s), 9 warning(s) (all genuine leak debt)
  • python -m pytest tests/unit/agents/test_{analyst,docker,docqa,fileio}_agent.py -q → 20 passed
  • python util/check_doc_code.py and python util/check_doc_versions.py → pass
  • python util/lint.py --black --isort → pass

Ovtcharov added 3 commits June 1, 2026 12:18
…taller/

The bash counterparts to the PowerShell scripts fixed in #1326 had the
identical off-by-one bug: both climbed one parent directory too few from
installer/scripts/, so $REPO_ROOT / $PROJECT_ROOT pointed at installer/
instead of the repo root. Downstream $WEBUI_DIR / $ELECTRON_DIR then
resolved to the non-existent installer/src/gaia/apps/webui, breaking
start-agent-ui.sh --frontend-only and build-ui-installer.sh on Linux/macOS.

Both scripts live at installer/scripts/, so the correct traversal is
$SCRIPT_DIR/../.. (two levels up to repo root).
…r false positives

The Agent Implementations and KNOWN_TOOLS tables in CLAUDE.md had drifted
from the code: seven agents (DocumentQA, Analyst, Browser, FileIO,
EmailTriage, ConnectorsDemo) and four tool mixins (code_index, filesystem,
scratchpad, browser) were undocumented, the summarize class was named
wrong (SummarizerAgent), and browse/analyze/email CLI commands were missing.

check_agent_conventions.py produced 12 false-positive warnings: it didn't
recognize the modern _snapshot_tools() isolation pattern (treating snapshot-
isolated agents as registry leaks) and discovered tests with a non-recursive
glob (missing every test under tests/unit/, tests/integration/, tests/mcp/).
Both are fixed, leaving only accurate warnings.
…AAgent, FileIOAgent

These four agents shipped without any test coverage. Each suite verifies
construction without a live Lemonade backend (skip_lemonade), the default
config, the system prompt, and tool registration. AnalystAgent isolates its
registry via clear()+_snapshot_tools() so its tool set is asserted exactly;
the other three share the process-global registry, so their own tools are
asserted as a subset.
@github-actions github-actions Bot added installer Installer changes devops DevOps/infrastructure changes tests Test changes labels Jun 1, 2026
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

A clean documentation-and-tooling PR with no blocking issues. The most impactful change is the rglob fix in the convention checker — the previous glob("test_*.py") was quietly missing every test under tests/unit/, tests/mcp/, tests/integration/, and tests/unit/agents/, meaning the soft "tests exist" check was effectively broken for the entire tests/unit/ tree. Everything else (CLAUDE.md sync, _snapshot_tools() recognition, installer path fix) follows naturally from that root problem.


Issues

🟢 Minor — _manages_registry_state: string match can hit docstrings (util/check_agent_conventions.py:85-87)

ast.unparse(cls) includes the text of all string literals in the class body, so a docstring like """Delegates to self._snapshot_tools().""" would satisfy the check even if the call is absent from the executable code. The risk is low in practice (a docstring mentioning _snapshot_tools strongly implies the real call is nearby, and a false negative would only suppress a warning), but a tighter check would inspect ast.Call nodes:

    for node in ast.walk(cls):
        if not isinstance(node, ast.Call):
            continue
        func = node.func
        if isinstance(func, ast.Attribute) and func.attr in ("_snapshot_tools",):
            return True
        if isinstance(func, ast.Name) and func.id == "_snapshot_tools":
            return True
        if (
            isinstance(func, ast.Attribute)
            and func.attr == "_instance_tools"
        ):
            return True

(Or keep the unparse approach and add a comment noting the docstring edge case — either is fine.)

🟢 Nit — DockerAgent test: no resource cleanup (tests/unit/agents/test_docker_agent.py:232-263)

test_analyst_agent.py correctly wraps each agent in try/finally: agent.close() because AnalystAgent holds a SQLite handle. The other three test files (DockerAgent, DocumentQAAgent, FileIOAgent) call _make() in test_* methods without cleanup. DockerAgent is an MCPAgent and skip_lemonade=True prevents any real connection, so the omission is probably safe today — but it establishes a pattern other contributors may copy for agents that do hold resources. A setUp/tearDown pair or a single addCleanup call would make the intent explicit:

    def setUp(self):
        self.agent = self._make()

    def tearDown(self):
        self.agent.close()

    def test_constructs_without_backend(self):
        self.assertIsNotNone(self.agent)

    def test_default_model_is_coding_model(self):
        self.assertEqual(self.agent.model_id, "Qwen3.5-35B-A3B-GGUF")

    def test_system_prompt_is_docker_focused(self):
        prompt = self.agent._get_system_prompt()
        self.assertIsInstance(prompt, str)
        self.assertIn("Docker", prompt)
        self.assertIn("Dockerfile", prompt)

    def test_registers_docker_tools(self):
        tools = set(self.agent._tools_registry)
        for expected in (
            "analyze_directory",
            "save_dockerfile",
            "build_image",
            "run_container",
        ):
            self.assertIn(expected, tools)

Same pattern applies to test_docqa_agent.py and test_fileio_agent.py.

🟢 Nit — PR description warning count is off by 1 in CI environment

The description claims "checker drops from 25 → 9 warnings." In this environment (missing dotenv, CLAUDE.md table not yet patched on disk) the actual output is 12 warnings — 9 genuine isolation-debt warnings + 2 "not mentioned in CLAUDE.md" warnings (which this PR's CLAUDE.md changes fix) + 1 KNOWN_TOOLS import failure from missing dotenv. All three extra warnings are environment artifacts, so the "9 genuine warnings" claim is accurate for a real GAIA install, but the test plan step (→ 0 error(s), 9 warning(s)) may surprise someone running check_agent_conventions.py in CI without dotenv installed. Not a blocker; just worth knowing.


Strengths

  • rglob fix eliminates a silent blind spot. The old glob("test_*.py") against tests/ top-level was structurally unable to find anything in tests/unit/agents/, tests/mcp/, or tests/integration/. Every agent added in the last several releases was incorrectly getting a "no tests found" warning. One-line fix, high leverage.

  • Test isolation in test_analyst_agent.py is exactly right. test_isolated_tool_set_is_scratchpad_only asserts the full tool set with assertEqual rather than a subset check — the right choice for an agent that clears the global registry. The try/finally: agent.close() pattern is correct for an agent that holds a SQLite handle, and the temp-path fixture avoids touching the user's home dir.

  • All new CLAUDE.md entries verified against code. New tool mixins (code_index, filesystem, scratchpad, browser) confirmed present in src/gaia/agents/registry.py. gaia browse, gaia analyze, and gaia email confirmed in cli.py. ChatAgent default model updated to Gemma-4-E4B matches DEFAULT_MODEL_NAME = "Gemma-4-E4B-it-GGUF" in lemonade_client.py:119. SummarizeAgent → SummarizerAgent rename matches class SummarizerAgent in agents/summarize/agent.py:115.


Verdict

Approve. No blocking issues. The two nits (docstring false-match risk, missing teardown in three test classes) are worth applying but don't affect correctness today. The CLAUDE.md sync and convention-checker fixes are accurate and well-scoped.

…env key

The eval guidance told contributors to check ANTHROPIC_API_KEY first and
treat an empty value as 'no access', then ask the user to export a key.
That's backwards: in a Claude Code session, Claude access comes from the
subscription, and the env var is normally unset. Reframe the check order —
confirm subscription auth first, treat ANTHROPIC_API_KEY as the eval-judge
fallback (src/gaia/eval/claude.py reads it directly), and only ask for the
key when an eval subprocess actually errors without it.
@kovtcharov-amd kovtcharov-amd self-assigned this Jun 1, 2026
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Clean maintenance PR — syncs CLAUDE.md to reality, fixes two real installer bugs, tightens the convention checker, and adds 20 unit tests for agents that previously had zero coverage. No blocking issues.

Summary

The installer path fix ($SCRIPT_DIR/../..) is the most concretely impactful change: the scripts live in installer/scripts/ so the old single-level .. resolved to installer/ instead of the repo root, breaking build-ui-installer.sh and start-agent-ui.sh for any user running them directly from the installer directory. The convention checker fix (adding rglob, recognising _snapshot_tools) eliminates 16 false positives that were masking real signal. The new tests are well-structured and match the patterns of existing agent tests in this directory.

Issues Found

🟢 Minor — assertTrue on a path is a weak assertion (test_analyst_agent.py:176)

self.assertTrue(cfg.scratchpad_db_path) passes for any truthy value — an empty string would fail, but 0, False, or a non-path object would also pass. Prefer asserting the type and non-emptiness:

        self.assertIsInstance(cfg.scratchpad_db_path, str)
        self.assertTrue(cfg.scratchpad_db_path)

🟢 Minor — ast.unparse() text scan for _snapshot_tools / _instance_tools includes string literals (util/check_agent_conventions.py:85-86)

ast.unparse(cls) produces a source-like representation that includes the text of string literals and docstrings. A docstring mentioning _snapshot_tools would satisfy the check even if no code calls it. In practice this is extremely unlikely in GAIA's codebase, but an ast.walk over ast.Name nodes would be tighter. Low severity for an internal CI linter — noting it for awareness rather than blocking.

Strengths

  • Installer bug fix is correct and clearly verified: installer/scripts/ is two levels below the repo root, so ../.. is right. The old single-step .. silently resolved to installer/ and would have broken WEBUI_DIR / ELECTRON_DIR resolution for any user running the scripts directly.
  • Test cleanup pattern is consistent with the agents' actual resource models: AnalystAgent.close() exists (line 89 of src/gaia/agents/analyst/agent.py) and is correctly called in try/finally. DockerAgent, DocumentQAAgent, and FileIOAgent have no close() method, so skipping it in their tests isn't an oversight — the omission is accurate, not lazy.
  • Convention checker warning message is now actionable: the updated message (call self._snapshot_tools() (preferred) or mutate _TOOL_REGISTRY) tells the author exactly how to fix the issue, versus the old message which only described the symptom.

Verdict

Approve — the two nits above are cosmetic and don't affect correctness. The installer fix and checker improvements are solid.

test_independent_jobs_run_concurrently asserted elapsed < 0.4s, but each
0.2s job carries ~0.2s of dispatch/thread-pool overhead, so concurrent
wall time lands just over 0.4s on slower runners (the macOS smoke lane).
The jobs were genuinely parallel (total ~0.4s vs ~0.8s sequential); only
the threshold was wrong. Assert against the 0.6s midpoint instead.
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Four well-scoped fixes land cleanly: the installer path bug, CLAUDE.md doc sync, convention-checker improvements, and unit-test gaps for four previously uncovered agents. The only issue worth flagging is a resource-cleanup inconsistency across three of the four new test files.


Summary

The diff does exactly what the PR description says: it fixes two genuine bugs (wrong installer repo-root path, non-recursive test glob in the convention checker), documents seven previously-undocumented agents and four tool mixins, and adds 20 real unit tests for AnalystAgent, DockerAgent, DocumentQAAgent, and FileIOAgent. The _snapshot_tools recognition fix in the checker is correct and the timing-bound relaxation in test_dispatch.py is the right call for slow CI runners. One minor gap: the AnalystAgent tests properly close agents via try/finally + agent.close(), but the three other new test files don't — inconsistent with both the AnalystAgent pattern and best practice for agents that may hold live resources.


Issues Found

🟢 Minor — Resource cleanup missing in three new test files

tests/unit/agents/test_docker_agent.py, tests/unit/agents/test_docqa_agent.py, tests/unit/agents/test_fileio_agent.py instantiate agents in _make() but never call close(). Compare with the AnalystAgent tests, which correctly do:

agent = self._make(tmp_dir)
try:
    self.assertIsNotNone(agent)
finally:
    agent.close()

DockerAgent is an MCPAgent and DocumentQAAgent constructs a RAGSDK at init — both may hold non-trivial state. Python GC will collect them eventually, but explicit cleanup avoids sporadic test-order-dependent resource warnings. Apply the AnalystAgent pattern to each _make()-based test in those three files.

Example for test_docker_agent.py:251:

    def test_constructs_without_backend(self):
        agent = self._make()
        try:
            self.assertIsNotNone(agent)
        finally:
            agent.close()

Same pattern for test_default_model_is_coding_model, test_system_prompt_is_docker_focused, and test_registers_docker_tools in TestDockerAgentInit, and for the parallel methods in TestDocumentQAAgentInit and TestFileIOAgentInit.


🟢 Minor — ast.unparse substring check is loose (util/check_agent_conventions.py:85)

class_src = ast.unparse(cls)
if "_snapshot_tools" in class_src or "_instance_tools" in class_src:
    return True

A docstring that cross-references _snapshot_tools (e.g., """calls self._snapshot_tools() — see base/agent.py""") would produce a false-positive pass. In practice GAIA agent docstrings don't do this, so the risk is theoretical. Comment-only since an AST-walk fix isn't worth the complexity here, but worth keeping in mind if the checker starts producing unexpected passes.


Strengths

  • Installer fix is airtight. installer/scripts/ sits two levels below repo root, so $SCRIPT_DIR/../.. is exactly right ($SCRIPT_DIR/.. was resolving to the installer/ directory, not the repo root). The same fix applied consistently to both scripts.
  • rglob fix closes a real blind spot. glob("test_*.py") on TESTS_DIR only saw the top-level tests/ files; rglob now finds tests under tests/unit/, tests/integration/, tests/mcp/, tests/unit/agents/ etc. — which is where all four newly-added test files live. Without this fix the checker would have still reported missing tests for the agents being covered by this very PR.
  • AnalystAgent tests set the right pattern. Snapshot-isolated tool set, temp_directory() fixture for DB path, explicit close() in finally — clean, easy to follow for contributors adding the next batch.
  • Timing bound rationale is preserved in comments. The test_dispatch.py change raises the ceiling from 0.4s to 0.6s and explains why (per-job dispatch/thread-pool overhead on slower runners), making it easy to revisit if the bound needs future tuning.

Verdict

Approve with suggestions. No blocking issues. The resource-cleanup inconsistency is the only gap worth closing before this merges; it's a straightforward pattern application from the AnalystAgent tests.

@kovtcharov-amd
kovtcharov-amd enabled auto-merge June 3, 2026 02:08
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Jun 3, 2026
Merged via the queue into main with commit 3d6dbd1 Jun 3, 2026
31 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claudia/task-28958bcc branch June 3, 2026 02:09
kovtcharov-amd pushed a commit that referenced this pull request Jun 3, 2026
Resolve conflicts in CLAUDE.md and docs/reference/cli.mdx by taking main's
versions: PRs #1337, #1340, #1364 already synced both files to the code more
recently, and the PR's stale side reintroduced removed commands (mcp
add/remove) and the broken /guides/summarize link that was failing the
internal cross-reference CI check.

Keep the PR's still-valid accuracy fixes (Gemma-4-E4B-it default in
chat/llm/emr docs, agent-ui Lemonade port 13305 + #install anchor, code
agent Python-gen still supported, telegram.mdx removal, #606 stale-note
removal).

Fix one contradiction the merge surfaced: main's CLAUDE.md and emr/cli.py
listed the EMR VLM as Qwen3-VL-4B, but agent.py and all --vlm-model
defaults are Gemma-4-E4B-it-GGUF. Aligned both with the code and emr.mdx.
kovtcharov-amd pushed a commit that referenced this pull request Jun 3, 2026
19 PRs merged to main after the v0.20.0 notes were drafted; merge main into
the release branch and update the notes to match.

- Multi-Device: note #1338 wired the selector end-to-end (it was a no-op
  after #1252 alone) and added loud runtime validation for unavailable devices.
- PowerPoint RAG: note #1366 unblocked .pptx in the Agent UI file picker
  (backend already accepted it; the frontend rejected it pre-upload).
- Activations: note #1310 widened the "Active for" panel to MCP-consuming
  agents (e.g. the chat agent), not just static REQUIRED_CONNECTORS.
- New bug fixes: RAG embedding reuse (#1306), overlapping-chat-turn 409
  (#1304), Memory/Settings mutual exclusivity (#1368).
- Tooling/CI: doc-vs-code realignment (#1298/#1337/#1340), gaia-testing
  skill (#1372), Claude CI + Codecov hardening.
- Full Changelog regenerated: 44 -> 63 commits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes installer Installer changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants