Skip to content

feat(agents): split ChatAgent into Chat, FileIO, and DocumentQA agent… - #924

Closed
theonlychant wants to merge 3 commits into
amd:mainfrom
theonlychant:feat/split-chat-agents
Closed

theonlychant wants to merge 3 commits into
amd:mainfrom
theonlychant:feat/split-chat-agents

Conversation

@theonlychant

@theonlychant theonlychant commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Contributes towards #923

Split the monolithic ChatAgent into three focused agents:

  • chat/lite_agent.py - handles conversational chat only
  • fileio/agent.py - handles file reading and writing
  • docqa/agent.py - handles document question answering

Tests added in tests/unit/test_agents_split.py, all passing.

itomek
itomek previously approved these changes Apr 30, 2026
@itomek

itomek commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

@theonlychant thanks for the contribution, please fix the listing errors so that we can get this merged in.

@itomek
itomek added this pull request to the merge queue Apr 30, 2026
@itomek
itomek removed this pull request from the merge queue due to a manual request Apr 30, 2026
@theonlychant

Copy link
Copy Markdown
Contributor Author

@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

@github-actions github-actions Bot added mcp MCP integration changes rag RAG system changes performance Performance-critical changes labels Apr 30, 2026
@itomek
itomek enabled auto-merge May 7, 2026 13:15

@itomek itomek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

  1. This PR: drop the 5 pylint: disable=no-member additions across unrelated modules, drop the documents.py exception-handling change, register the new agents in src/gaia/agents/registry.py so they aren't dead code, replace the except Exception: pass tool-registration blocks with specific error handling, fix the rag_documents mutable default, and beef up test_agents_split.py to exercise tool registration end-to-end.
  2. Separate PR (optional): bundle the pylint disables in one place — pylintrc ignore rules or fixing the underlying type stubs.
  3. Separate PR (required): the documents.py except HTTPException: raise removal 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/gaia/agents/docqa/agent.py Resolved

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
auto-merge was automatically disabled May 7, 2026 15:25

Head branch was pushed to by a user without write access

antmikinka pushed a commit to antmikinka/gaia that referenced this pull request May 7, 2026
## 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
@theonlychant
theonlychant deleted the feat/split-chat-agents branch May 8, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents mcp MCP integration changes performance Performance-critical changes rag RAG system changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants