API reference
The public surface of Tess Core. Names listed here are covered by the stability promise: they change only with a version bump and a note in the changelog. Anything you import from a deeper module path is internal and may change without notice.
A test in the repository checks that every name on this page is importable from its entry point, and that nothing leaves the surface by accident.
Start here
The names most applications use. The guides explain each one.
| Name | What it is |
|---|---|
start_runtime | Start a runtime on a runtime home. The one call an embedding application needs first. |
Runtime | A started runtime: sessions, scheduler, status(), inspect(), stop(). |
Session | One open conversation: run_turn, subscribe, cancel_turn, close, end. |
SessionOptions | How a session is set up: provider, model, tools, permission mode, MCP servers, prompts. |
Unavailable | Returned by your session_options function when a session cannot be opened right now. |
ToolDefinition | A tool the model can call: name, description, input schema and an async handler. |
ProviderRegistry | A loaded provider registry. Pass one, or a path to its YAML file, to start_runtime. |
ExecutionBudget | A shared ceiling on model calls, tool calls and time across turns. |
MonitorDeliveryController | Lets a host claim, publish and settle monitor deliveries on its own channels. |
SessionBusy | Raised when a turn is started on a session that is already running one. |
SessionEnded | Raised when a session that has been ended is used again. |
UnknownSessionError | Raised when a session id does not exist in the runtime home. |
RuntimeStopped | Raised when a stopped runtime is used. |
tess_core
The main entry point. Everything an embedding application needs.
Functions
| Name | Description |
|---|---|
def active_session_payload(session: SessionRecord, config: dict[str, Any]) -> dict[str, Any] | The data of the session.activated event for a session. |
def build_system_prompt_for_agent(config: dict[str, Any], agentName: str | None, fallbackSystemPrompt: str | None = None) -> str | The system prompt for a named agent: the base prompt followed by the agent's own instructions. |
async def clear_auth() -> None | Remove the runtime home's stored credentials file. |
def configure_runtime_home(runtimeHome: str) -> str | Set the runtime home for this process and return its absolute path. |
async def connect_task_supervisor_daemon_client(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | None | Connect to an instance's running task daemon. |
def create_agent_runtime_bindings(args: Mapping[str, Any] | None = None, **kwargs: Any) -> Mapping[str, Any] | Build the read-only bindings an agent turn runs with. |
async def create_bridge_runtime(args: dict[str, Any] | None = None) -> dict[str, Any] | Create the selected, durable bridge generation for a session. |
def create_builtin_tools(options: dict[str, Any] | None = None) -> list[ToolDefinition] | The built-in tools, as ToolDefinition objects. |
async def create_collaboration_runtime(args: dict[str, Any] | None = None) -> dict[str, Any] | Start tracking a session's workers: its sub-agents, background tasks and monitors. |
def create_empty_session(params: dict[str, Any] | None = None, **kwargs: Any) -> SessionRecord | A new session record with no messages. |
async def create_git_worktree(...) | Create a git worktree on a new branch beside the repository, for isolated work. |
def create_initial_runtime_state(session: dict[str, Any] | None = None) -> dict[str, Any] | The starting runtime state: an idle turn, provider and compaction, with the session's summary when a session is given. |
def create_monitor_record(fields: dict[str, Any]) -> MonitorRecord | Build one monitor record from record-shaped fields (wire-key input). |
async def create_remote_session(args: dict[str, Any] | None = None) -> dict[str, Any] | Create and save the remote-session record for a session, and return it. |
def create_runtime_event(envelope: dict[str, Any]) -> RuntimeEventEnvelope | Normalize one envelope-shaped record (wire-adjacent: alias keys accepted). |
def create_runtime_session_binding(...) | Bind a session to a runtime generation and configuration revision. |
def create_runtime_state_store(initialState: dict[str, Any] | None = None) -> dict[str, Any] | A small state store over the runtime state: getState, setState, dispatch and subscribe. |
async def ensure_base_layout(cwd: str, paths: RuntimePaths | None = None) -> None | Create the runtime home's directories when they are missing. |
async def ensure_task_supervisor_daemon(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Start the task daemon for an instance if it is not running, and return a connected client. |
async def finalize_background_subagent_failure_from_env(error: Any) -> None | In a sub-agent worker process, record that the child failed. |
async def finalize_background_subagent_success_from_env(session: dict[str, Any], result: dict[str, Any]) -> None | In a sub-agent worker process, record the finished turn as the child's result. |
def find_git_root(cwd: str) -> str | None | Resolve the nearest worktree root without spawning git. |
async def find_sessions_for_workspace(sessions: list[dict[str, Any]], cwd: str) -> list[dict[str, Any]] | The sessions that belong to a directory or to its git repository. |
async def format_bridge_tail(bridgeId: str, limit: int = 20) -> str | The last limit events of a remote bridge as text, one per line. |
def format_session_candidate(session: dict[str, Any]) -> str | One line describing a session for a picker: short id, time, model and name. |
def get_default_auto_mode() -> AutoModePolicy | A copy of the default auto-mode policy. |
def get_state_root() -> str | The absolute path of the active runtime home. |
def is_task_supervisor_gateway(value: Any) -> bool | Whether a value offers the task daemon's client methods. |
async def list_active_bridge_rows() -> list[str] | One formatted row per active remote bridge, for display. |
async def list_child_agents() -> list[ChildAgentRecord] | Every valid sub-agent record, most recently started first. |
async def list_sessions() -> list[SessionRecord] | Every saved session that has messages, most recently updated first. |
async def load_auth() -> dict[str, Any] | None | Read the runtime home's stored credentials file, or None when there is none. |
async def load_auto_mode(cwd: str) -> AutoModePolicy | The project's auto-mode policy, or the default when it has none. |
async def load_bridge(bridgeId: str) -> dict[str, Any] | None | Load a remote bridge record, or None when it does not exist. A damaged record is an error. |
async def load_bridge_events(bridgeId: str) -> list[dict[str, Any]] | The recorded events of a remote bridge, oldest first. |
async def load_marketplaces() -> list[dict[str, Any]] | The plugin marketplaces known to this runtime home. |
async def load_mcp_servers(scope: Scope, cwd: str) -> list[dict[str, Any]] | The MCP servers registered at a scope: user, project or local. |
async def load_plugins(scope: Scope, cwd: str) -> list[dict[str, Any]] | The plugin records installed at a scope. |
async def load_session(sessionId: str) -> SessionRecord | None | Load a session with its conversation, or None when it does not exist. |
async def persist_session(session: SessionRecord, config: dict[str, Any], options: dict[str, Any] | None = None, **kwargs: Any) -> None | Save a session when persistence is on and it has messages to save. force saves an empty one. |
async def readOpenChildQuestions(session: dict[str, Any]) -> list[dict[str, Any]] | The questions this session's sub-agents have asked that are still waiting for an answer. |
def reset_configured_runtime_home() -> None | Forget the configured runtime home and return to the default. |
async def resolve_codex_auth(path: str | Path) -> str | Read only an explicit Codex auth JSON file; no home discovery or refresh. |
async def resolve_config(options: dict[str, Any] | None, cwd: str) -> ResolvedConfig | Resolve the full configuration for a session. |
def resolve_model_for_agent(config: dict[str, Any], agentName: str | None, fallbackModel: str | None = None) -> str | The model a named agent runs on: its own, else the fallback, else the configured model. |
def resolve_provider_profile(name: str, record: dict[str, Any], overrides: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Resolve one provider profile record into the settings a request needs, such as API mode and token limits, applying any overrides. |
def resolve_provider_profiles(customProfiles: dict[str, Any] | None) -> dict[str, dict[str, Any]] | The built-in provider profiles with custom profiles merged over them, keyed by normalised name. |
async def resolve_provider_secret(...) | Normalize a supplied credential or secret reference in the scoped runtime. |
async def resolve_session(...) | Find the session the options ask to resume or fork, or create an empty one from the configuration. |
async def resolve_teleport_session(args: dict[str, Any] | None = None) -> dict[str, Any] | None | Choose the remote session to resume: by id, or by asking when the terminal is interactive. |
async def run_agent_prompt(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Run one agent turn: call the model, run its tool calls, repeat until it stops. Low-level; see Session.run_turn. |
async def run_task_supervisor_daemon(cwd: str, instanceId: str, ownerPid: int | None = None) -> None | Run the task daemon for an instance in this process until it stops. |
async def save_auth(auth: dict[str, Any]) -> None | Write the runtime home's stored credentials file, keeping secrets in the secret store. |
async def save_bridge(record: dict[str, Any]) -> None | Save a remote bridge record. |
async def save_child_agent(record: ChildAgentRecord) -> None | Save a sub-agent record, merged with what is already stored. |
async def save_marketplaces(records: list[dict[str, Any]]) -> None | Replace the plugin marketplaces known to this runtime home. |
async def save_mcp_servers(scope: Scope, cwd: str, servers: list[dict[str, Any]]) -> None | Replace the MCP servers registered at a scope. |
async def save_monitor(record: MonitorRecord) -> None | Save a monitor record. |
async def save_plugins(scope: Scope, cwd: str, records: list[dict[str, Any]]) -> None | Replace the plugin records installed at a scope. |
async def save_session(session: SessionRecord) -> None | Save a session, merged with what is already stored so another writer's changes are kept. |
async def send_bridge_message(args: dict[str, Any] | None = None) -> dict[str, Any] | Admit one generation-bound, idempotent bridge message. |
async def start_runtime(...) | Start the runtime for runtime_home (default: $TESS_CORE_HOME or the engine's default home) in this process. |
async def update_remote_session(remoteSessionId: str, updates: dict[str, Any]) -> dict[str, Any] | None | Apply updates to a remote-session record and save it. Returns None when it does not exist. |
Types
| Name | Description |
|---|---|
class AnthropicMessage | One conversation message in Anthropic wire shape. |
class AnthropicUsage | Normalized usage (snake_case on both providers; cache keys Anthropic-only). |
class AskQuestionDetail | Context sent to the host with a question. For a permission prompt: the tool, mode, summary and reason. |
class ChildAgentRecord | Child-agent record at agents/{agentId}.json. |
class ExecutionBudget | A ceiling on model calls, tool calls and elapsed time, shared by every turn it is given to. |
class ExecutionBudgetExceeded | No further work may be admitted. |
class MonitorDeliveryController | Host consumer bound to an explicit runtime home and native session IDs. |
class MonitorDeliveryError | A monitor delivery was refused. code says why, for example monitor.not_found. |
PermissionMode | The permission modes: default, acceptEdits, auto, dontAsk, bypassPermissions. |
class ProviderRegistry | Load a YAML providerProfiles (or profiles) mapping from an explicit path. |
class ProviderRegistryError | A redacted registry/profile/credential configuration error. |
class ResolvedConfig | Output of resolve_config (config/resolution.py). |
class Runtime | A started runtime. Build it with :func:start_runtime. |
class RuntimeActivationContext | RuntimeActivationContext(binding: 'RuntimeSessionBinding', session: 'Mapping[str, Any]', config: 'Mapping[str, Any]', tools: 'tuple[Any, ...]', slashCommands: 'tuple[Any, ...]', workspace: 'Any', p... |
class RuntimeEventEnvelope | The exact shape emitted by create_runtime_event — every key always present. |
class RuntimeOwnershipError | Another live process, or this one, already owns the runtime home. |
RuntimeSecretPurpose | What a stored secret is for, such as a provider API key or an OAuth token. |
class RuntimeSecretRef | An opaque reference to a secret the runtime holds. It carries no secret material. |
RuntimeSecretValue | A secret given either as a literal value or as a RuntimeSecretRef. |
class RuntimeSessionBinding | RuntimeSessionBinding(sessionId: 'str', generation: 'int', configRevision: 'int', runtimeInstanceId: 'str' = 'standalone', pathGraphId: 'str' = 'unbound') |
class RuntimeStopped | The runtime is stopping or stopped: it takes no new sessions or turns. |
class Session | A stable handle: the session's id plus the manager. |
class SessionBusy | The session has a turn running or queued; close never cancels. |
class SessionEnded | The session was ended, the one explicit instruction: it never reopens and takes no more work. |
class SessionManager | The runtime's sessions, reached as runtime.sessions. |
class SessionOptions | How one session is set up. Everything is optional; the runtime home is the runtime's and the workspace defaults to the runtime's cwd. |
class SessionRecord | Hydrated live session contract returned by storage loaders. |
class SessionUnavailableError | Raised when the host's session_options answered Unavailable for a session. |
class ToolDefinition | ToolDefinition(name: 'str', description: 'str', inputSchema: 'dict[str, Any]', handler: 'Callable[[dict[str, Any], ToolContext], Awaitable[ToolResult]]', concurrency: 'ToolConcurrency | None' = Non... |
class Unavailable | The host refuses or defers opening this session. |
class UnknownSessionError | No session with that id exists in the runtime home. |
tess_core.shell_surface
Extra names for applications that build an interactive shell around the runtime.
Functions
| Name | Description |
|---|---|
def build_transcript_snapshot(session: dict[str, Any], limit: int | None = None) -> list[dict[str, Any]] | Render a session's messages as display entries: text, and tool results grouped by tool. |
def compact_model_name(model: str) -> str | A shorter model name for status lines. |
async def create_debug_bundle(args: dict[str, Any] | None = None) -> dict[str, Any] | Write a diagnostic bundle for a session to a directory and return its manifest and path. |
def estimate_encoded_image_request_bytes(mimeType: str, decodedBytes: int) -> int | An upper estimate of the bytes an image adds to a request once base64-encoded. |
def format_usage_summary(usage: dict[str, Any] | None) -> str | One line of token, tool and turn counts for display. |
async def handle_slash_command(args: dict[str, Any] | str | None = None, **kwargs: Any) -> dict[str, Any] | Run a slash command the user typed. |
def list_slash_commands(args: dict[str, Any] | None = None) -> list[dict[str, Any]] | The available slash commands with their usage and description, including those the runtime adds. |
def make_text_entry(args: dict[str, Any]) -> dict[str, Any] | A display entry for a piece of text. |
def make_tool_entry(args: dict[str, Any]) -> dict[str, Any] | A display entry for one tool result. |
def merge_transcript_entry(entries: list[dict[str, Any]], entry: dict[str, Any]) -> list[dict[str, Any]] | Append a display entry, merging it into the previous one when both are results of the same tool. |
def normalize_transcript_body(value: str) -> str | Normalise line endings and remove leading and trailing blank lines. |
Types
| Name | Description |
|---|---|
AnthropicBlock | One content block of a message: text, an image, a tool call or a tool result. |
tess_core.platform_support
Operating-system support: the daemon, sandboxing and diagnostics.
Functions
| Name | Description |
|---|---|
async def approve_mcp_source(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Approve the MCP servers configured at a scope, exactly as they are now. |
async def approve_plugin_source(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Approve the plugins configured at a scope, exactly as they are now. |
def authorize_runtime_secret_write(...) | Issue a short-lived authorization to store one secret for one purpose. |
async def collect_doctor_report(cwd: str, args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Collect a diagnostic report for a workspace. |
async def get_repository_trust_status(cwd: str) -> dict[str, Any] | A repository's identity, where its trust record is kept, and its current approvals. |
async def inspect_mcp_source_trust(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Report whether the MCP servers configured at a scope are approved for this repository. |
async def inspect_plugin_source_trust(args: dict[str, Any] | None = None) -> dict[str, Any] | Report whether the plugins enabled at a scope are approved for this repository. |
def is_runtime_secret_ref(value: Any) -> bool | Whether a value is a well-formed runtime secret reference. |
async def maybe_auto_connect_ide(cwd: str, args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Connect to the IDE when exactly one supported IDE is detected, launching it if needed. |
async def maybe_exec_into_tmux(args: dict[str, Any] | None = None) -> dict[str, Any] | Hand the launch over to a tmux session when the tmux option asks for one. |
def parse_installed_plugin_record(value: Any, field: str = installedPlugin) -> dict[str, Any] | Validate an installed-plugin record: manifest, enabled flag, scope, install time and source. |
def parse_marketplace_manifest(value: Any, field: str = marketplace) -> dict[str, Any] | Validate a marketplace manifest and its plugins. Duplicate plugin ids are an error. |
def parse_mcp_server_config(value: Any, field: str = mcp) -> dict[str, Any] | Validate one MCP server descriptor and return it in canonical form. |
def parse_mcp_server_config_list(value: Any, field: str = mcp) -> list[dict[str, Any]] | Validate one MCP server descriptor or a list of them. Duplicate names are an error. |
def parse_plugin_manifest_v1(value: Any, field: str = plugin) -> dict[str, Any] | Validate a version-1 plugin manifest. Its entry path must stay inside the plugin root. |
def parse_setting_sources(raw: str | list[str] | tuple[str, ...] | None) -> list[str] | Normalise a selection of setting sources (user, project, local). |
async def resolve_chrome_companion_server(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Detect the Chrome companion: its status and, when supported, the MCP descriptor that starts it. |
def resolve_tmux_launch_context_from_env(env: dict[str, str] | None = None) -> dict[str, Any] | None | The launch context a tmux hand-off left in the environment, or None when there is none. |
async def revoke_repository_approval(args: dict[str, Any] | None = None) -> dict[str, Any] | Withdraw one approval (cwd, family, scope) and return the repository's trust status. |
async def run_chrome_companion_mcp_server(input_stream: Any | None = None, output_stream: Any | None = None) -> None | Serve the Chrome companion's MCP protocol on the given streams until input ends. |
async def run_chrome_native_host(input_stream: Any | None = None, output_stream: Any | None = None) -> None | Serve Chrome's native-messaging protocol on the given streams until input ends. |
async def run_repo_install(args: dict[str, Any] | None = None) -> dict[str, Any] | Install a source checkout as the active package, in editable mode, and report the steps taken. |
async def run_repo_update(args: dict[str, Any] | None = None) -> dict[str, Any] | Update a source checkout from its upstream when the working tree is clean, and report each step. |
async def store_runtime_secret(...) | Store a secret under an authorization and return a reference to it. |
tess_core.testing
Internals exposed for integration tests. Not covered by the stability promise.
Functions
| Name | Description |
|---|---|
def build_messages_for_working_context(session: dict[str, Any]) -> list[dict[str, Any]] | The messages a request is built from: those after the session's compaction cutoff. |
def create_provider_failure_record(args: dict[str, Any] | None = None, **kwargs: Any) -> ProviderFailureRecord | Build the bounded, structured record of a provider failure. |
def create_provider_request_error(record: dict[str, Any]) -> ProviderRequestError | Wrap a failure record in the exception the agent loop handles. |
def is_provider_request_error(error: BaseException | Any) -> bool | Whether an exception is a provider request failure that carries a failure record. |
async def run_compaction(args: dict[str, Any] | None = None) -> dict[str, Any] | Compact a session's conversation: checkpoint the older messages and keep the recent ones. |
async def send_anthropic_messages_request(args: dict[str, Any] | None = None, **kwargs: Any) -> ProviderResponse | Send one request to the Anthropic Messages API and return the normalised response. |
async def send_openai_responses_request(args: dict[str, Any] | None = None, **kwargs: Any) -> dict[str, Any] | Send one request to an OpenAI Responses endpoint and return the normalised response. |
Types
| Name | Description |
|---|---|
class CompactionModelClient | The model client compaction uses: wraps the complete callable that writes a checkpoint. |