GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(server): let users withhold browser access from agents by juliusmarminge · Pull Request #7083 · pingdotgg/t3code

feat(server): let users withhold browser access from agents #7083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 4 commits into main from browser-agent-access
Aug 17, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(server): let users withhold browser access from agents #7083

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
5e93541
feat(server): let users withhold browser access from agents
juliusmarminge Aug 15, 2026
9989fdf
test(server): cover the agent browser access gate
juliusmarminge Aug 15, 2026
324e3be
fix(server): revoke the MCP credential when agent browser access is w…
juliusmarminge Aug 16, 2026
0d31f11
fix(web): include agent browser access in Restore defaults
juliusmarminge Aug 17, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

32 changes: 26 additions & 6 deletions 32 apps/server/src/provider/CodexDeveloperInstructions.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ For browser work, first call \`preview_status\`. If no automation-capable previe
Do not switch to global browser skills, Chrome, Node REPL browser automation, standalone Playwright, or agent-browser merely because the preview is initially closed or a first call fails. Use an alternative browser system only when the T3 preview tools are absent, the user explicitly requests another browser, or \`preview_open\` returns an explicit unsupported/unavailable error. A failed T3 preview tool call should be inspected and retried with corrected arguments when the error is actionable.
`;

export const CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS = `<collaboration_mode># Plan Mode (Conversational)
/**
* The browser block is omitted entirely when the preview tools aren't attached.
* Describing `preview_*` tools that aren't in the turn's tool list would be
* worse than saying nothing: the instructions actively steer the model away
* from Playwright and agent-browser, so leaving them in would talk it out of
* the only browser automation it still has.
*/
const browserToolInstructions = (browserToolsAvailable: boolean): string =>
browserToolsAvailable ? T3_CODE_BROWSER_TOOL_INSTRUCTIONS : "";

export const codexPlanModeDeveloperInstructions = (
browserToolsAvailable: boolean,
): string => `<collaboration_mode># Plan Mode (Conversational)

You work in 3 phases, and you should *chat your way* to a great plan before finalizing it. A great plan is very detailed-intent- and implementation-wise-so that it can be handed to another engineer or agent to be implemented right away. It must be **decision complete**, where the implementer does not need to make any decisions.

Expand Down Expand Up @@ -139,10 +151,12 @@ Do not ask "should I proceed?" in the final output. The user can easily switch o
Only produce at most one \`<proposed_plan>\` block per turn, and only when you are presenting a complete spec.

If the user stays in Plan mode and asks for revisions after a prior \`<proposed_plan>\`, any new \`<proposed_plan>\` must be a complete replacement. If the user indicates that the prior plan is not acceptable but does not provide enough information to produce a complete replacement, address the concern and continue planning without producing a \`<proposed_plan>\` block. If the follow-up neither requires changes nor calls the plan into question (e.g. clarifying question), answer it before the block, then reproduce the prior \`<proposed_plan>\` unchanged.
${T3_CODE_BROWSER_TOOL_INSTRUCTIONS}
${browserToolInstructions(browserToolsAvailable)}
</collaboration_mode>`;

export const CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS = `<collaboration_mode># Collaboration Mode: Default
export const codexDefaultModeDeveloperInstructions = (
browserToolsAvailable: boolean,
): string => `<collaboration_mode># Collaboration Mode: Default

You are now in Default mode. Any previous instructions for other modes (e.g. Plan mode) are no longer active.

Expand All @@ -153,7 +167,7 @@ Your active mode changes only when new developer instructions with a different \
Use the \`request_user_input\` tool only when it is listed in the available tools for this turn.

In Default mode, strongly prefer making reasonable assumptions and executing the user's request rather than stopping to ask questions. If you absolutely must ask a question because the answer cannot be discovered from local context and a reasonable assumption would be risky, ask the user directly with a concise plain-text question. Never write a multiple choice question as a textual assistant message.
${T3_CODE_BROWSER_TOOL_INSTRUCTIONS}
${browserToolInstructions(browserToolsAvailable)}
</collaboration_mode>`;

export interface CodexRuntimeInfo {
Expand All @@ -169,11 +183,17 @@ function toSingleLine(value: string): string {
export function buildCodexDeveloperInstructions(
interactionMode: ProviderInteractionMode,
runtime: CodexRuntimeInfo,
/**
* Whether the `t3-code` MCP server is attached to this turn. Callers derive
* it from the session's actual MCP configuration rather than re-reading the
* setting, so the prompt cannot claim tools the turn doesn't have.
*/
browserToolsAvailable = true,
): string {
const base =
interactionMode === "plan"
? CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS
: CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS;
? codexPlanModeDeveloperInstructions(browserToolsAvailable)
: codexDefaultModeDeveloperInstructions(browserToolsAvailable);
return `${base}

<runtime_info>In case you're asked: you are running in T3 Code through the Codex harness, as ${toSingleLine(runtime.model)} with ${toSingleLine(runtime.reasoningEffort)} reasoning effort. No need to mention this otherwise.</runtime_info>`;
Expand Down
38 changes: 32 additions & 6 deletions 38 apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import * as EffectCodexSchema from "effect-codex-app-server/schema";

import {
buildCodexDeveloperInstructions,
CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
codexDefaultModeDeveloperInstructions,
codexPlanModeDeveloperInstructions,
} from "../CodexDeveloperInstructions.ts";
import { codexSessionAppServerArgs } from "./codexLaunchArgs.ts";
import {
Expand Down Expand Up @@ -255,7 +255,7 @@ describe("buildCodexDeveloperInstructions", () => {
reasoningEffort: "high",
});

NodeAssert.ok(instructions.startsWith(CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS));
NodeAssert.ok(instructions.startsWith(codexDefaultModeDeveloperInstructions(true)));
NodeAssert.match(instructions, /T3 Code/);
NodeAssert.match(instructions, /Codex harness/);
NodeAssert.match(instructions, /as gpt-5\.3-codex with high reasoning effort/);
Expand All @@ -267,7 +267,7 @@ describe("buildCodexDeveloperInstructions", () => {
reasoningEffort: "medium",
});

NodeAssert.ok(instructions.startsWith(CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS));
NodeAssert.ok(instructions.startsWith(codexPlanModeDeveloperInstructions(true)));
NodeAssert.match(instructions, /as gpt-5\.3-codex with medium reasoning effort/);
});

Expand Down Expand Up @@ -298,15 +298,41 @@ describe("buildCodexDeveloperInstructions", () => {
describe("T3 browser developer instructions", () => {
it("prefers the product-native preview tools in both collaboration modes", () => {
for (const instructions of [
CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
codexDefaultModeDeveloperInstructions(true),
codexPlanModeDeveloperInstructions(true),
]) {
NodeAssert.match(instructions, /t3-code/);
NodeAssert.match(instructions, /preview_status/);
NodeAssert.match(instructions, /preview_open/);
NodeAssert.match(instructions, /Do not switch to global browser skills/);
}
});

it("omits the browser block entirely when the preview tools are not attached", () => {
for (const instructions of [
codexDefaultModeDeveloperInstructions(false),
codexPlanModeDeveloperInstructions(false),
]) {
NodeAssert.doesNotMatch(instructions, /preview_status/);
NodeAssert.doesNotMatch(instructions, /preview_open/);
NodeAssert.doesNotMatch(instructions, /T3 Code collaborative browser/);
// Steering away from other browser automation must go with the tools;
// keeping it would leave the model talked out of its only option.
NodeAssert.doesNotMatch(instructions, /Do not switch to global browser skills/);
// The rest of the collaboration mode is untouched.
NodeAssert.match(instructions, /<collaboration_mode>/);
NodeAssert.match(instructions, /<\/collaboration_mode>/);
}
});

it("tracks the turn's MCP configuration rather than defaulting to on", () => {
const runtime = { model: "gpt-5.3-codex", reasoningEffort: "high" };
NodeAssert.match(buildCodexDeveloperInstructions("default", runtime, true), /preview_open/);
NodeAssert.doesNotMatch(
buildCodexDeveloperInstructions("default", runtime, false),
/preview_open/,
);
});
});

describe("hasConfiguredMcpServer", () => {
Expand Down
17 changes: 13 additions & 4 deletions 17 apps/server/src/provider/Layers/CodexSessionRuntime.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ function buildCodexCollaborationMode(input: {
readonly interactionMode?: ProviderInteractionMode;
readonly model?: string;
readonly effort?: EffectCodexSchema.V2TurnStartParams__ReasoningEffort;
readonly browserToolsAvailable?: boolean;
}): EffectCodexSchema.V2TurnStartParams__CollaborationMode | undefined {
if (input.interactionMode === undefined) {
return undefined;
Expand All @@ -351,10 +352,11 @@ function buildCodexCollaborationMode(input: {
settings: {
model,
reasoning_effort: reasoningEffort,
developer_instructions: buildCodexDeveloperInstructions(input.interactionMode, {
model,
reasoningEffort,
}),
developer_instructions: buildCodexDeveloperInstructions(
input.interactionMode,
{ model, reasoningEffort },
input.browserToolsAvailable ?? true,
),
},
};
}
Expand All @@ -371,6 +373,8 @@ export function buildTurnStartParams(input: {
readonly serviceTier?: CodexServiceTier;
readonly effort?: EffectCodexSchema.V2TurnStartParams__ReasoningEffort;
readonly interactionMode?: ProviderInteractionMode;
/** Defaults to true so callers that predate the agent-access gate are unchanged. */
readonly browserToolsAvailable?: boolean;
}): Effect.Effect<
CodexTurnStartParamsWithCollaborationMode,
CodexErrors.CodexAppServerProtocolParseError
Expand All @@ -391,6 +395,7 @@ export function buildTurnStartParams(input: {
...(input.interactionMode ? { interactionMode: input.interactionMode } : {}),
...(input.model ? { model: input.model } : {}),
...(input.effort ? { effort: input.effort } : {}),
browserToolsAvailable: input.browserToolsAvailable ?? true,
});

return decodeCodexTurnStartParamsWithCollaborationMode({
Expand Down Expand Up @@ -1822,6 +1827,10 @@ export const makeCodexSessionRuntime = (
...(input.serviceTier ? { serviceTier: input.serviceTier } : {}),
...(input.effort ? { effort: input.effort } : {}),
...(input.interactionMode ? { interactionMode: input.interactionMode } : {}),
// Derived from the session's own MCP configuration rather than the
// setting, so the prompt describes the tools this turn actually
// has even if the setting changed after the session started.
browserToolsAvailable: hasConfiguredMcpServer(options.appServerArgs),
Comment thread

@macroscopeapp macroscopeapp Bot Aug 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

🟡 Medium Layers/CodexSessionRuntime.ts:1833

When MCP is configured through launchArgs, the spawned session has the preview_* tools but the generated developer instructions omit them because this check reads only options.appServerArgs. Use the resolved appServerArgs value here.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/provider/Layers/CodexSessionRuntime.ts around line 1833:

When MCP is configured through `launchArgs`, the spawned session has the `preview_*` tools but the generated developer instructions omit them because this check reads only `options.appServerArgs`. Use the resolved `appServerArgs` value here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
});
const rawResponse = yield* client.raw.request("turn/start", params);
const response = yield* decodeV2TurnStartResponse(rawResponse).pipe(
Expand Down
90 changes: 89 additions & 1 deletion 90 apps/server/src/provider/Layers/ProviderService.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
} from "@t3tools/contracts";
import {
ApprovalRequestId,
EnvironmentId,
EventId,
ProviderDriverKind,
ProviderInstanceId,
Expand All @@ -20,7 +21,7 @@ import {
TurnId,
} from "@t3tools/contracts";
import { createModelSelection } from "@t3tools/shared/model";
import { it, assert, vi } from "@effect/vitest";
import { it, assert, describe, vi } from "@effect/vitest";

import * as Effect from "effect/Effect";
import * as Exit from "effect/Exit";
Expand Down Expand Up @@ -1957,3 +1958,90 @@ validation.layer("ProviderServiceLive validation", (it) => {
}),
);
});

describe("agent browser access", () => {
const revokedThreads: Array<ThreadId> = [];

const startSessionWith = (enableAgentBrowserAccess: boolean, threadId: ThreadId) =>
Effect.gen(function* () {
const issued: Array<ThreadId> = [];
const codex = makeFakeCodexAdapter();
const providerAdapterLayer = Layer.succeed(
ProviderAdapterRegistry.ProviderAdapterRegistry,
makeAdapterRegistryMock({ [CODEX_DRIVER]: codex.adapter }),
);
const runtimeRepositoryLayer = ProviderSessionRuntime.layer.pipe(
Layer.provide(SqlitePersistenceMemory),
);
const directoryLayer = ProviderSessionDirectoryLive.pipe(
Layer.provide(runtimeRepositoryLayer),
);
const providerLayer = makeProviderServiceLive({
issueMcpCredential: (request) =>
Effect.sync(() => {
issued.push(request.threadId);
return undefined;
}),
revokeMcpCredential: (revoked) => Effect.sync(() => void revokedThreads.push(revoked)),
}).pipe(
Layer.provide(providerAdapterLayer),
Layer.provide(directoryLayer),
Layer.provide(ServerSettings.ServerSettingsService.layerTest({ enableAgentBrowserAccess })),
Layer.provide(serverConfigTestLayer),
Layer.provide(AnalyticsService.layerTest),
Layer.provide(
Layer.succeed(
ProviderEventLoggers.ProviderEventLoggers,
ProviderEventLoggers.NoOpProviderEventLoggers,
),
),
);

yield* Effect.gen(function* () {
const provider = yield* ProviderService.ProviderService;
return yield* provider.startSession(threadId, {
provider: CODEX_DRIVER,
providerInstanceId: codexInstanceId,
threadId,
runtimeMode: "full-access",
});
}).pipe(Effect.provide(providerLayer));

return issued;
});

// Credential issuance is the observable that matters: it is the only place a
// credential is minted, and `/mcp` accepts nothing else, so withholding it is
// what actually denies every provider and external MCP client.
it.effect("requests no MCP credential when agent browser access is off", () =>
Effect.gen(function* () {
const issued = yield* startSessionWith(false, asThreadId("thread-browser-off"));

assert.deepEqual(issued, []);
}).pipe(Effect.provide(NodeServices.layer)),
);

it.effect("revokes an already-issued credential when access is off", () =>
Effect.gen(function* () {
const threadId = asThreadId("thread-browser-revoke");
revokedThreads.length = 0;

yield* startSessionWith(false, threadId);

// Clearing the in-memory map is not enough: a token issued before the
// toggle flipped stays valid against `/mcp` for its whole liveness
// window, and later turns refresh it.
assert.deepEqual(revokedThreads, [threadId]);
}).pipe(Effect.provide(NodeServices.layer)),
);

it.effect("requests an MCP credential when agent browser access is on", () =>
Effect.gen(function* () {
const threadId = asThreadId("thread-browser-on");

const issued = yield* startSessionWith(true, threadId);

assert.deepEqual(issued, [threadId]);
}).pipe(Effect.provide(NodeServices.layer)),
);
});
66 changes: 59 additions & 7 deletions 66 apps/server/src/provider/Layers/ProviderService.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import * as ProviderEventLoggers from "./ProviderEventLoggers.ts";
import * as AnalyticsService from "../../telemetry/AnalyticsService.ts";
import * as McpProviderSession from "../../mcp/McpProviderSession.ts";
import * as McpSessionRegistry from "../../mcp/McpSessionRegistry.ts";
import * as ServerSettings from "../../serverSettings.ts";
const isModelSelection = Schema.is(ModelSelection);

/**
Expand All @@ -66,6 +67,15 @@ const isModelSelection = Schema.is(ModelSelection);
*/
export interface ProviderServiceLiveOptions {
readonly canonicalEventLogger?: EventNdjsonLogger;
/**
* Overrides MCP credential issuance. The real issuer reads a module-global
* registry that only a running MCP server installs, which makes the
* agent-browser-access gate unobservable from a unit test; this seam lets a
* test see whether a credential was requested at all.
*/
readonly issueMcpCredential?: typeof McpSessionRegistry.issueActiveMcpCredential;
/** Same seam as `issueMcpCredential`, for observing the deny path's revoke. */
readonly revokeMcpCredential?: typeof McpSessionRegistry.revokeActiveMcpThread;
}

type ProviderServiceMethod<Name extends keyof ProviderService.ProviderService["Service"]> =
Expand Down Expand Up @@ -215,16 +225,58 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (

const registry = yield* ProviderAdapterRegistry.ProviderAdapterRegistry;
const directory = yield* ProviderSessionDirectory.ProviderSessionDirectory;
const serverSettings = yield* ServerSettings.ServerSettingsService;
const issueMcpCredential =
options?.issueMcpCredential ?? McpSessionRegistry.issueActiveMcpCredential;
const revokeMcpCredential =
options?.revokeMcpCredential ?? McpSessionRegistry.revokeActiveMcpThread;
const runtimeEventPubSub = yield* PubSub.unbounded<ProviderRuntimeEvent>();
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
/**
* Attach the `t3-code` MCP server to the session that is about to start.
*
* This is the only place a credential is minted, so withholding one here is
* what disables agent browser access everywhere: every adapter already
* treats a missing session as "no MCP server", and the `/mcp` endpoint
* accepts nothing but tokens issued from this path.
*/
/**
* Deny on an unreadable settings file rather than letting the read failure
* escape: adding `ServerSettingsError` to `ProviderServiceError` would widen
* a union every caller handles, for a branch that only decides whether one
* optional toolset is attached. Denying is the safe direction — an explicit
* "off" silently becoming "on" would violate the user's stated choice,
* whereas the reverse costs an agent one toolset and is visible immediately.
*/
const agentBrowserAccessEnabled = serverSettings.getSettings.pipe(
Effect.map((settings) => settings.enableAgentBrowserAccess),
Effect.catch((cause) =>
Effect.logWarning(
"Could not read server settings; withholding agent browser access for this session.",
{ cause },
).pipe(Effect.as(false)),
),
);

const prepareMcpSession = (threadId: ThreadId, providerInstanceId: ProviderInstanceId) =>
McpSessionRegistry.issueActiveMcpCredential({ threadId, providerInstanceId }).pipe(
Effect.tap((credential) =>
credential
? Effect.sync(() => McpProviderSession.setMcpProviderSession(credential.config))
: Effect.void,
),
);
Effect.gen(function* () {
if (!(yield* agentBrowserAccessEnabled)) {
Comment thread

@macroscopeapp macroscopeapp Bot Aug 15, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is a backend behavior change (a session may now start with no MCP credential, and a stale provider session is cleared), but the only new tests cover prompt text in CodexSessionRuntime.test.ts. Consider adding a focused test in ProviderService.test.ts using ServerSettings.ServerSettingsService.layerTest({ enableAgentBrowserAccess: false }) asserting that startSession issues no credential and clears the thread's MCP provider session, plus the enabled counterpart — the existing suite already wires a test settings layer, so it is a small addition.

Posted via Macroscope — Effect Service Conventions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
// Revoke as well as clear. Every other prepare path reaches
// `issueActiveMcpCredential`, which revokes the thread first, so
// skipping it here would leave a previously issued bearer token valid
// against `/mcp` for the rest of its liveness window — and later turns
// would keep refreshing it. A session restart (runtime mode, cwd,
// model) re-prepares without stopping, so it relies on this.
yield* revokeMcpCredential(threadId);
yield* Effect.sync(() => McpProviderSession.clearMcpProviderSession(threadId));
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

return undefined;
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

}
const credential = yield* issueMcpCredential({ threadId, providerInstanceId });
if (credential) {
yield* Effect.sync(() => McpProviderSession.setMcpProviderSession(credential.config));
}
return credential;
});
const clearMcpSession = (threadId: ThreadId) =>
McpSessionRegistry.revokeActiveMcpThread(threadId).pipe(
Effect.tap(() => Effect.sync(() => McpProviderSession.clearMcpProviderSession(threadId))),
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.