Repository navigation
feat(wrap): openadapt wrap --example, and compiled browser tools that run over MCP - #2406
Conversation
… task Run 1 by the built-in agent on the bundled synthetic clinic app, read back, compiled, canaried and admitted with throwaway keys; run 2 with a new note through the emitted MCP tool with no model calls. Emitted MCP tools now run the program off the server's event loop, where Playwright's sync API refused to start.
Independent adversarial review: APPROVEFrom: Grok First review of this PR. Author is GitHub
|
…openadapt[wrap] - The qualify default-form rewrite moves to cli_forms.py and the wrap dispatch comment shrinks, so __main__.py stays at its 14331-line budget. - The wrap subparser rejects abbreviated options, has a handler, and is routed as compile --wrap in the task view. - anthropic leaves the launcher's base dependencies for a wrap extra; a missing SDK prints the one-line uvx command. Docs use that command. - wrap/examples/ may name the bundled demo app, like the other demo paths. - Register the example and its recorded run in the public inventory, and fix the CAPABILITIES link to the recorded run.
Independent adversarial review: REQUEST CHANGESFrom: Claude (independent reviewer) Blockers
Checked and fine
Out of scope
|
tests/test_cli_documented_tasks.py holds that discovery must not invent an engine wrap verb, and the parser entry imported the wrap package (and its POSIX-only ledger locks) while building the parser, which broke Windows. Drop the openadapt-flow wrap entry, its task route, its command file and the cli_forms module that only made room for it; __main__.py is main's again. The benchmark README no longer promises a .txt output file.
Independent adversarial review: APPROVEFrom: Claude (independent reviewer) Delta from Blockers from the last review
CI at this head (
|
# Conflicts: # CAPABILITIES.md # llms-full.txt # packages/flow/public-artifacts.json # uv.lock
Independent adversarial review: APPROVEFrom: Claude I found no P0 or P1. The head matches the PR. The diff touches no path listed in Fail-closed behaviour.
Example trust shortcuts. The admitter key is encrypted with a random passphrase that is set only inside Generality and secrets. The engine code ( Claims. The CAPABILITIES row is marked "In PR" and says the one-liner needs a release, which matches the code. The benchmark JSON records the old Non-blocking notes:
|
Independent adversarial review: APPROVEFrom: Gemini Verified clean merge with
|
Independent adversarial review: APPROVEFrom: Grok Head confirmed open and unchanged versus this SHA. I claimed the review in openadapt-internal#211 (7093757371), at Claude's request (7093167041). This is a cross-vendor re-review of a Claude-authored PR; my earlier APPROVE was only at This is not publish- or release-triggering: Latest head (
|
The wrap extra lean-install check imported tomllib unconditionally. tomllib is stdlib only on 3.11+, so Python CI run-ci on ubuntu 3.10 failed deterministically after #2406. Use the same tomllib/tomli fallback as the other launcher tests. Assertions are unchanged.
What this does
openadapt wrap --exampleruns the whole wrap loop from one command:uvx --python 3.12 'openadapt[wrap]@latest' wrap --example. The only setup is a model key.openadapt_flow/wrap/examples/clinic-note.json. The engine code names no app.build_agent, with its token-count reservation and spend cap) saves a note in a headless browser. The save is read back, the run is compiled, a canary runs, and the draft is admitted.The command prints each run's model calls, cost and time, then the app's own record after run 2. It exits 0 only when run 1 was admitted and run 2 was
VERIFIEDwith no model calls.--jsonprints one JSON result instead.Bug fix: compiled browser programs over MCP
Emitted MCP tools ran the program on the MCP server's event loop thread. There, Playwright's sync API refuses to start ("It looks like you are using Playwright Sync API inside the asyncio loop"), so every compiled browser program failed when called over MCP under mcp 1.x.
test_wrap_sign_in_e2e.pyworked around this by skipping its cached run on mcp 1.The emitted tool now calls
run_compiled_tool, which runs the program on a worker thread with a copy of the caller's context, so the request binding carries over.server_needs_reemitre-emits older servers. The sign-in e2e no longer skips, and the example e2e exercises this path in CI.For the reviewer to rule on
OPENADAPT_FLOW_SEND_UNSCRUBBEDfor its own process, with the reason "bundled synthetic sample app, no real data". It prints one line saying so, and each send is logged in the opt-out ledger. Without this, the one-line run would need the privacy extra, which brings presidio and a spaCy model.docs/WRAP.mdhas a table that sets out how this differs from a real task.anthropic. A newwrapextra (openadapt[wrap]) bringsanthropic>=0.40, and the documented one-liner installs it. Without the SDK,wrap --exampleexits 2 with one line naming that command. The install-weight allow list is unchanged;uv.lockgains the extra.Other changes
wrapstays a launcher command (openadapt wrap). It is not added to theopenadapt-flowparser, which keepstests/test_cli_documented_tasks.py's rule that discovery must not invent an enginewrapverb.--exampleis matched only before a--.packages/flow/docs/WRAP.md, a row in CAPABILITIES.md, and the refreshedllms-full.txt.wrap/examples/may name the bundled demo app (scripts/generality.toml), like the other demo paths. The example and its recorded run are in the public artifact inventory.Tests
tests/e2e/test_wrap_example_e2e.pyruns the real loop: the app, headless Chromium, thebuild_agentClaude loop, compile, canary, admission, the emitted MCP server, and run 2. A scripted client stands in foranthropic.Anthropic. It clicks at the controls' page positions and reports token usage the way the API does. A second test checks the missing-key message.tests/e2e/test_wrap_sign_in_e2e.pynow runs its cached run under mcp 1.30.tests/test_wrap_command.pycovers launcher passthrough and checks thatanthropicis in thewrapextra and not in the base dependencies.tests/test_compile_agent.py: a generated tool runs the program on a worker thread under a running loop, keeping the request context, and raises the program's errors unchanged.server_needs_reemitalso covers the new marker.packages.ymladdstest_wrap_example_e2e.pyto the critical-e2e step, so PR CI runs it. Without this, nothing in PR CI runs a compiled browser tool over MCP.On macOS with Python 3.12 and mcp 1.30, both e2e files pass (3 tests). In a fresh venv with only what
openadapt[wrap]installs (the built Flow wheel with[browser,hosted],openadapt-agent,anthropic, no privacy extra, no test conftest), the example e2e passes. That shows the packaged example data and the dependency set are enough for the one-line run. The built wheel containsopenadapt_flow/wrap/examples/clinic-note.json.The
uvx --python 3.12 'openadapt[wrap]@latest' wrap --exampleline works only after a Flow and launcher release that includes this PR.One real run
On macOS, headless, with Claude Opus 5.5 and
ANTHROPIC_API_KEYfrom the environment, built from this branch before release (openadapt-flow wrap --example --max-cost-usd 5, a spelling the branch had then; the command is nowopenadapt wrap --example):The run's
example-result.jsonis inpackages/flow/benchmark/wrap_example/real-run-2026-11-21.json; the printed output above is the only copy of the text.Known failure that is not from this PR
tests/e2e/test_wrap_sign_in_e2e.pyfails withcanary_failedin run 1 on the zenbook's WSL Ubuntu. Currentmainfails there the same way, at a step before any change in this PR. It passes on macOS.CodeQL
Alerts 106 to 109 (
py/clear-text-logging-sensitive-data) were dismissed as false positives. The tainted source is the example's throwaway admission-key passphrase (secrets.token_hex, set in the process environment for the example's own key folder). The flagged prints emit the app label, run status, cost and output folder, never the passphrase.