From 55e9ae462cc9574853b9a458dd28115e673564a7 Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 10:15:44 +0200 Subject: [PATCH 1/4] perf(sandbox): start the Playwright MCP server only when a turn uses it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every managed agent turn lists the Playwright MCP server among its tools, so every turn started it: a Node process that loads Playwright as it starts, about 100 MB of memory and a third of a second of CPU, held for the whole turn, although most turns never open a browser. tale-playwright-mcp, now a small Python proxy (about 20 MB, first answer in about 50 ms), answers the start of a turn itself — initialize, tools/list and ping — from manifests the image build records from the real server for the argument sets the platform passes (playwright-mcp-args.json, held equal to exec-builder's sets by its test). The answer to initialize is the server's own for every protocol version MCP has named, its latest for one it does not speak, so a later start negotiates the same version. On the turn's first other request it starts the server, replays the client's initialize under an id of its own, and passes every message through both ways. Unknown arguments or protocol versions, and TALE_PLAYWRIGHT_MCP_EAGER=1, start the server at once, as before. The proxy flags it adds to the server are unchanged. --- .../lib/harnesses/exec-builder.test.ts | 22 ++ .../platform/lib/harnesses/exec-builder.ts | 10 + services/platform/turbo.json | 1 + services/sandbox-runtime/Dockerfile | 12 +- services/sandbox-runtime/README.md | 11 +- .../daemon/src/tale-playwright-mcp.test.ts | 366 ++++++++++++++++-- .../sandbox-runtime/playwright-mcp-args.json | 20 + services/sandbox-runtime/tale-playwright-mcp | 361 ++++++++++++++++- 8 files changed, 761 insertions(+), 42 deletions(-) create mode 100644 services/sandbox-runtime/playwright-mcp-args.json diff --git a/services/platform/lib/harnesses/exec-builder.test.ts b/services/platform/lib/harnesses/exec-builder.test.ts index 95c5a0dfa1..aec2a33ccd 100644 --- a/services/platform/lib/harnesses/exec-builder.test.ts +++ b/services/platform/lib/harnesses/exec-builder.test.ts @@ -5,6 +5,10 @@ // injection safety, error paths). Byte-exact construction is // golden-exec.test.ts. +import { readFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + import type { HarnessDefinition } from '@tale/shared/schemas/providers'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; @@ -13,6 +17,7 @@ import { buildHarnessExec, CACHE_AFFINITY_GATEWAY_HEADER, isClaudeModelRef, + PLAYWRIGHT_MCP_ARG_SETS, } from './exec-builder'; import { batteryFor, GOLDEN_BYO_ENV, GOLDEN_GATEWAY } from './test-helpers'; import type { HarnessExec, HarnessRunSpec } from './types'; @@ -904,3 +909,20 @@ describe('gemini requests the model it was given', () => { } }); }); + +describe('the Playwright MCP server the runtime image prepares for', () => { + it('has a record for every argument set a turn may start it with', () => { + // The image records the server's answers for these sets; a set missing + // there starts the server (~100 MB) with every turn again. + const recorded: unknown = JSON.parse( + readFileSync( + path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + '../../../sandbox-runtime/playwright-mcp-args.json', + ), + 'utf8', + ), + ); + expect(recorded).toEqual(PLAYWRIGHT_MCP_ARG_SETS); + }); +}); diff --git a/services/platform/lib/harnesses/exec-builder.ts b/services/platform/lib/harnesses/exec-builder.ts index b67a396e02..77813c12cb 100644 --- a/services/platform/lib/harnesses/exec-builder.ts +++ b/services/platform/lib/harnesses/exec-builder.ts @@ -187,6 +187,16 @@ const PLAYWRIGHT_MCP_ARGS = [ * the path, so the agent reads it as usual. */ const PLAYWRIGHT_VISION_ARGS = ['--image-responses', 'omit'] as const; +/** Every argument set a turn may start the Playwright MCP server with. The + * runtime image records the server's answers to the start of a turn for each + * of them (services/sandbox-runtime/playwright-mcp-args.json, held equal by + * this module's test), so a turn that never opens a browser never starts the + * server; a set it has no record for starts the server at once. */ +export const PLAYWRIGHT_MCP_ARG_SETS: readonly (readonly string[])[] = [ + PLAYWRIGHT_MCP_ARGS, + [...PLAYWRIGHT_MCP_ARGS, ...PLAYWRIGHT_VISION_ARGS], +]; + /** The capability-dispatch bridge — lets the agent use the org's connected * connectors. The credential stays server-side; the bridge only relays * dispatch requests to the platform, authed by the session key. Because it diff --git a/services/platform/turbo.json b/services/platform/turbo.json index 89503098b5..f4f0655cec 100644 --- a/services/platform/turbo.json +++ b/services/platform/turbo.json @@ -26,6 +26,7 @@ "$TURBO_ROOT$/services/sandbox-runtime/Dockerfile", "$TURBO_ROOT$/services/sandbox-runtime/daemon/src/file-ops.ts", "$TURBO_ROOT$/services/sandbox-runtime/daemon/src/protocol.ts", + "$TURBO_ROOT$/services/sandbox-runtime/playwright-mcp-args.json", "$TURBO_ROOT$/services/sandbox/src/config.ts" ] }, diff --git a/services/sandbox-runtime/Dockerfile b/services/sandbox-runtime/Dockerfile index c285c9cf18..2b72a21c67 100644 --- a/services/sandbox-runtime/Dockerfile +++ b/services/sandbox-runtime/Dockerfile @@ -488,10 +488,16 @@ COPY services/sandbox-runtime/tale-plan-gate /usr/local/bin/tale-plan-gate # via the session entrypoint; baked here so it exists read-only. COPY services/sandbox-runtime/tale-git-credential /usr/local/bin/tale-git-credential -# Playwright MCP launcher shim: appends --proxy-server/--proxy-bypass from the -# container's HTTPS_PROXY/NO_PROXY (Chromium ignores the env vars) and execs -# mcp-server-playwright. The agent adapters use this as the MCP command. +# Playwright MCP launcher: appends --proxy-server/--proxy-bypass from the +# container's HTTPS_PROXY/NO_PROXY (Chromium ignores the env vars), and answers +# the start of an agent turn (initialize, tools/list) from manifests of the +# real server's answers, recorded below for the argument sets the platform +# passes (playwright-mcp-args.json, held to exec-builder.ts by its test): the +# server, a Node process holding ~100 MB, starts only once the turn first uses +# the browser. The agent adapters use this as the MCP command. COPY services/sandbox-runtime/tale-playwright-mcp /usr/local/bin/tale-playwright-mcp +COPY services/sandbox-runtime/playwright-mcp-args.json /opt/tale/playwright-mcp/args.json +RUN python3 -Es /usr/local/bin/tale-playwright-mcp --write-manifests /opt/tale/playwright-mcp/args.json # Connector-dispatch MCP bridge: a dependency-free stdio MCP server the agent # adapters wire in via --mcp-config. Relays connector({slug,operation,args}) diff --git a/services/sandbox-runtime/README.md b/services/sandbox-runtime/README.md index 7d748ba844..51f2003c41 100644 --- a/services/sandbox-runtime/README.md +++ b/services/sandbox-runtime/README.md @@ -16,7 +16,16 @@ Headless Chromium and Playwright are available on demand for automation, rendering and screenshots. The runtime starts no display server, managed browser or viewing tunnel. Configured transparent egress redirects external network access through `@tale/sandbox-egress`; Playwright MCP also receives -the proxy settings through its launcher. +the proxy settings through its launcher (`tale-playwright-mcp`). Every managed +agent turn lists the Playwright MCP server, but most never open a browser, and +the server — a Node process that loads Playwright — holds about 100 MB while it +runs. So the launcher answers the start of a turn itself (`initialize`, +`tools/list`, `ping`) from manifests of the real server's answers, recorded at +image build for the argument sets the platform passes +([`playwright-mcp-args.json`](playwright-mcp-args.json)), and starts the server +only on the turn's first tool call, replaying the start to it. Unknown +arguments or protocol versions, and `TALE_PLAYWRIGHT_MCP_EAGER=1`, start the +server at once. Python document libraries are baked into the shared Python 3.12 environment: openpyxl and xlrd for spreadsheets, pypdf for PDFs, PyYAML for safe YAML diff --git a/services/sandbox-runtime/daemon/src/tale-playwright-mcp.test.ts b/services/sandbox-runtime/daemon/src/tale-playwright-mcp.test.ts index 4718a57f08..2e4eecf149 100644 --- a/services/sandbox-runtime/daemon/src/tale-playwright-mcp.test.ts +++ b/services/sandbox-runtime/daemon/src/tale-playwright-mcp.test.ts @@ -1,34 +1,54 @@ -// The headless launcher still bridges proxy settings into Playwright's flags -// after removal of the managed browser/CDP viewing mode. +// The Playwright MCP launcher: it bridges the sandbox proxy into Playwright's +// flags, and it answers the start of a turn from a manifest of the real +// server's answers, starting the server only when the turn first uses it. A +// stand-in server on PATH records what reached it. import { afterAll, describe, expect, test } from 'bun:test'; -import { spawnSync } from 'node:child_process'; -import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { spawn, spawnSync } from 'node:child_process'; +import { + existsSync, + mkdirSync, + mkdtempSync, + readdirSync, + readFileSync, + rmSync, + writeFileSync, +} from 'node:fs'; import { tmpdir } from 'node:os'; import { join, resolve } from 'node:path'; -const dir = mkdtempSync(join(tmpdir(), 'tale-playwright-shim-')); -const shim = resolve(import.meta.dir, '../../tale-playwright-mcp'); -writeFileSync( - join(dir, 'mcp-server-playwright'), - '#!/bin/sh\nprintf "%s\\n" "$PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK" "$@"\n', - { mode: 0o755 }, -); +const dir = mkdtempSync(join(tmpdir(), 'tale-playwright-mcp-')); +const launcher = resolve(import.meta.dir, '../../tale-playwright-mcp'); +const python = Bun.which('python3') ?? 'python3'; afterAll(() => rmSync(dir, { recursive: true, force: true })); -function launch(proxy: string, bypass: string): string[] { - const result = spawnSync( - '/bin/sh', - [shim, '--headless', '--browser', 'chromium'], - { - env: { ...process.env, PATH: dir, HTTPS_PROXY: proxy, NO_PROXY: bypass }, - encoding: 'utf8', - }, +describe('headless Playwright MCP launcher', () => { + const bin = join(dir, 'echo-bin'); + mkdirSync(bin); + writeFileSync( + join(bin, 'mcp-server-playwright'), + '#!/bin/sh\nprintf "%s\\n" "$PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK" "$@"\n', + { mode: 0o755 }, ); - expect(result.status).toBe(0); - return result.stdout.trim().split('\n'); -} -describe('headless Playwright MCP launcher', () => { + function launch(proxy: string, bypass: string): string[] { + const result = spawnSync( + python, + ['-Es', launcher, '--headless', '--browser', 'chromium'], + { + env: { + ...process.env, + PATH: bin, + HTTPS_PROXY: proxy, + NO_PROXY: bypass, + TALE_PLAYWRIGHT_MCP_MANIFESTS: join(dir, 'no-manifests'), + }, + encoding: 'utf8', + }, + ); + expect(result.status).toBe(0); + return result.stdout.trim().split('\n'); + } + test('preserves headless launch flags and appends the sandbox proxy', () => { expect(launch('http://sandbox-egress:3128', '127.0.0.1,localhost')).toEqual( [ @@ -43,6 +63,7 @@ describe('headless Playwright MCP launcher', () => { ], ); }); + test('does not invent proxy arguments when no proxy is configured', () => { expect(launch('', '')).toEqual([ '1', @@ -51,4 +72,303 @@ describe('headless Playwright MCP launcher', () => { 'chromium', ]); }); + + test('runs through its own interpreter line', () => { + const result = spawnSync(launcher, ['--headless'], { + env: { + ...process.env, + PATH: `${bin}:${process.env.PATH ?? ''}`, + TALE_PLAYWRIGHT_MCP_MANIFESTS: join(dir, 'no-manifests'), + }, + encoding: 'utf8', + }); + expect(result.status).toBe(0); + expect(result.stdout.trim().split('\n')).toEqual(['1', '--headless']); + }); +}); + +// A stand-in MCP server: it speaks two protocol versions, lists one tool, +// asks the client for its roots on a tool call when the client offered them, +// and writes every message it receives to its log, behind a `started` line. +const STAND_IN = String.raw`#!/usr/bin/env python3 +import json, os, sys +log = open(os.environ['STAND_IN_LOG'], 'a') +log.write('started ' + ' '.join(sys.argv[1:]) + '\n'); log.flush() +SUPPORTED = ['2025-06-18', '2024-11-05'] +def send(obj): + sys.stdout.write(json.dumps(obj) + '\n'); sys.stdout.flush() +roots = False +for line in sys.stdin: + msg = json.loads(line) + log.write(json.dumps(msg) + '\n'); log.flush() + method, id_ = msg.get('method'), msg.get('id') + if method == 'initialize': + asked = msg['params']['protocolVersion'] + roots = 'roots' in msg['params'].get('capabilities', {}) + send({'jsonrpc': '2.0', 'id': id_, 'result': { + 'protocolVersion': asked if asked in SUPPORTED else SUPPORTED[0], + 'capabilities': {'tools': {}}, + 'serverInfo': {'name': 'Playwright', 'version': '0.0.41'}}}) + elif method == 'tools/list': + send({'jsonrpc': '2.0', 'id': id_, 'result': {'tools': [ + {'name': 'browser_navigate', 'inputSchema': {'type': 'object'}}]}}) + elif method == 'tools/call': + found = None + if roots: + send({'jsonrpc': '2.0', 'id': 'srv-roots', 'method': 'roots/list'}) + found = json.loads(sys.stdin.readline()) + log.write(json.dumps(found) + '\n'); log.flush() + text = 'navigated' if found is None else 'navigated with %d roots' % len(found['result']['roots']) + send({'jsonrpc': '2.0', 'id': id_, 'result': {'content': [{'type': 'text', 'text': text}]}}) + elif method == 'ping': + send({'jsonrpc': '2.0', 'id': id_, 'result': {}}) +sys.exit(int(os.environ.get('STAND_IN_EXIT', '0'))) +`; + +const ARGS = ['--headless', '--browser', 'chromium', '--isolated']; + +describe('the start of a turn without the server', () => { + const bin = join(dir, 'stand-in-bin'); + const manifests = join(dir, 'manifests'); + const standInLog = join(dir, 'stand-in.log'); + mkdirSync(bin); + writeFileSync(join(bin, 'mcp-server-playwright'), STAND_IN, { + mode: 0o755, + }); + const baseEnv = { + ...process.env, + PATH: `${bin}:${process.env.PATH ?? ''}`, + TALE_PLAYWRIGHT_MCP_MANIFESTS: manifests, + STAND_IN_LOG: standInLog, + HTTPS_PROXY: '', + NO_PROXY: '', + }; + + // The image build records the manifest. + const argSets = join(dir, 'arg-sets.json'); + writeFileSync(argSets, JSON.stringify([ARGS])); + const written = spawnSync( + python, + ['-Es', launcher, '--write-manifests', argSets], + { env: baseEnv, encoding: 'utf8' }, + ); + + const received = (): string[] => + existsSync(standInLog) + ? readFileSync(standInLog, 'utf8').trim().split('\n') + : []; + + /** A client of the launcher: send lines, await answers by id. */ + function client(env: Record = {}) { + rmSync(standInLog, { force: true }); + const proc = spawn(python, ['-Es', launcher, ...ARGS], { + env: { ...baseEnv, ...env }, + stdio: ['pipe', 'pipe', 'pipe'], + }); + const lines: Array> = []; + const waiters: Array<() => void> = []; + let buffer = ''; + proc.stdout.on('data', (chunk: Buffer) => { + buffer += chunk.toString(); + for ( + let end = buffer.indexOf('\n'); + end !== -1; + end = buffer.indexOf('\n') + ) { + lines.push(JSON.parse(buffer.slice(0, end))); + buffer = buffer.slice(end + 1); + } + for (const wake of waiters.splice(0)) wake(); + }); + const exited = new Promise((done) => { + proc.on('exit', (code) => done(code)); + }); + return { + send(obj: Record) { + proc.stdin.write(`${JSON.stringify(obj)}\n`); + }, + async answer(id: unknown): Promise> { + const until = Date.now() + 10_000; + for (;;) { + const found = lines.find((line) => line.id === id); + if (found !== undefined) return found; + if (Date.now() > until) + throw new Error(`no answer for ${String(id)}`); + await new Promise((wake) => { + waiters.push(wake); + setTimeout(wake, 50); + }); + } + }, + lines, + async close(): Promise { + proc.stdin.end(); + return exited; + }, + }; + } + + const initialize = (protocolVersion: string, capabilities = {}) => ({ + jsonrpc: '2.0', + id: 1, + method: 'initialize', + params: { + protocolVersion, + capabilities, + clientInfo: { name: 'test-client', version: '1' }, + }, + }); + + test('the image build records the server’s answer to each protocol version', () => { + expect(written.status).toBe(0); + const files = readdirSync(manifests).filter((name) => + name.endsWith('.json'), + ); + expect(files).toHaveLength(1); + const manifest = JSON.parse( + readFileSync(join(manifests, files[0] ?? ''), 'utf8'), + ); + expect(manifest.args).toEqual(ARGS); + const spoken = Object.fromEntries( + Object.entries(manifest.initialize).map(([asked, result]) => [ + asked, + typeof result === 'object' && + result !== null && + 'protocolVersion' in result + ? result.protocolVersion + : undefined, + ]), + ); + // A version it speaks is answered with itself, any other with its latest. + expect(spoken).toEqual({ + '2025-11-25': '2025-06-18', + '2025-06-18': '2025-06-18', + '2025-03-26': '2025-06-18', + '2024-11-05': '2024-11-05', + '2024-10-07': '2025-06-18', + }); + expect(manifest.tools['2025-06-18'].tools[0].name).toBe('browser_navigate'); + }); + + test('a known version the server does not speak is answered as the server would, still without it', async () => { + const mcp = client(); + mcp.send(initialize('2025-11-25')); + expect(await mcp.answer(1)).toMatchObject({ + result: { protocolVersion: '2025-06-18' }, + }); + mcp.send({ jsonrpc: '2.0', id: 2, method: 'tools/list' }); + await mcp.answer(2); + expect(await mcp.close()).toBe(0); + expect(received()).toEqual([]); + }); + + test('answers initialize, tools/list and ping without starting the server', async () => { + const mcp = client(); + mcp.send(initialize('2025-06-18')); + expect(await mcp.answer(1)).toMatchObject({ + result: { + protocolVersion: '2025-06-18', + serverInfo: { name: 'Playwright' }, + }, + }); + mcp.send({ jsonrpc: '2.0', method: 'notifications/initialized' }); + mcp.send({ jsonrpc: '2.0', id: 2, method: 'tools/list' }); + expect(await mcp.answer(2)).toMatchObject({ + result: { tools: [{ name: 'browser_navigate' }] }, + }); + mcp.send({ jsonrpc: '2.0', id: 3, method: 'ping' }); + expect(await mcp.answer(3)).toMatchObject({ result: {} }); + expect(await mcp.close()).toBe(0); + expect(received()).toEqual([]); + }); + + test('starts the server on the first tool call, replaying the start to it', async () => { + const mcp = client(); + mcp.send(initialize('2024-11-05')); + await mcp.answer(1); + mcp.send({ jsonrpc: '2.0', method: 'notifications/initialized' }); + mcp.send({ jsonrpc: '2.0', id: 2, method: 'tools/list' }); + await mcp.answer(2); + mcp.send({ + jsonrpc: '2.0', + id: 7, + method: 'tools/call', + params: { name: 'browser_navigate', arguments: { url: 'about:blank' } }, + }); + expect(await mcp.answer(7)).toMatchObject({ + result: { content: [{ text: 'navigated' }] }, + }); + expect(await mcp.close()).toBe(0); + const log = received(); + expect(log[0]).toBe(`started ${ARGS.join(' ')}`); + const seen = log.slice(1).map((line) => JSON.parse(line)); + expect(seen.map((msg) => msg.method)).toEqual([ + 'initialize', + 'notifications/initialized', + 'tools/call', + ]); + // The client's own start, under an id of the launcher's. + expect(seen[0].params.protocolVersion).toBe('2024-11-05'); + expect(seen[0].params.clientInfo.name).toBe('test-client'); + expect(seen[0].id).not.toBe(1); + // Only the client's answers reach the client: one per request it sent. + expect(mcp.lines.map((line) => line.id)).toEqual([1, 2, 7]); + }); + + test('a request of the server and the client’s answer pass through', async () => { + const mcp = client(); + mcp.send(initialize('2025-06-18', { roots: { listChanged: false } })); + await mcp.answer(1); + mcp.send({ jsonrpc: '2.0', method: 'notifications/initialized' }); + mcp.send({ + jsonrpc: '2.0', + id: 4, + method: 'tools/call', + params: { name: 'browser_navigate', arguments: {} }, + }); + const asked = await mcp.answer('srv-roots'); + expect(asked.method).toBe('roots/list'); + mcp.send({ + jsonrpc: '2.0', + id: 'srv-roots', + result: { roots: [{ uri: 'file:///agent/workspace' }] }, + }); + expect(await mcp.answer(4)).toMatchObject({ + result: { content: [{ text: 'navigated with 1 roots' }] }, + }); + await mcp.close(); + }); + + test('a protocol version the manifest has no answer for gets the server at once', async () => { + const mcp = client(); + mcp.send(initialize('2099-01-01')); + expect(await mcp.answer(1)).toMatchObject({ + result: { protocolVersion: '2025-06-18' }, + }); + await mcp.close(); + expect(received()[0]).toBe(`started ${ARGS.join(' ')}`); + expect(JSON.parse(received()[1] ?? '{}').id).toBe(1); + }); + + test('TALE_PLAYWRIGHT_MCP_EAGER=1 starts the server at once', async () => { + const mcp = client({ TALE_PLAYWRIGHT_MCP_EAGER: '1' }); + mcp.send(initialize('2025-06-18')); + await mcp.answer(1); + await mcp.close(); + expect(received()[0]).toBe(`started ${ARGS.join(' ')}`); + }); + + test('once started, the launcher exits with the server’s status', async () => { + const mcp = client({ STAND_IN_EXIT: '7' }); + mcp.send(initialize('2025-06-18')); + await mcp.answer(1); + mcp.send({ + jsonrpc: '2.0', + id: 2, + method: 'tools/call', + params: { name: 'browser_navigate', arguments: {} }, + }); + await mcp.answer(2); + expect(await mcp.close()).toBe(7); + }); }); diff --git a/services/sandbox-runtime/playwright-mcp-args.json b/services/sandbox-runtime/playwright-mcp-args.json new file mode 100644 index 0000000000..7bebdfbc28 --- /dev/null +++ b/services/sandbox-runtime/playwright-mcp-args.json @@ -0,0 +1,20 @@ +[ + [ + "--headless", + "--browser", + "chromium", + "--isolated", + "--no-sandbox", + "--ignore-https-errors" + ], + [ + "--headless", + "--browser", + "chromium", + "--isolated", + "--no-sandbox", + "--ignore-https-errors", + "--image-responses", + "omit" + ] +] diff --git a/services/sandbox-runtime/tale-playwright-mcp b/services/sandbox-runtime/tale-playwright-mcp index 201fd8f0ab..a1653f4695 100755 --- a/services/sandbox-runtime/tale-playwright-mcp +++ b/services/sandbox-runtime/tale-playwright-mcp @@ -1,15 +1,346 @@ -#!/bin/sh -# Playwright MCP launcher: bridge the container egress env to Chromium flags. -# Chromium ignores HTTPS_PROXY/NO_PROXY env vars, and the sandbox network is -# internal-only — without an explicit --proxy-server the browser can only -# reach in-container addresses. Behavior flags (--headless etc.) stay in the -# agent adapters; this shim only does env→flag bridging. -# Playwright force-appends <-loopback> to the Chromium bypass list whenever a -# proxy is set, which overrides the explicit localhost/127.0.0.1 entries below -# (later rules win) and sends loopback traffic to tinyproxy — whose loopback -# is a different container. Disable that so in-container dev servers stay -# reachable from the browser. -export PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK=1 -[ -n "${HTTPS_PROXY:-}" ] && set -- "$@" --proxy-server "$HTTPS_PROXY" -[ -n "${NO_PROXY:-}" ] && set -- "$@" --proxy-bypass "$NO_PROXY" -exec mcp-server-playwright "$@" +#!/usr/bin/env -S python3 -Es +"""Playwright MCP launcher for agent turns. + +Every managed agent turn lists the Playwright MCP server among its tools, but +most turns never open a browser, and the server is a Node process that loads +Playwright as it starts: about 100 MB and a third of a second of CPU, held for +the whole turn. So this launcher answers the start of the conversation itself +— `initialize`, `tools/list`, `ping` — from a manifest recorded from the real +server when the image was built, and starts the real server only when the turn +first asks for anything else (a tool call). It then replays the client's +`initialize` to it and passes every message through, both ways. Where no +manifest matches the server arguments, or the client asks for a protocol +version the manifest has no answer for, the real server starts at once, as it +always did; TALE_PLAYWRIGHT_MCP_EAGER=1 always starts it at once. + +It also bridges the container's egress env to Chromium flags: Chromium ignores +HTTPS_PROXY/NO_PROXY, and the sandbox network is internal-only, so without an +explicit --proxy-server the browser can only reach in-container addresses. +Playwright force-appends <-loopback> to the Chromium bypass list whenever a +proxy is set, which overrides the explicit localhost/127.0.0.1 entries (later +rules win) and sends loopback traffic to tinyproxy, whose loopback is a +different container; that is turned off so in-container dev servers stay +reachable from the browser. Behaviour flags (--headless etc.) stay with the +agent adapters. + + tale-playwright-mcp [SERVER ARGS...] + tale-playwright-mcp --write-manifests ARG_SETS.json (image build) +""" + +import hashlib +import json +import os +import signal +import subprocess +import sys +import threading + +REAL_SERVER = 'mcp-server-playwright' +MANIFEST_DIR = os.environ.get( + 'TALE_PLAYWRIGHT_MCP_MANIFESTS', '/opt/tale/playwright-mcp' +) +# The protocol versions MCP has named. The manifest holds the server's answer +# to a client asking for each of them (its own latest, for one it does not +# speak); a client asking for another gets the real server. +PROBED_VERSIONS = ( + '2025-11-25', + '2025-06-18', + '2025-03-26', + '2024-11-05', + '2024-10-07', +) +# The id of the replayed `initialize`: the client's own ids never reach it. +REPLAYED_INIT_ID = 'tale-playwright-mcp-initialize' +# How long the image build waits for the real server to answer. +PROBE_TIMEOUT_S = 120 + + +def log(message): + sys.stderr.write(f'[tale-playwright-mcp] {message}\n') + sys.stderr.flush() + + +def server_env(): + env = dict(os.environ) + env['PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK'] = '1' + return env + + +def server_argv(args, env): + argv = [REAL_SERVER, *args] + if env.get('HTTPS_PROXY'): + argv += ['--proxy-server', env['HTTPS_PROXY']] + if env.get('NO_PROXY'): + argv += ['--proxy-bypass', env['NO_PROXY']] + return argv + + +def manifest_path(args): + key = hashlib.sha256(json.dumps(args).encode()).hexdigest()[:32] + return os.path.join(MANIFEST_DIR, f'{key}.json') + + +def load_manifest(args): + try: + with open(manifest_path(args), encoding='utf-8') as handle: + manifest = json.load(handle) + except FileNotFoundError: + return None + except (OSError, ValueError) as error: + log(f'manifest unreadable, starting the server at once: {error}') + return None + if manifest.get('args') != args: + return None + return manifest + + +def message(line): + """A JSON-RPC message object from one line, or None.""" + try: + parsed = json.loads(line) + except ValueError: + return None + return parsed if isinstance(parsed, dict) else None + + +def encode(obj): + return json.dumps(obj, separators=(',', ':')).encode() + b'\n' + + +# --- image build: record what the real server answers ---------------------- + + +def probe(argv, env, version): + """The real server's answers to `initialize` (asking for `version`) and + to `tools/list`, from a server of its own.""" + proc = subprocess.Popen( + argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env + ) + timer = threading.Timer(PROBE_TIMEOUT_S, proc.kill) + timer.start() + try: + + def send(obj): + proc.stdin.write(encode(obj)) + proc.stdin.flush() + + def answer(id_): + for line in proc.stdout: + msg = message(line) + if msg is not None and msg.get('id') == id_: + if 'result' not in msg: + raise RuntimeError(f'the server refused: {line!r}') + return msg['result'] + raise RuntimeError('the server closed its output before answering') + + send({ + 'jsonrpc': '2.0', + 'id': 1, + 'method': 'initialize', + 'params': { + 'protocolVersion': version, + 'capabilities': {}, + 'clientInfo': {'name': 'tale-playwright-mcp', 'version': '1'}, + }, + }) + initialize = answer(1) + send({'jsonrpc': '2.0', 'method': 'notifications/initialized'}) + send({'jsonrpc': '2.0', 'id': 2, 'method': 'tools/list'}) + tools = answer(2) + return initialize, tools + finally: + timer.cancel() + try: + proc.stdin.close() + except OSError: + pass + try: + proc.wait(timeout=10) + except subprocess.TimeoutExpired: + proc.kill() + proc.wait() + + +def write_manifests(arg_sets_file): + with open(arg_sets_file, encoding='utf-8') as handle: + arg_sets = json.load(handle) + env = server_env() + os.makedirs(MANIFEST_DIR, exist_ok=True) + for args in arg_sets: + argv = server_argv(args, env) + initialize = {} + tools = {} + for version in PROBED_VERSIONS: + initialize[version], tools[version] = probe(argv, env, version) + path = manifest_path(args) + with open(f'{path}.tmp', 'w', encoding='utf-8') as handle: + json.dump( + {'args': args, 'initialize': initialize, 'tools': tools}, + handle, + ) + os.replace(f'{path}.tmp', path) + spoken = sorted({result.get('protocolVersion') for result in initialize.values()}) + print(f'{path}: {" ".join(args)} (speaks {", ".join(map(str, spoken))})') + + +# --- a turn: answer the start, then pass everything through ---------------- + + +class LazyServer: + def __init__(self, argv, env, manifest): + self.argv = argv + self.env = env + self.manifest = manifest + self.server = None + self.pump = None + self.out = sys.stdout.buffer + self.out_lock = threading.Lock() + # The protocol version answered to the client, once it was. + self.version = None + self.init_params = None + self.client_initialized = False + # Notifications that came before the server: replayed to it. + self.held = [] + + def write(self, data): + try: + with self.out_lock: + self.out.write(data) + self.out.flush() + except (BrokenPipeError, ValueError): + # The client stopped reading: the turn is over. + if self.server is not None and self.server.poll() is None: + self.server.terminate() + os._exit(0) + + def reply(self, id_, result): + self.write(encode({'jsonrpc': '2.0', 'id': id_, 'result': result})) + + def answered(self, msg, line): + """Answer `msg` without the server; False when it needs the server.""" + method = msg.get('method') + has_id = 'id' in msg + if method == 'initialize' and has_id and self.version is None: + params = msg.get('params') + version = params.get('protocolVersion') if isinstance(params, dict) else None + result = self.manifest['initialize'].get(version) if isinstance(version, str) else None + if result is None: + return False + self.version = version + self.init_params = params + self.reply(msg['id'], result) + return True + if self.version is None: + return False + if method == 'notifications/initialized' and not has_id: + self.client_initialized = True + return True + if method == 'ping' and has_id: + self.reply(msg['id'], {}) + return True + if method == 'tools/list' and has_id: + params = msg.get('params') + if not (isinstance(params, dict) and params.get('cursor')): + self.reply(msg['id'], self.manifest['tools'][self.version]) + return True + return False + if isinstance(method, str) and not has_id: + self.held.append(line) + return True + return False + + def start(self): + self.server = subprocess.Popen( + self.argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=self.env + ) + if self.version is not None: + self.send(encode({ + 'jsonrpc': '2.0', + 'id': REPLAYED_INIT_ID, + 'method': 'initialize', + 'params': self.init_params, + })) + for line in self.server.stdout: + msg = message(line) + if msg is not None and msg.get('id') == REPLAYED_INIT_ID: + result = msg.get('result') + spoken = result.get('protocolVersion') if isinstance(result, dict) else None + if spoken != self.version: + log(f'the server speaks {spoken}, the client was told {self.version}') + break + self.write(line) + else: + self.exit_with_server() + if self.client_initialized: + self.send(encode({'jsonrpc': '2.0', 'method': 'notifications/initialized'})) + for line in self.held: + self.send(line) + self.held = [] + self.pump = threading.Thread(target=self.relay_server, daemon=True) + self.pump.start() + + def send(self, data): + try: + self.server.stdin.write(data) + self.server.stdin.flush() + except (BrokenPipeError, ValueError): + self.exit_with_server() + + def relay_server(self): + for line in self.server.stdout: + self.write(line) + self.exit_with_server() + + def exit_with_server(self): + code = self.server.wait() + sys.stderr.flush() + os._exit(code if code >= 0 else 128 - code) + + def run(self): + for line in sys.stdin.buffer: + if self.server is not None: + self.send(line) + continue + msg = message(line) + if msg is None or not self.answered(msg, line): + self.start() + self.send(line) + # The client is gone: so is the turn. + if self.server is None: + os._exit(0) + try: + self.server.stdin.close() + except OSError: + pass + self.pump.join(timeout=10) + if self.server.poll() is None: + self.server.terminate() + self.exit_with_server() + + def stop(self, signum, _frame): + if self.server is not None and self.server.poll() is None: + self.server.send_signal(signum) + os._exit(128 + signum) + + +def main(): + args = sys.argv[1:] + if args[:1] == ['--write-manifests'] and len(args) == 2: + write_manifests(args[1]) + return + env = server_env() + argv = server_argv(args, env) + manifest = None + if env.get('TALE_PLAYWRIGHT_MCP_EAGER') != '1': + manifest = load_manifest(args) + if manifest is None: + os.execvpe(REAL_SERVER, argv, env) + lazy = LazyServer(argv, env, manifest) + signal.signal(signal.SIGTERM, lazy.stop) + signal.signal(signal.SIGINT, lazy.stop) + signal.signal(signal.SIGHUP, lazy.stop) + lazy.run() + + +if __name__ == '__main__': + main() From 55eb1fa9c3ce1a5904611a333735cfe25c60b12d Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 10:16:09 +0200 Subject: [PATCH 2/4] test(sandbox): check the image's Playwright MCP starts on the first tool call Under the session container contract, the launcher with the platform's first argument set answers initialize and tools/list while no mcp-server-playwright process runs, its tool list equals the server's own, and a browser_navigate reaches the server it starts then. --- .../container-sandbox-runtime-test.ts | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/services/platform/tests/integration/container-sandbox-runtime-test.ts b/services/platform/tests/integration/container-sandbox-runtime-test.ts index 436c502f5b..e95c5619b8 100644 --- a/services/platform/tests/integration/container-sandbox-runtime-test.ts +++ b/services/platform/tests/integration/container-sandbox-runtime-test.ts @@ -690,6 +690,97 @@ send({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: ' } } +console.log(''); +console.log('--- playwright MCP starts only when a turn uses the browser ---'); +// The launcher answers the start of a turn from the manifests the image build +// recorded for the platform's argument sets (playwright-mcp-args.json): the +// real server, a Node process holding ~100 MB, must not run until the first +// tool call, its tool list must be the server's own, and a tool call must +// reach a server started then. +{ + const nodeScript = `const { spawn, execFileSync } = require('child_process'); +const args = JSON.parse(require('fs').readFileSync('/opt/tale/playwright-mcp/args.json', 'utf8'))[0]; +const serverRunning = () => { + try { execFileSync('pgrep', ['-f', 'bin/mcp-server-playwright']); return true; } catch { return false; } +}; +function session(command, argv) { + const srv = spawn(command, argv, { stdio: ['pipe', 'pipe', 'inherit'] }); + const waiting = new Map(); + let buf = ''; + srv.stdout.on('data', (d) => { + buf += d.toString(); + let idx; + while ((idx = buf.indexOf('\\n')) >= 0) { + const line = buf.slice(0, idx); buf = buf.slice(idx + 1); + let msg; try { msg = JSON.parse(line); } catch { continue; } + const done = waiting.get(msg.id); + if (done) { waiting.delete(msg.id); done(msg); } + } + }); + const ask = (id, method, params) => new Promise((resolve) => { + waiting.set(id, resolve); + srv.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, ...(params ? { params } : {}) }) + '\\n'); + }); + const tell = (method) => srv.stdin.write(JSON.stringify({ jsonrpc: '2.0', method }) + '\\n'); + return { srv, ask, tell }; +} +const init = { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'conformance', version: '1.0' } }; +(async () => { + const deadline = setTimeout(() => { console.error('LAZY_TIMEOUT'); process.exit(1); }, 90000); + const lazy = session('tale-playwright-mcp', args); + await lazy.ask(1, 'initialize', init); + lazy.tell('notifications/initialized'); + const listed = await lazy.ask(2, 'tools/list'); + if (serverRunning()) { console.error('LAZY_SERVER_STARTED_EARLY'); process.exit(1); } + const direct = session('mcp-server-playwright', args); + await direct.ask(1, 'initialize', init); + direct.tell('notifications/initialized'); + const own = await direct.ask(2, 'tools/list'); + direct.srv.kill(); + if (JSON.stringify(listed.result) !== JSON.stringify(own.result)) { console.error('LAZY_TOOLS_DIFFER'); process.exit(1); } + const called = await lazy.ask(3, 'tools/call', { name: 'browser_navigate', arguments: { url: 'about:blank' } }); + if (called.error || (called.result && called.result.isError)) { console.error('LAZY_NAVIGATE_FAILED ' + JSON.stringify(called)); process.exit(1); } + clearTimeout(deadline); + console.log('MCP_LAZY_OK ' + listed.result.tools.length); + lazy.srv.kill(); + process.exit(0); +})().catch((error) => { console.error(error); process.exit(1); }); +`; + const { combined } = await capture( + [ + 'docker', + 'run', + '--rm', + '-i', + '--user', + '10001', + '--read-only', + '--tmpfs', + '/tmp:exec,nosuid,nodev,size=256m', + '--tmpfs', + '/workspace:uid=10001,gid=10001', + '--shm-size=512m', + '--env', + 'HOME=/workspace/.home', + '--env', + 'TMPDIR=/workspace/.tmp', + '--entrypoint', + 'sh', + IMAGE, + '-c', + 'mkdir -p "$HOME" "$TMPDIR" && exec node -', + ], + { stdin: nodeScript }, + ); + if (combined.includes('MCP_LAZY_OK')) { + pass( + 'playwright MCP answers the start itself and starts the server on the first tool call', + ); + } else { + fail(`playwright MCP lazy start failed (got: ${combined.slice(0, 400)})`); + } +} + console.log(''); console.log('--- runnerd boots under the daemon entrypoint ---'); // Start the daemon (PID 1 via the image entrypoint `daemon` arg) and probe From e4aaf3c7037731b4f0a29675065a9e268488ce6c Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 10:16:20 +0200 Subject: [PATCH 3/4] test(sandbox): rerun the daemon's tests when a runtime wrapper changes The daemon's suite tests the wrappers beside it (tale-*-run, tale-playwright-mcp, tale-connectors-mcp, the hooks, entrypoint.sh), but its cache key held only the daemon workspace, so a change to a wrapper alone could replay a stale pass. Its test task now hashes them. --- services/sandbox-runtime/daemon/turbo.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 services/sandbox-runtime/daemon/turbo.json diff --git a/services/sandbox-runtime/daemon/turbo.json b/services/sandbox-runtime/daemon/turbo.json new file mode 100644 index 0000000000..fb51027775 --- /dev/null +++ b/services/sandbox-runtime/daemon/turbo.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://turbo.build/schema.v2.json", + "extends": ["//"], + "tasks": { + "test": { + "inputs": [ + "$TURBO_EXTENDS$", + "$TURBO_DEFAULT$", + "$TURBO_ROOT$/services/sandbox-runtime/entrypoint.sh", + "$TURBO_ROOT$/services/sandbox-runtime/playwright-mcp-args.json", + "$TURBO_ROOT$/services/sandbox-runtime/tale-*" + ] + } + } +} From 597865f925f6a93ee30fe46ddedc87dd428bc80c Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 10:16:25 +0200 Subject: [PATCH 4/4] docs(manual): record the lazy Playwright MCP checks A ledger row for the launcher: the start answered from the build's manifests, the server started and the start replayed on the first other request, pass-through both ways, the eager fallbacks, and where each is automated. --- services/platform/tests/manual/reference/automation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/services/platform/tests/manual/reference/automation.md b/services/platform/tests/manual/reference/automation.md index 62627fadf7..f7c6711ac9 100644 --- a/services/platform/tests/manual/reference/automation.md +++ b/services/platform/tests/manual/reference/automation.md @@ -189,6 +189,7 @@ Legend: ✅ fully automated · 🔶 partially automated · ⛔ manual-only (no s | [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | A managed Claude Code agent turn on a model that is not Claude names its exec in every request (`ANTHROPIC_CUSTOM_HEADERS: x-bf-eh-x-tale-cache-affinity: `, which the gateway forwards upstream as `X-Tale-Cache-Affinity`), keeping any header the harness already sends; a Claude model, an exec without an id and a bring-your-own credential send none | 🔶 backend | `lib/harnesses/exec-builder.test.ts`; whether a multi-replica balancer keeps the turn on one replica is a deployment check | | [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | A managed harness turn that ends cleanly with nothing at all from its model (no text, no tool call, no output tokens: the empty 200 a serving cluster answers when it fails mid-prefill) settles failed with “The model returned an empty answer, so the agent did nothing this turn.”: an automation `agent` node as a retryable `harness_error`, a task run on the retryable `empty_turn` path with its conversation handle kept, and a resumed task start is not taken for a dead handle. A turn that only called tools (the operator question included) or only reported output tokens (a reasoning-only turn, for one) is not empty; Claude Code's turn totals come from its result | 🔶 backend | `backend/core/chat/external_turn_shared.test.ts`, `lib/harnesses/parsers/claude-stream-json.test.ts` (the pinned-CLI `empty-answer-turn`, `token-only-turn` and `thinking-only-turn` captures), `backend/core/automations/agent_host.empty_answer.test.ts`, `backend/core/tasks/agent_run_host.empty_answer.test.ts`; a live empty answer from a failing model server stays a deployment check | | [projects](../suites/projects.md) | Runtime image carries every managed harness (Qwen Code included) | ✅ automated | `tests/integration/container-sandbox-runtime-test.ts` (registry-driven: every `managed: true` harness's exec binary on the agent PATH), `services/sandbox-runtime/daemon/src/tale-qwen-run.test.ts`, `tale-hermes-run.test.ts` (returned SDK failures end as errors; resume restores the stored conversation) | +| [projects](../suites/projects.md) / [tasks](../suites/tasks.md) | A managed agent turn that never opens a browser never starts the Playwright MCP server (a Node process holding ~100 MB): the launcher answers `initialize` — as the server would for every protocol version MCP has named, the server's latest for one it does not speak — `tools/list` and `ping` from manifests the image build records for the platform's argument sets, starts the server on the first other request, replaying the client's start under an id of its own, and passes every message through both ways (a server request and the client's answer included); unknown arguments or protocol versions and `TALE_PLAYWRIGHT_MCP_EAGER=1` start the server at once; the platform's argument sets and the image's record are held equal | ✅ automated | `services/sandbox-runtime/daemon/src/tale-playwright-mcp.test.ts` (a stand-in server: the build's manifest, the start answered without it, the start replayed on the first tool call, a roots request round trip, an unknown version and the eager switch, the exit status, the proxy flags), `tests/integration/container-sandbox-runtime-test.ts` (the image's own server: not running after `tools/list`, the same tool list as the server's, a `browser_navigate` through the server started then), `lib/harnesses/exec-builder.test.ts` (the argument sets) | | [settings](../suites/settings.md) / [tasks](../suites/tasks.md) | An exec's leftover processes are ended: what its command backgrounded (`cmd &`, `nohup`, a descendant in a session of its own) gets SIGTERM, then SIGKILL, when the command exits — or, while another exec of the session still runs, when the session's last running exec ends — and at once on a cancel or at the deadline (what an exited exec left waiting included, and the group SIGKILL while the exec's own process runs even when no process there shows the tag); leftovers that wait keep their output pipes; the exit is reported without waiting out the drain grace; each process is signalled once (the group as a whole, on its own only a tagged process that left it), and a group whose tagged processes all left is never signalled later; a dropped attach releases its subscriber and its active operation; a session stop passes SIGTERM on to every live exec and to what exited execs left waiting; a group known to be the exec's gets its signal before the process table is read, a scan answers with what it read after two seconds and skips a process whose read never came back, and runnerd ends itself by SIGKILL while such a read is out; a leftover that stayed in the exec's group without the tag is still reached through the group's recorded processes (pid and start time) once it waited, and by the SIGKILL after an exec that ended alone; a steer's restart cancels the old exec as a rotation (`?leftovers=keep`, passed on by the spawner): only its own group ends, what it left outside is held until an exec started after it ends (a later cancel of the old exec leaves it held; with no successor within ten minutes the hold lifts), and a Stop or a crash still ends everything; a cancelled Gemini, Qwen or Pi turn removes its staged settings and context file, and a second signal does not cut that cleanup short; every exec runs under the subreaper shim (`tale-exec-shim`), so a process that left the exec's group and session and replaced its environment is still found below it and ended, and a round whose every exec still has its shim reads `stat` alone; the shim's status pipe gives the command's group, its exit status (128 + N for signal N) or why it could not run, the shim's own exit standing in only when the pipe ended without one; a cancel that comes before the shim named the group signals the group once it does; a refused subreaper is logged once and the exec falls back to group and tag | ✅ automated | `services/sandbox-runtime/daemon/src/exec-manager.test.ts` (exec tag in the environment, background child ended at exit and on cancel, one SIGTERM per cancel, an untagged leader still SIGKILLed, leftovers kept while another exec runs and keeping their pipes, a cancel during the drain, the daemon's stop of live and waiting execs, the leftover prune, a `setsid` descendant found by its tag on Linux, a dropped consumer settles its attach), `process-reaper.test.ts` (tag and process-group match, one signal per process, no stale group, one scan per round, init and runnerd never, a known group signalled before a hanging read, the scan deadline and the skipped stalled read, the stat-only group record, a recorded member's proof and a reused pid's none, a shim's descendants whatever their group, session or tag, a stat-only scan while every shim runs, the tag again once a shim has exited, an unreadable environment still walked through), `exec-shim.test.ts` (on Linux the shim built from its source: output and exit status, 128 + N for a signal, a spawn error, a `setsid env -i` escapee ended with its exec, while another exec runs and after a rotation, and out of reach without the shim, a cancel before the group is named; everywhere, stand-in shims for the status pipe: its exit over the shim's, a killed shim, a spawn error, a refused subreaper said once), `tests/integration/container-sandbox-runtime-test.ts` (the image's runnerd names its shim and ends an escapee), `daemon-exit.test.ts` (the SIGKILL exit while a read is out, under Node), `main.test.ts` (`?leftovers=keep` over HTTP on Linux), `harness-wrapper-cancel.test.ts` (each wrapper's staged files removed after one and after two signals); the rotation in `exec-manager.test.ts` (the group ended, the held server ended once the next exec ends, a hold outlasting an earlier exec and a late cancel, a `setsid` server on Linux) and the untagged in-group leftover after a deferral and after an exec that ended alone (Linux); `services/sandbox/src/server.test.ts` + `services/sandbox/src/session/session-routes.test.ts` (the flag reaches runnerd); `backend/core/node_only/sandbox/helpers/session_client.test.ts` (the query) and `backend/core/tasks/agent_run_host.reap.test.ts` (the restart lane rotates, a Stop and a crash cancel in full) | | [projects](../suites/projects.md) / [tasks](../suites/tasks.md) | A Gemini CLI agent on a model whose id ends in "flash" (`deepseek-flash`, `glm-5.3-flash`, `qwen3.6-flash`, OpenRouter `google/gemini-3.5-flash`, …) requests that model, not the CLI's own gemini-3.5-flash | ✅ automated | `lib/harnesses/exec-builder.test.ts` (the gemini exec carries `experimental.dynamicModelConfiguration` on both lanes and passes `--model` verbatim), `lib/harnesses/golden-exec.test.ts`, `tests/integration/container-sandbox-runtime-test.ts` (the pinned CLI through `tale-gemini-run` against a loopback gateway stand-in keeps a flash-suffixed id in the request path; the control run without the setting still shows the rewrite) | | [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | `TASK-F35` (the image half): runnerd links every built-in skill baked into the runtime image into each harness's native user-level skill directory (`.claude/skills`, `.agents/skills`, `.hermes/skills`), keeping a directory or live link of someone's own; before every exec it withdraws the link beside a same-named skill the workspace repository ships in `.claude/skills` or `.agents/skills`, and restores it once the repository drops it. Every managed harness names `visual-aspect-analyzer` in its first model request, and with a repository copy in both directories lists that copy (Hermes, which reads no project skills, keeps the baked one) | 🔶 image + stub model | `services/sandbox-runtime/daemon/src/baked-skills.test.ts`, `exec-manager.test.ts` (the reconcile runs before each spawn), `tests/integration/container-sandbox-runtime-test.ts` (every registry harness has a directory; each managed harness's golden exec through runnerd against a request-recording stub; links withdrawn and restored); a live model reading and running the skill stays `TASK-F35` |