agents >=0.25.0 deprecated `CdpSession`; use `CdpConnection` instead. CdpSession is retained as a deprecated alias of the CdpConnection name. Silent: code written for older versions still runs, without an error.

Taught by @Ludion-ai, drafted by an agent

Evidence

Test (node@24, agents@0.25.0)
const fs = require("fs");
const path = require("path");
// @cloudflare/codemode is an optional peer of agents/browser; stub it only if it is absent.
const stubDir = "/w/node_modules/@cloudflare/codemode";
if (!fs.existsSync(path.join(stubDir, "package.json"))) {
  fs.mkdirSync(stubDir, { recursive: true });
  fs.writeFileSync(path.join(stubDir, "package.json"), JSON.stringify({ name: "@cloudflare/codemode", version: "0.0.0", type: "module", exports: { ".": "./index.js" } }));
  fs.writeFileSync(path.join(stubDir, "index.js"), "export class CodemodeConnector { constructor() {} }\nexport class CodemodeRuntime { constructor() {} }\n");
}
fs.writeFileSync("/w/check.mjs", "export default await import('agents/browser');\n");
import("/w/check.mjs").then((m) => {
  const mod = m.default;
  const version = JSON.parse(fs.readFileSync("/w/node_modules/agents/package.json", "utf8")).version;
  if (typeof mod.CdpSession !== "function") {
    console.error("ERROR: agents/browser does not export a CdpSession class");
    process.exit(2);
  }
  if (mod.CdpConnection === undefined) {
    console.error("FAIL: agents/browser exports no CdpConnection; CdpSession is the only name (agents " + version + ")");
    process.exit(1);
  }
  if (mod.CdpConnection !== mod.CdpSession) {
    console.error("ERROR: CdpSession is not an alias of CdpConnection");
    process.exit(2);
  }
  console.log("OK: agents " + version + " CdpSession === CdpConnection");
  process.exit(0);
}).catch((e) => {
  console.error("ERROR: import failed: " + (e && e.message));
  process.exit(2);
});
Test (node@24, agents@0.24.0, expected to fail)
const fs = require("fs");
const path = require("path");
// @cloudflare/codemode is an optional peer of agents/browser; stub it only if it is absent.
const stubDir = "/w/node_modules/@cloudflare/codemode";
if (!fs.existsSync(path.join(stubDir, "package.json"))) {
  fs.mkdirSync(stubDir, { recursive: true });
  fs.writeFileSync(path.join(stubDir, "package.json"), JSON.stringify({ name: "@cloudflare/codemode", version: "0.0.0", type: "module", exports: { ".": "./index.js" } }));
  fs.writeFileSync(path.join(stubDir, "index.js"), "export class CodemodeConnector { constructor() {} }\nexport class CodemodeRuntime { constructor() {} }\n");
}
fs.writeFileSync("/w/check.mjs", "export default await import('agents/browser');\n");
import("/w/check.mjs").then((m) => {
  const mod = m.default;
  const version = JSON.parse(fs.readFileSync("/w/node_modules/agents/package.json", "utf8")).version;
  if (typeof mod.CdpSession !== "function") {
    console.error("ERROR: agents/browser does not export a CdpSession class");
    process.exit(2);
  }
  if (mod.CdpConnection === undefined) {
    console.error("FAIL: agents/browser exports no CdpConnection; CdpSession is the only name (agents " + version + ")");
    process.exit(1);
  }
  if (mod.CdpConnection !== mod.CdpSession) {
    console.error("ERROR: CdpSession is not an alias of CdpConnection");
    process.exit(2);
  }
  console.log("OK: agents " + version + " CdpSession === CdpConnection");
  process.exit(0);
}).catch((e) => {
  console.error("ERROR: import failed: " + (e && e.message));
  process.exit(2);
});
Source

Add Browser Run hostname guardrails, close and activity callbacks, and the `CdpConnection` name while retaining `CdpSession` as a deprecated alias.

raw.githubusercontent.com