Repository navigation
[16.0][ADD] ai_tool_read: generic read tools with per-field AI opt-out - #122
Conversation
61c1536 to
d765eb0
Compare
6819645 to
965ee23
Compare
Lets an AI agent read any model and field the calling user can access, with a per-field "AI Read Forbidden" flag to keep personal or sensitive fields out of reach. Copied verbatim from OCA/ai#122, which is still open, so the source is the PR head rather than a branch: re-sync from the 16.0 branch once the PR merges. Vendored from OCA/ai@965ee23 (refs/pull/122/head) Assisted-by: Claude Opus 5.5
ebcf9cf to
8d315d7
Compare
Lets an AI agent read any model and field the calling user can access, with a per-field "AI Read Forbidden" flag to keep personal or sensitive fields out of reach. Copied verbatim from OCA/ai#122, which is still open, so the source is the PR head rather than a branch: re-sync from the 16.0 branch once the PR merges. Vendored from OCA/ai@8d315d7 (refs/pull/122/head) Assisted-by: Claude Opus 5.5
8d315d7 to
0b05d55
Compare
Lets an AI agent read any model and field the calling user can access, with a per-field "AI Read Forbidden" flag to keep personal or sensitive fields out of reach. Copied verbatim from OCA/ai#122, which is still open, so the source is the PR head rather than a branch: re-sync from the 16.0 branch once the PR merges. Vendored from OCA/ai@0b05d55 (refs/pull/122/head) Assisted-by: Claude Opus 5.5
ai_tool lets modules expose tools to AI agents, but each one has to be written for a specific model. This module adds three generic tools, list_models, get_fields and search_read, so that an agent can read any model the calling user is allowed to read, with the user's own access rights (ACLs, record rules and field groups still apply). Personal or otherwise sensitive data can be kept out of the results with a new "AI Read Forbidden" flag on ir.model.fields. A flagged field is never returned nor described, and neither is any field exposing its value: related fields, _inherits included, and computed fields depending on it, as the registry reports them. Many2one values are returned as plain IDs, and display names computed on the fly are left out, as both come from name_get, which may show another record's forbidden field. Searches are not restricted, so an agent probing on purpose can still find records by a forbidden value; the README lists those cases. search_read returns the stored fields unless a field list is given, pages its results with limit, offset and has_more, and does not fail as a whole because of one field or record the user may not read. Assisted-by: Claude Opus 5.5
0b05d55 to
1e4cac3
Compare
Port ai_tool_read from OCA#122 to 19.0. - Manifest version bump. - user_has_groups() removed: use res.users.has_groups(). - check_access_rights() deprecated since 18.0: use has_access() / check_access(). - View xpath targets use <list> instead of <tree>. - display_name is never stored in 19.0, so it is excluded everywhere; adjust test_display_name_hidden. - Replace setup/ symlink dir with the whool pyproject.toml convention. Requires the ai_tool fixes from OCA#125, cherry-picked in the preceding commits (ir.model is not readable by internal users in 19.0). Assisted-by: Devin:SWE-2 High
Port ai_tool_read from OCA#122 to 19.0. - Manifest version bump. - user_has_groups() removed: use res.users.has_groups(). - check_access_rights() deprecated since 18.0: use has_access() / check_access(). - View xpath targets use <list> instead of <tree>. - display_name is never stored in 19.0, so it is excluded everywhere; adjust test_display_name_hidden. - Replace setup/ symlink dir with the whool pyproject.toml convention. Requires the ai_tool fixes from OCA#125, cherry-picked in the preceding commits (ir.model is not readable by internal users in 19.0). Assisted-by: Devin:SWE-2 High
|
@dreispt |
- _ai_jsonify: note that isinstance(date) also covers datetime. - _ai_get_fields: document that reporting forbidden fields under "hidden" is deliberate, unlike group-restricted fields which are not disclosed. - _ai_forbidden_fields: return early when no field is flagged. - _ai_search_read: an explicit empty fields list now returns ids only; previously it fell back to the stored-fields default, same as no fields argument at all. Assisted-by: Devin:SWE-2 High
Add a USAGE section covering how the registered ai.tool records are consumed (e.g. via ai_oca_mcp), the list_models / get_fields / search_read agent workflow, and the search_read arguments with an example. Drop the "This module" opening from the description. Assisted-by: Devin:SWE-2 High
210c87b to
609e40b
Compare
- The help of "AI Read Forbidden" still said that flagged fields are kept out of domains and orderings. They are not since the tools stopped rejecting them (see Known issues): say that the flag keeps values out of the results only, so that an administrator does not rely on it against filtering. - A negative offset reached PostgreSQL and failed the call with a SQL error. Treat it as 0, next to the limit guard. - The tool descriptions kept the leading newline and indentation of the XML text, shown as is in the form view and sent to MCP clients. Write each one as a single paragraph. - CONFIGURE.md: start the list items with a capital letter. Assisted-by: Claude Opus 5.5
|
@dreispt Thanks again. I've updated the branch:
The PR description is corrected accordingly, and CI is green. |
AungKoKoLin1997
left a comment
There was a problem hiding this comment.
Code and functional review: LGTM
|
This PR has the |
|
@etobella, this ADD PR is ready for you to review. Thanks in advance for taking the time to review this PR! I really appreciate your feedback and support! |
|
@dreispt, could you merge this PR when you have time? |
etobella
left a comment
There was a problem hiding this comment.
Well, I get the idea of the tools
- You can access only models that the accessing user has access to. It implies that I cannot say that it only has access to products and not sale.orders and another MCP viceversa.
- Safety for me is correct
Let's merge it as there is no problems with the code
/ocabot merge nobump
|
Thank you for checking this PR! |
|
Hey, thanks for contributing! Proceeding to merge this for you. |
|
@etobella The merge process could not be finalized, because command |
|
@OCA/pypi-support 🙏 |
|
@etobella name reserved |
|
/ocabot merge nobump |
|
On my way to merge this fine PR! |
|
Congratulations, your PR was merged at 6ec93fa. Thanks a lot for contributing to OCA. ❤️ |
This module adds generic
ai_tooltools that let an AI agent read any model and field it is allowed to access, while keeping personal or otherwise sensitive fields out of the results.Three tools are provided:
hidden.The tools run with the calling user's own access rights (no
sudoon the data), so ACLs, record rules and fieldgroupsstill apply.A per-field flag AI Read Forbidden (
ai_no_read) is added toir.model.fields. A flagged field is never returned nor described, and neither are the fields exposing its value through their definition (related fields, fields delegated through_inherits, and computed fields depending on it). The flag can be set on base fields as well as custom ones. It keeps values out of the results, not out of the searches an agent runs: filtering or sorting on a forbidden field is not prevented (see Known issues in the README).Assisted-by: Claude Opus 5.5
@qrtl
QT6693