Skip to content

Add the AI Research Assistant app template and its features - #557

Merged
samhornstein merged 12 commits into
masterfrom
pr-ai-research-assistant
Nov 23, 2026
Merged

samhornstein merged 12 commits into
masterfrom
pr-ai-research-assistant

Conversation

@samhornstein

@samhornstein samhornstein commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What

A Workbench app (src/ai-research-assistant): an OpenCode agent in an NVIDIA OpenShell sandbox, behind its own web UI, with code-server under /ide/. New features: ai-policy, agent-sandbox, opencode-harness, cohort-designer, kumo-forecast, vertex-model, vllm-model. Tests are under tests/. CI is .github/workflows/test-ai-research-assistant.yaml.

  • Access. Two fixed Workbench groups in the verily org (alpha, beta), with feature flags per tier. The UI server refuses /oc and /events to anyone the check does not admit, and refuses cross-site requests.
  • Model. Beta gets Nemotron 3.5 Super VL on vLLM 0.34.0 on 2× H100 80 GB. Alpha also gets Vertex AI models when the machine has no H100s: a Nemotron endpoint in the workspace's project, else Gemini. No Vertex AI model is offered inside a data perimeter (workspace policy terra/exfil-perimeter-constraint, for the workspace in the VM's metadata), or when the app cannot read the policies.
  • Sandbox. The agent holds no credentials. Its network is deny-by-default, compiled from the image's policy. It allows the workspace's BigQuery and Cloud Storage, writes only to resources the workspace owns, the Workbench MCP server's core and workflow tools (not the shell or credential tools), and the cohort and forecast MCP servers.
  • Assistant UI. An allow-list sanitizer renders model and tool text under a Content-Security-Policy, so the text cannot make the browser load a URL.
  • Cohort designer. A released binary, fetched by URL with a pinned sha256. Its source has a separate licence and is not in this repository. The default release URL is a bucket shared with the testers.
  • Kumo forecasts. Risk forecasts for a locked cohort. Counts of 1–19 are masked. Writing the highest-risk members to a bucket asks for approval.

Reviewer guide

About 9,500 lines of code, 5,000 of tests and 1,400 of docs, in ten commits, one per area. Review each one on its own (Commits → pick one). Skim the tests. Read them where the code looks wrong.

intro-diagram
# Area Code Tests Reviewer Focus
1 App template: compose, start-services.sh, README 1,180 420 platform / devcontainers Start-up order and locks. What each container can reach.
2 Assistant UI server and page 1,800 440 web security /oc allow-list and access gate. Cross-site refusal. Sanitizer and CSP.
3 Vendored marked + DOMPurify 76 – skip Unmodified releases.
4 ai-policy: access, perimeter, policy compiler 1,460 1,010 security Does every error path fail closed? Can workspace data widen the network policy?
5 agent-sandbox: sandbox CLI, broker 2,340 400 security / infra Broker forced command. No root-owned writes through the user's folder. What the agent can reach.
6 opencode-harness: sandbox image, OpenCode config 300 210 security Pinned downloads. Approvals map to OpenCode permissions.
7 Models: vLLM, Vertex AI proxy, endpoint deploy 1,170 710 ML infra Bind addresses. Token handling. deploy-endpoint.sh needs --yes.
8 Cohort designer install 470 300 anyone sha256 check before install.
9 Kumo forecasts 2,120 1,470 data privacy / ML Every count that leaves the service masks 1–19 (privacy.py and callers). Fixtures are synthetic.
10 CI workflow 67 – anyone

Decided (please do not reopen)

  • One app for All of Us and other workspaces. No -aou variant.
  • Access is two fixed groups (alpha, beta). Not configurable.
  • Models per tier as in What.
  • The cohort designer ships as a released binary with a pinned sha256. Its release bucket is temporary, until the shared registry is available.
  • Small counts: the agent's instructions forbid counts 1–19. Kumo masks them in code. The designer does not mask them yet (separate release schedule).
  • No workflows inside data perimeters.

How tested

  • Eight Python suites, shellcheck, and the Go tests of the server this PR stacks on pass. Five cohort-designer tests skip without the binary.
  • 2× H100: the image builds. Super VL answers on vLLM 0.34.0 across both GPUs.
  • T4 (Gemini), this exact code: build, start, full stop and start, and the policy applied to the existing sandbox on restart. Also the broker's status file, the pinned OpenCode release, the UI's CSP and request checks, all three MCP servers, ?toolsets=all still listing only the 28 core and workflow tools, and a wb tool call after restart. An earlier commit also ran a cohort request up to its lock approval.
  • Not yet run on a live app: the approval prompt on forecast_select_highest_risk.

To run the tests:

for s in agent-sandbox ai-policy ai-research-assistant cohort-designer kumo-forecast opencode-harness vertex-model vllm-model; do
  python3 -m unittest discover -s tests/$s
done

Install what CI installs: pyyaml, the assistant UI's requirements.txt, and pandas==2.3.3 numpy scikit-learn==1.9.1 pyarrow==25.0.0. Set COHORT_DESIGNER_BIN to run the five cohort-designer tests.

Known limitations

  • The access and perimeter checks control what the app offers. They are not a boundary against the app's own user, who has root in the app container. The sandbox is the boundary for the agent.
  • A process the agent starts (for example curl from its shell tool) can call the allowed MCP tools without the approval prompt.
  • The cohort designer does not mask small counts in code. The agent's instructions keep them out of answers.
  • Kumo's population breakdown (two excluded counts, members at risk, population size) always adds up. When exactly one count is under 20, a reader can calculate it.
  • Workflow runs are not supported inside data perimeters.

Merge order

After #556. tests/ai-policy reads its tool groups.

Generated with Claude Code

@samhornstein
samhornstein requested review from a team as code owners November 20, 2026 07:01
@samhornstein
samhornstein marked this pull request as draft November 20, 2026 07:06
@samhornstein
samhornstein marked this pull request as ready for review November 20, 2026 07:12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all these features intended to be used in other apps as well? why not build them into the app itself?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Features (OpenShell agent sandboxing, OpenCode harness, cohort designer, Kumo forecasting) were intentionally pulled out so others apps could reuse them.

@pantherman594 pantherman594 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long term we should have a better home for most of the code in this app but changes are contained so risk is low

Comment thread src/ai-research-assistant/Dockerfile Resolved

@michaelxiao7 michaelxiao7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for future reference this probably should've been 3-4 PRs, but as David said the changes are pretty isolated so it should be okay to ship

Base automatically changed from pr-wb-mcp-toolsets to master November 23, 2026 20:14
Sam H and others added 12 commits November 23, 2026 12:16
src/ai-research-assistant: the devcontainer, the compose file (app, sandbox gateway, broker,
assistant UI, Caddy front door, port guard), start-services.sh (access check, model choice,
starting the servers once per container start), and the README with the architecture and the
Known limitations. Tests for the front door, the broker image and start-up logic, and a check
that no project IDs are committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A FastAPI server and a static page. The server lets through only an allow-list of OpenCode
calls (/oc) and the event stream (/events), only for a person the access check admitted, and
refuses cross-site requests. The page renders model text through an allow-list sanitizer under
a Content-Security-Policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unmodified minified releases with their licence headers; no review needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…policy compiler

access.py: the two fixed groups in the verily org, the feature flags per tier, the data
perimeter check for the app's workspace, and the model choice. render-policy.py: compiles the
administrator's ai-policy.yaml, the workspace's data and the tool groups into the OpenShell
network policy. workspace-data.py: the workspace's datasets and buckets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its broker

agent-sandbox.sh: creates the sandbox, applies the rendered policy, forwards the agent's
server, uploads and downloads. The broker container is the only thing that talks to the
OpenShell gateway: sshd with a forced command. The image's policy files (config/), the tool
groups, the agent's instructions and the self-test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndbox

The sandbox image (OpenCode from its release, checked by sha256), the harness definition and
the OpenCode config hook that turns the policy's tools and approvals into OpenCode
permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vllm-model: Nemotron 3.5 Super VL on vLLM 0.34.0 on two H100 80 GB. vertex-model: an
OpenAI-compatible proxy in front of Gemini or a Nemotron endpoint on Vertex AI, for alpha users
outside a data perimeter, and deploy-endpoint.sh for that endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fetches the released designer binary by URL, checks its pinned sha256 before installing, and
runs it as an MCP server. Its source is under a separate licence and not in this repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d cohort

An MCP server: reads a cohort the designer locked, builds the relational graph, forecasts the
outcome with Kumo's model and baselines, and reports counts and rates with 1-19 masked
(privacy.py). Writing the highest-risk members to a bucket asks for approval. Test fixtures
are synthetic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shellcheck and the Python suites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The side panel's last line under "Where the assistant runs" named Gemini,
and its unquoted ": " made YAML read it as a mapping, so the page showed
it as a dict. The model in use is already named at the top of the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samhornstein
samhornstein force-pushed the pr-ai-research-assistant branch from d933771 to 5a538da Compare November 23, 2026 20:16
@samhornstein
samhornstein merged commit 8593522 into master Nov 23, 2026
4 checks passed
@samhornstein
samhornstein deleted the pr-ai-research-assistant branch November 23, 2026 20:19
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.

3 participants