feat(coding-agent): run the built-in tools on a runtime without a session (RT10-pre)

Closed
CO
22d ago
+184-6

Summary

A runtime built by bootstrapRuntime() without a sessionManager now runs the built-in tools. Before this change it could not: the runtime got an implicit in-memory session manager with no loop bound, so every wrapped tool failed in runner.getActiveTools() ("Extension runtime not initialized"). With that fixed, read and bash still read loop-side context members (ctx.model, the session environment).

  • src/core/runtime/bootstrap.ts: with no sessionManager, the runner is session-less (the #5223 shape: runtime context only, loop-side members refused by name, no active tools reported). The built-in read is built with contextModel: false and bash with exposeSessionEnvironment: false (an existing option): a runtime without a session has no model and no session state to read.
  • src/core/tools/read.ts: new ReadToolOptions.contextModel (default true). When false, read does not read ctx.model: no model-specific image note, and the resize profile falls back to resizeOptions, exactly as it already does when no context is passed.

Part of #5413.

Inertness

No product path changes. AgentSession._buildRuntime is the one production caller of bootstrapRuntime() and always passes its own sessionManager, so every session (TUI, print, RPC, desktop) builds exactly the same read and bash definitions as before (contextModel unset → true; exposeSessionEnvironment unset → true). The session-less path is used by nothing yet; its first caller is the loopless runtime in the stacked follow-up.

Tests (run on a Linux host at the exact head 9fd81b75d1)

  • test/runtime/sessionless-builtin-tools.test.ts (new):
    • without a session: read reads a text file; read returns an image with no model-specific note; bash runs with no PI_SESSION_ID/PI_PROVIDER/PI_MODEL.
    • in a session (Z1 pin, passes before and after): read still adds the non-vision note for a text-only model; bash still exposes the session id, provider and model.
  • RED at the base (bootstrap.ts, read.ts reset to origin/main): the three session-less cases fail.
  • GREEN: the new file passes. Owner suites unchanged and green: test/runtime/{bootstrap-registry,context-split}.test.ts, test/sdk-session-manager.test.ts, test/agent-session-dynamic-tools.test.ts, test/block-images.test.ts, test/image-resize-callers.test.ts, test/suite/bash-browser-engine-env.test.ts, test/suite/bash-output-redaction.test.ts, test/anthropic-subscription-tools.test.ts, test/read-summary-parity.test.ts, test/bash-prompt-snippet.test.ts, test/filesystem-policy.test.ts.
  • bun run check: green.

KILL

None: no durable write and no ToolHost state transition.

Dead code

None made dead (SessionManager in bootstrap.ts becomes a type-only import).


Summary by cubic

Lets a runtime built by bootstrapRuntime() without a sessionManager run the built-in read and bash tools. Previously the runtime got an implicit in-memory session manager with no loop bound, so every tool failed on getActiveTools().

The session-less runner now reports no active tools. read gains a contextModel option (default true), which session-less builds set to false so the tool stops reading ctx.model; bash is built with exposeSessionEnvironment: false. No product path changes: AgentSession._buildRuntime is the only production caller and always passes a session manager, so session behavior is identical.

Part of #5413.