Repository navigation
feat(agents): split ChatAgent into Chat, FileIO, and DocumentQA agent… - #924
theonlychant wants to merge 3 commits into
Conversation
|
@theonlychant thanks for the contribution, please fix the listing errors so that we can get this merged in. |
I am on it right now I'll fix those real quick |
itomek
left a comment
There was a problem hiding this comment.
@theonlychant — thanks for taking on the agent split for #923. Want to help land it but the PR currently bundles enough off-scope work that I don't think it's reviewable as one unit yet. Specifics inline.
Suggested shape
- This PR: drop the 5
pylint: disable=no-memberadditions across unrelated modules, drop thedocuments.pyexception-handling change, register the new agents insrc/gaia/agents/registry.pyso they aren't dead code, replace theexcept Exception: passtool-registration blocks with specific error handling, fix therag_documentsmutable default, and beef uptest_agents_split.pyto exercise tool registration end-to-end. - Separate PR (optional): bundle the pylint disables in one place —
pylintrcignore rules or fixing the underlying type stubs. - Separate PR (required): the
documents.pyexcept HTTPException: raiseremoval with its own justification.
Dead-code check
grep -rn "ChatAgentLite\|DocumentQAAgent\|FileIOAgent" src/ tests/ only finds these classes in the new test file. No CLI subcommand, no KNOWN_TOOLS entry, no docs. Per CLAUDE.md "no half-finished work" + "every new feature must be documented", agents that no caller can reach are a hold signal. Either wire them up (registry + docs) in this PR, or sequence them after a follow-up does that wiring.
Happy to re-review once the scope is tightened.
Generated by Claude Code
There was a problem hiding this comment.
These pylint disables are unrelated to the agent split. The same disable also appears in 4 other untouched files (src/gaia/mcp/servers/agent_ui_mcp.py, src/gaia/rag/pdf_utils.py, src/gaia/utils/parsing.py, src/gaia/vlm/structured_extraction.py). Per CLAUDE.md scope-clean rule, drive-by lint suppressions across modules untouched by the stated task belong in their own PR. If they're genuine pylint false-positives, the right home is pylintrc ignore rules, not five inline disables sprinkled across unrelated modules.
Generated by Claude Code
| ) | ||
| hasher.update(chunk) | ||
| out.write(chunk) | ||
| except HTTPException: |
There was a problem hiding this comment.
This except HTTPException: raise was load-bearing — without it, the downstream except OSError branch could swallow upstream HTTPExceptions raised inside the with open(...) body (size-limit checks, etc.). Whether the removal is correct or not, it's unrelated to splitting ChatAgent and needs its own PR with a stated reason.
Generated by Claude Code
There was a problem hiding this comment.
try: ... except Exception: pass around tool registration is the silent-fallback anti-pattern called out in CLAUDE.md ("No Silent Fallbacks — Fail Loudly"). The same pattern appears in docqa/agent.py::_register_tools and fileio/agent.py::_register_tools.
If a specific mixin's optional dep is missing, catch the specific ImportError/AttributeError, log it with context, and skip that registration — don't blanket-swallow Exception around a multi-call setup. As written, a real bug in any of these register_* calls (typo, signature change, broken mixin) is invisible at runtime: the agent simply ships with no tools registered, and only the test in test_agents_split.py catches it (and that test only checks instantiation, not registration).
Generated by Claude Code
There was a problem hiding this comment.
Tests only assert instantiation, not behaviour. Per CLAUDE.md Testing Requirements, agent implementations need tests that exercise _register_tools and at least one tool dispatch.
As-is, these tests would pass even if every register_*_tools call inside _register_tools() silently failed (which the except Exception: pass blocks let happen). A regression that left the new agents with zero tools registered would still see a green test suite. Recommend: assert the agent's tool_registry (or equivalent) contains the expected tool names after instantiation.
Generated by Claude Code
- Restore except HTTPException: raise in documents.py to prevent OSError handler from swallowing upstream HTTP exceptions - Replace bare except Exception: pass in _register_tools across chat, docqa, and fileio agents with specific ImportError/ AttributeError catches that log and re-raise unexpected errors - Fix mutable default: rag_documents Optional[list[str]] = None in docqa agent dataclass - Expand test_agents_split.py to assert tool_registry contents after instantiation, not just that instantiation succeeds
Head branch was pushed to by a user without write access
## Summary The `claude-code-action` gates execution on the **actor's** repo permission. Fork-PR authors only have `read`, so the action exits with `"Actor does not have write permissions to the repository"` before ever calling Anthropic — which is why PR amd#924 from `@theonlychant` (and any future fork PR) gets a 5-second red ❌ on the Claude AI Assistant check. Setting `allowed_non_write_users: "*"` on `pr-review` and `issue-handler` bypasses that gate so external contributors get the same auto-review maintainers do, with no username allowlist to maintain. ## Threads - **`pr-review` + `issue-handler` get `allowed_non_write_users: "*"`** — these are the two jobs that take input from non-maintainers (fork-PR diffs, `@claude` mentions on issues / PR conversations). - **`pr-comment` and `release-notes` left alone** — `pr-comment` is already filtered to non-fork PRs (`head.repo.full_name == github.repository`), and `release-notes` only fires from a maintainer-owned tag push via `workflow_run`. The actor on those is always a write user, so the gate is a no-op there. - **Header comment documents the residual risk** — fork-PR diff feeds into Claude, which has `Bash` in `--allowedTools` and access to `ANTHROPIC_API_KEY` + `GITHUB_TOKEN`. Prompt injection in the diff could try to coerce Claude into running an exfiltration command. The action's built-in mitigations (subprocess secret scrubbing via `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1` auto-set when this input is non-empty, pinned bun binary, hardened PATH) reduce — but don't eliminate — the surface. Future-us reading the header knows what to tighten if a real attempt lands (swap `*` for a literal username list — verified upstream in `src/github/validation/permissions.ts` that `allowed_non_write_users` only takes literal usernames or `*`, **not** `author_association` values like `CONTRIBUTOR`). ## Test plan `pull_request_target` uses the workflow from `main`, not the PR head, so this PR can't validate itself. The verification path is post-merge: - [ ] Merge to `main` - [ ] Re-trigger PR amd#924 (push a commit to it, or close/reopen) and confirm the Claude AI Assistant check now runs to completion instead of failing in 5s with the permission error - [ ] Confirm the run log shows `⚠️ SECURITY WARNING: Bypassing write permission check for theonlychant due to allowed_non_write_users configuration` (the action emits this when the bypass takes effect) - [ ] Sanity-check that `pr-comment` (non-fork-only) still works on a maintainer's `@claude` review-comment reply
Contributes towards #923
Split the monolithic ChatAgent into three focused agents:
chat/lite_agent.py- handles conversational chat onlyfileio/agent.py- handles file reading and writingdocqa/agent.py- handles document question answeringTests added in
tests/unit/test_agents_split.py, all passing.