Support AGENTS.md in GitLab Duo Chat Web UI
## Summary
Currently, `AGENTS.md` file support in GitLab Duo Chat is limited to IDE extensions (VS Code, JetBrains). This feature should be extended to the GitLab Web UI to provide consistent behavior across all Chat interfaces.
## Current State
- **IDE Support**: Full support for user-level, workspace-level, and subdirectory-level `AGENTS.md` files
- **Web UI Support**: Not currently supported
## Desired State
`AGENTS.md` files should be automatically discovered and applied in GitLab Duo Chat conversations within the Web UI, similar to how they work in IDE extensions.
## Scope
### In Scope: Project-level AGENTS.md
The Web UI should support **project-level** `AGENTS.md` files:
- `AGENTS.md` at the project root, or `.gitlab/agents.md`
- Applies to all conversations in that project
> **Note**: "Workspace-level" in the IDE context maps to "project-level" in the Web UI. The Web UI has no workspace concept equivalent to [VSCode Workspace](https://code.visualstudio.com/docs/editing/workspaces/workspaces) or [JetBrains Workspace](https://www.jetbrains.com/help/idea/workspaces.html). GitLab's own [Workspace feature](https://docs.gitlab.com/user/workspace/) is unrelated. This is similar to Copilot's [repository-level custom instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions#creating-custom-instructions).
### Out of Scope (follow-up)
- **Subdirectory-level AGENTS.md**: Adds meaningful complexity (tree-walking, caching, Gitaly calls). Will be tracked as a separate follow-up issue.
- **User-level AGENTS.md**: No local filesystem access in a browser, so this is IDE-only. This will be documented as a limitation.
## Implementation Considerations
### Rule Evaluation Behavior
AGENTS.md rules should be **re-evaluated on each message** based on the user's current project context, not locked at conversation start. If a user switches projects mid-conversation, the new project's AGENTS.md should apply. This keeps behavior consistent with `chat-rules.md` (see [#593392 discussion](https://gitlab.com/gitlab-org/gitlab/-/work_items/593392#note_3166099842)).
### File Discovery
- Web UI should automatically detect and read `AGENTS.md` files from the repository on the default branch
- Similar to how custom rules (`.gitlab/duo/chat-rules.md`) are currently handled in Web UI
### Platform-Specific Notes
Due to the different nature of the interfaces, the business logic of AGENTS.md in Editor Extensions (i.e. GitLab-LSP) and Web UI cannot be consolidated. New business logic will need to be added to [frontend JS in GitLab project](https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/app/assets/javascripts/ai/duo_agentic_chat) (plus extending Backend / Gitaly as needed).
### Coordination with chat-rules.md
The `chat-rules.md` feature ([#593392](https://gitlab.com/gitlab-org/gitlab/-/work_items/593392)) is being implemented in parallel with a similar architecture. The REST API endpoint `/api/v4/duo_chat/rules` can potentially be extended to also return AGENTS.md content. See [!227746](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/227746) for the chat-rules implementation.
## Acceptance Criteria
- [ ] Project-level `AGENTS.md` files (at project root or `.gitlab/agents.md`) are automatically discovered and applied in Web UI Chat
- [ ] AGENTS.md rules are re-evaluated on each message based on the user's current project context (not locked at conversation start)
- [ ] User-level `AGENTS.md` is documented as an IDE-only limitation
- [ ] Subdirectory-level `AGENTS.md` is tracked as a follow-up issue
- [ ] Behavior is consistent with IDE implementation (where applicable)
- [ ] Documentation is updated to clarify Web UI support
## Related Issues/Documentation
- [How GitLab Duo uses AGENTS.md files](https://gitlab.com/help/user/duo_agent_platform/customize/agents_md)
- [Custom rules in Web UI](https://gitlab.com/help/user/duo_agent_platform/customize/custom_rules) (for reference on how similar features are implemented)
- [#593392](https://gitlab.com/gitlab-org/gitlab/-/work_items/593392) - chat-rules.md implementation
- [#592785](https://gitlab.com/gitlab-org/gitlab/-/work_items/592785) - Customization files at subgroup, group, and instance levels
- [gitlab-lsp#1730](https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/work_items/1730) - IDE implementation details
issue