[IMP] odev-plugin-ai: improve sandbox handler flow - #42
Open
sea-odoo wants to merge 3 commits into
Open
Conversation
Keep AI command execution consistent across handlers and sandbox backends.\n\nAlign editor and sandbox interactions so local and hosted runs use the same execution path.
sea-odoo
force-pushed
the
copilot/local-20260901-odev-plugin-ai
branch
from
September 1, 2026 14:18
f059bcd to
3b47f60
Compare
Fix plugin loading failures caused by committed merge conflict markers and mismatched symbols in shared AI helper modules. Restore coherent implementations for agent, handlers and sandbox base, and reintroduce GUIDELINES_SKILL in mixins for downstream imports.
…read off it
`odev ai` died before starting on any run: both sandbox backends pass
`mcp_servers=spec.mcp_servers` to the security warning, and neither the field nor the
parameter it lands on was ever added.
AttributeError: 'ExecutionSpec' object has no attribute 'mcp_servers'
- sandbox: add `mcp_servers` to `ExecutionSpec`, pass it from `Agent.run`, and take it on
`_display_sandbox_warning`. An MCP server is a hole in the sandbox - it reaches
whatever it reaches from outside it - so it is listed on the panel the developer
approves, by name and by the command or url it runs, alongside the binds.
- bwrap: write the Chrome wrapper by handing `Chrome` an object whose `home_path` is the
sandbox tmp, rather than assigning to `Odev.home_path`, which is a read-only property
and failed with "property 'home_path' of 'Odev' object has no setter". The wrapper
points at the guest binary, so it must not be written to the shared odev home where it
would overwrite the host's own.
- bwrap: `_check_bwrap_support` returns its success value from an `else` branch, and the
guest paths, deferred import and deliberate blind catches carry the `noqa` that says
why - the file did not pass the repository's own ruff hook.
Assisted by Claude Opus 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improve AI plugin internals for handlers, editor integration and sandbox execution so command flows are more consistent and predictable.
308bb72fixes two bugs that madeodev aiunusable on Linux:spec.mcp_serversnever existed. Both backends passmcp_servers=spec.mcp_serversinto the security warning (bwrap.py:372,seatbelt.py:405), but the field was never added toExecutionSpecand the parameter was never added to_display_sandbox_warning— so every run died on theAttributeError, and would have hit aTypeErrorright after it. The field is now on the spec, passed fromAgent.run, and taken by the warning. It is also shown: an MCP server is a hole in the sandbox — it reaches whatever it reaches from outside it — so it belongs on the panel the developer approves, listed by name and by the command or url it runs. This is whatai-analyzeandai-scaffoldpass throughrun_ai_agent(mcp_servers=...), and it was silently unreviewable.Odev.home_pathis a read-only property._add_system_bindsassigned to it to redirectChrome.get_wrapper()intosandbox_tmp, which has never worked.Chromereads nothing offodevbuthome_path, so it is handed an object that answers with the sandbox tmp instead. Note the wrapper must not go to the shared odev home: it points at the guest binary (/opt/google/chrome/chrome), so writing it to{odev.home_path}/tmp/odoo-chrome-wrapperwould overwrite the host's own wrapper with a path that only resolves inside a sandbox._check_bwrap_supportreturns its success value from anelsebranch — and this is not cosmetic: theTRY300fix is only correct with theelse, since dropping thereturnfrom thetryalone makes the function returnNoneon success and report a working host as unsupported.bwrap.pynow passes the repository's ownruff-requiredhook: the guest/tmppaths, the deferredbashimport and the deliberate blind catches carry anoqanaming the reason.Verification
Ran the reported command end to end on Linux/bwrap — it now reaches the security panel and exits cleanly, with no Chrome warning and no exception. The MCP panel section was exercised separately against all three server shapes (
command+args,url, and an empty dict, which must render no parenthesis).Known issue — not fixed here
pre-commit run --from-ref origin/beta --to-ref HEADstill failsruff-requiredwith 19 findings from this branch's earlier commits, in two files308bb72does not touch:common/sandbox/seatbelt.py(15) — the macOS backend, which cannot be run or verified from Linux. Several are behaviour-adjacent rewrites (PERF401×4,SIM105,TRY300), and theTRY300above is exactly the shape that silently breaks a return value.common/handlers/agy.py(4) —PLR0913,S110,BLE001×2.Worth a separate pass, ideally by someone who can run the macOS backend.
Linked Issues
Compliance
docsdirectoryrequirements.txtfile, if anyAssisted by Claude Opus 5