Skip to content

[IMP] odev-plugin-ai: improve sandbox handler flow - #42

Open
sea-odoo wants to merge 3 commits into
betafrom
copilot/local-20260901-odev-plugin-ai
Open

[IMP] odev-plugin-ai: improve sandbox handler flow#42
sea-odoo wants to merge 3 commits into
betafrom
copilot/local-20260901-odev-plugin-ai

Conversation

@sea-odoo

@sea-odoo sea-odoo commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Improve AI plugin internals for handlers, editor integration and sandbox execution so command flows are more consistent and predictable.

308bb72 fixes two bugs that made odev ai unusable on Linux:

[!] Failed to setup Chrome wrapper: property 'home_path' of 'Odev' object has no setter
[-] Execution failed due to an unhandled exception:
    AttributeError: 'ExecutionSpec' object has no attribute 'mcp_servers'
  • spec.mcp_servers never existed. Both backends pass mcp_servers=spec.mcp_servers into the security warning (bwrap.py:372, seatbelt.py:405), but the field was never added to ExecutionSpec and the parameter was never added to _display_sandbox_warning — so every run died on the AttributeError, and would have hit a TypeError right after it. The field is now on the spec, passed from Agent.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 what ai-analyze and ai-scaffold pass through run_ai_agent(mcp_servers=...), and it was silently unreviewable.
  • Odev.home_path is a read-only property. _add_system_binds assigned to it to redirect Chrome.get_wrapper() into sandbox_tmp, which has never worked. Chrome reads nothing off odev but home_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-wrapper would overwrite the host's own wrapper with a path that only resolves inside a sandbox.
  • _check_bwrap_support returns its success value from an else branch — and this is not cosmetic: the TRY300 fix is only correct with the else, since dropping the return from the try alone makes the function return None on success and report a working host as unsupported.
  • bwrap.py now passes the repository's own ruff-required hook: the guest /tmp paths, the deferred bash import and the deliberate blind catches carry a noqa naming 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 HEAD still fails ruff-required with 19 findings from this branch's earlier commits, in two files 308bb72 does 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 the TRY300 above 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

  • None

Compliance

  • I have read the contribution guide
  • I made sure the documentation is up-to-date both in doctrings and the docs directory
  • I have added or modified unit tests where necessary
  • I have added new libraries to the requirements.txt file, if any
  • I have incremented the version number according the versioning guide
  • The PR contains my changes only and no other external commit

Assisted by Claude Opus 5

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 sea-odoo changed the title chore: apply local updates [IMP] odev-plugin-ai: improve sandbox handler flow Sep 1, 2026
@sea-odoo
sea-odoo force-pushed the copilot/local-20260901-odev-plugin-ai branch from f059bcd to 3b47f60 Compare September 1, 2026 14:18
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant