AI automation
AI automation is the shared product layer for model-assisted operations, chat, tool use, AI-first workspaces, and background agent work. It connects provider-neutral AI access to current platform context, user authority, approval steps, controlled workspaces, and extensible tools so AI can help without becoming an alternate path around platform rules.
AI capability boundary
The AI layer gives product features one common way to request text, typed data, streamed turns, tool calls, and user decisions. Provider-specific transports stay behind this boundary, so chat, summaries, and workflows can share the same controls.
Provider-neutral AI access
The provider-neutral AI service is the main entry point for AI work. It supports one-shot completion, typed structured output, multi-turn history, streamed text, streamed tool activity, cancellation, and normalized user interactions. A request can carry a purpose and project scope so the platform can attribute use and apply policy before it reaches a model. The service also reports whether a selected provider can serve chat and whether the saved model supports tool schemas, so callers do not send unsupported tools.
The same boundary serves plain inference and workspace work without giving them the same authority. Gateway calls use configured or permitted caller credentials. Harness calls use the execution and capability rules of the selected agent environment. AI is best-effort, so callers can fall back to non-AI behavior when a provider or harness is unavailable.
References: crates/…/lib.rs• L4-21 crates/…/service.rs• L15-58 crates/…/service.rs• L168-215 crates/…/service.rs• L237-289 crates/…/service.rs• L429-522 crates/…/preflight.rs• L7-49 crates/…/preflight.rs• L123-143
Provider and model selection
The gateway connects model requests to configured providers such as OpenAI, Anthropic, Gemini, xAI, OpenRouter, and managed Temps Cloud inference. It resolves the selected credential, checks the model route, validates an external provider URL when one is supplied, and exposes a common streaming shape. A caller may use an administrator-managed key or an allowed bring-your-own key; a pinned system key remains exact and does not silently fall back to another key.
Model choice follows the most specific policy available. A project model allow-list takes priority over instance policy. Without a concrete policy choice, the system uses a configured key default when it is usable, then a current provider catalog or provider default. Self-hosted providers add a base URL and a discovered default model, and their discovery is tied to the current connection settings. If no local key can serve the request, a configured managed Temps Cloud model can provide the route. A live catalog is the strongest account-aware signal; bootstrap and stale inventories help the UI show choices but do not prove that an account can use them.
Provider setup keeps several readiness signals separate: a saved credential, a host CLI login, a workspace-ready connection, and the source of the model catalog. A preflight checks the harness path without making a provider model request. A smoke test requires explicit consent because it can make a billable request. An explicit model refresh can resolve the account-aware model list for a workspace provider. When a permitted local login exists on the Temps host, an administrator can import it without sending the secret through the browser. Credential checks report whether a provider is verified; an infrastructure failure does not mark a credential as invalid, and an unverified connection cannot make a workspace harness ready. The console can also show a provider choice before a key is entered, then clears fields that belong to the previous provider when the choice changes.
The gateway also provides an OpenAI-native surface for the Responses, Files, and Batches APIs. Official OpenAI SDKs can use this surface without request translation. The gateway still applies model routing, model allow-lists, caller ownership, usage accounting, and provider URL checks. Stateful provider data requires the caller's own key when a shared administrator key would otherwise expose one account's stored state to other callers.
The console exposes provider credentials, model inventories, summary defaults, usage, latency, errors, and estimated cost through the AI Gateway area. These views support governance of AI use rather than only connection setup. Cloud AI Activity uses an exact set of telemetry attributes to identify model calls and token usage without storing conversation content. Projects that send spans to Cloud must enable that metadata before new spans can provide the full activity view; attributes omitted from earlier spans cannot be recovered. When a chat provider fails, the console can offer a safe local-login refresh, provider settings, another provider for quota failures, or a retry after the problem is resolved.
References: crates/…/preflight.rs• L7-49 crates/…/preflight.rs• L123-143 crates/…/service.rs• L221-406 crates/…/gateway_service.rs• L20-45 crates/…/gateway_service.rs• L80-116 crates/…/gateway_service.rs• L229-331 crates/…/native_api_service.rs• L4-15 crates/…/native_api_service.rs• L563-643 crates/…/native_api_service.rs• L1448-1469 crates/…/mod.rs• L24-35 crates/…/mod.rs• L101-136 crates/…/openai_native.rs• L4-10 crates/…/ai_service.rs• L64-179 crates/…/ai_service.rs• L376-513 crates/…/provider.rs• L19-93 crates/…/ai_providers.rs• L65-143 crates/…/ai_providers.rs• L445-556 crates/…/ai_providers.rs• L641-748 crates/…/ai_providers.rs• L1055-1169 crates/…/ai_providers.rs• L1172-1286 crates/…/ai_providers.rs• L1289-1388 web/…/CloudAiMetadataNotice.tsx• L10-39 web/…/ProviderKeyProviderPicker.tsx• L7-69 web/…/ProviderKeyProviderPicker.test.tsx• L21-48 web/…/provider-key-form.ts• L13-113 web/…/provider-key-form.ts• L163-193 web/…/provider-key-form.test.ts• L54-113 web/…/provider-key-form.test.ts• L115-198 web/…/SessionDiagnostics.tsx• L21-105 web/…/cloud-ai-metadata.ts• L4-39 web/…/AiGateway.tsx• L259-401 web/…/AiGateway.tsx• L404-683 web/…/AiGateway.tsx• L846-903 web/…/ChatFailureActions.tsx• L10-50 web/…/chat-failure-recovery.ts• L4-21
OpenAI-native gateway
The OpenAI-native gateway extends the common AI boundary to provider-managed response state and asynchronous batch work. Responses can return a complete object or a server-sent event stream. Files and batches let callers submit many requests, track progress, retrieve result files, and account for token use after the original request ends.
The gateway records the owner and credential scope of each uploaded file and batch. Later reads, downloads, cancellations, and deletes use that record, so a caller cannot use an object created by another user or project. Batch reconciliation continues in the background and records final usage once, including usage recovered from result lines when the provider omits an aggregate total.
This diagram shows how native batch work moves from an input file to durable ownership and final accounting.
flowchart LR
C[Authenticated SDK or console] --> U[Validated batch input]
U --> F[Provider file]
F --> B[Provider batch]
B --> P[Durable polling record]
P --> R[Result and error files]
R --> A[Usage and ownership accounting]
References: crates/…/native.rs• L4-10 crates/…/native.rs• L88-105 crates/…/native_types.rs• L22-49 crates/…/native_types.rs• L93-210 crates/…/native_api_service.rs• L97-127 crates/…/native_api_service.rs• L266-325 crates/…/native_api_service.rs• L369-455 crates/…/native_api_service.rs• L649-719 crates/…/native_api_service.rs• L821-1091 crates/…/native_api_service.rs• L1093-1163
Usage and telemetry
AI usage is recorded as request-level accounting data rather than conversation content. The record can identify the provider, model, token counts, latency, response status, streaming mode, credential source, conversation, tags, request ID, and trace ID. This supports cost views, provider comparisons, time trends, and conversation summaries.
Streaming usage is collected as the stream passes through the gateway. The collector keeps only the bounded structure needed to read terminal token fields, forwards the original bytes, and records usage when the stream ends or the client disconnects. Batch usage uses the same goal of exact accounting: missing or malformed evidence stays pending or fails instead of being silently counted as zero.
The AI Gateway also applies request and spend limits at project and instance scope. A blank value inherits the next scope, while zero means unlimited. Monthly budgets use the UTC calendar month and cap operator-funded spend; requests that use a caller-supplied provider key are not counted against that budget. The console presents these rules in one shared limit form so the displayed meaning matches the value sent to the gateway.
References: crates/…/gateway.rs• L116-200 crates/…/native.rs• L451-527 crates/…/sse_usage.rs• L4-12 crates/…/sse_usage.rs• L388-449 crates/…/usage_service.rs• L19-116 crates/…/usage_service.rs• L280-350 crates/…/usage_service.rs• L353-418 web/…/ai-gateway-limits.ts• L6-16 web/…/ai-gateway-limits.ts• L121-199 web/…/AiLimitDialog.tsx• L34-87 web/…/AiLimitDialog.tsx• L89-158 web/…/AiGatewayLimitsPage.tsx• L82-111
Assisted chat
Assisted chat gives an operator a durable conversation about a project, deployment, alert, global platform scope, or multi-project application. A context provider supplies the starting facts and tools for that subject. The user's current authority remains the source of truth for each operation, so the context helps the model understand the task but does not grant extra access.
The console offers project chat in a persistent dock and a full-page chat view. Project conversations stay on project-scoped routes, while global and application conversations use the user-owned AI-first workspace. Users can resume, rename, archive, or start conversations, and a project chat can be created lazily when its first message is sent. On a phone, the chat list replaces the conversation until the user selects or closes it; focus returns to the matching list control. On wider screens, the list stays beside the conversation. Conversations keep their provider and runtime choices, store their history, and stream tokens, tool activity, permission requests, errors, and completion state to connected views. The browser can recover a running turn from durable server state when a live connection is lost, while a terminal state remains authoritative over partial streamed content.
The chat view keeps text, tool calls, attachments, and permission requests in ordered message parts. Read results can use a focused presentation, while unknown or failed operations remain inspectable as tool cards. Write proposals show redacted request details and a clear confirmation gate. A failed write can start a follow-up diagnosis, and a multi-step plan exposes one action at a time; a failed or rejected step stops the later steps. Before a turn, chat readiness and tool support are checked for the selected provider and saved model. If the model cannot call tools, the turn proceeds without tool schemas instead of being refused. For a new chat, the service can choose a provider that can actually stream. The browser also refreshes provider status and model catalogs when a selection needs an authoritative account-aware list. A context indicator reports the selected harness's current or estimated token use; it is a context limit view, not a billing counter. The application-level assistant can attach short-lived page context to the next turn without storing that framing in conversation history.
References: crates/…/plugin.rs• L91-128 crates/…/service.rs• L885-952 crates/…/service.rs• L2205-2362 crates/…/handlers.rs• L4-10 crates/…/handlers.rs• L523-687 crates/…/service.rs• L230-283 web/…/AiAssistantDock.tsx• L152-237 web/…/AiAssistantDock.tsx• L261-425 web/…/AiAssistantDock.tsx• L427-528 web/…/AiAssistantDock.tsx• L577-610 web/…/AiAssistantDock.tsx• L660-910 web/…/AiAssistantDock.tsx• L984-1115 web/…/AiAssistantDock.phone.test.tsx• L115-191 web/…/DebugChatPanel-components.tsx• L1314-1426 web/…/DebugChatPanel-components.tsx• L1520-1541 web/…/DebugChatPanel-shared.ts• L84-153 web/…/DebugChatPanel-shared.ts• L201-255 web/…/DebugChatPanel-shared.ts• L357-496 web/…/DebugChatPanel-shared.ts• L856-943 web/…/chat-page-state.ts• L8-13 web/…/chat-page-state.ts• L27-41 web/…/chat-page-state.ts• L56-121 web/…/chat-page-state.test.ts• L16-125 web/…/DebugChatPanel-components.tsx• L447-530 web/…/DebugChatPanel-components.tsx• L1447-1541 web/…/SessionDiagnostics.tsx• L21-105 web/…/ContextWindow-components.tsx• L12-121
Tool invocation and approval
Tool invocation lets a model gather current evidence before it answers. A chat turn may combine context-specific tools with read-only platform tools, repository exploration, managed process actions, and harness-native tools. The model can stream prose and tool activity in one turn, receive each result, and continue until it has enough evidence. Tool inputs and results shown to the user are redacted or reduced to safe status text when they may contain protected platform data.
Application workspaces also expose managed process actions for named development servers and other long-running commands. These actions stay inside the workspace, use bounded inputs and outputs, and require the same live authorization checks as other protected harness work. This lets a chat turn inspect a running process without giving the model arbitrary host access.
Provider-native questions, plan approvals, and tool approvals can use an interactive permission bridge. The user resolves the request in the chat, and the answer resumes the same turn. If the bridge is not available, the console explains the provider's permission mode instead of showing a false local approval path.
Platform mutations use a separate proposal path. The model prepares an allow-listed operation, the system stores a protected proposal, and the user confirms or rejects it. Confirmation rechecks current authority, runs the operation through the real platform route, and records the result. Multi-step plans run in order and stop after a failed or rejected step. The console renders trusted cards for operations such as service creation, service linking, project collections, and deployments; these cards use validated platform data and keep secrets out of the model-facing view.
This diagram shows how a chat turn moves from context and evidence to either a response or a user-gated change.
flowchart LR
U[Operator message] --> C[Contextual conversation]
C --> M[Selected provider and model]
M -->|needs evidence| T[Scoped read or workspace tool]
T --> R[Redacted tool result]
R --> M
M -->|answer| A[Streamed response]
M -->|change requested| P[Protected proposal]
P --> H[Current-user confirmation]
H --> X[Authorized platform operation]
References: crates/…/streaming.rs• L29-72 crates/…/streaming.rs• L257-359 crates/…/ai_service.rs• L826-949 crates/…/service.rs• L512-647 crates/…/service.rs• L827-922 crates/…/service.rs• L965-1024 crates/…/service.rs• L4380-4778 crates/…/pending_actions.rs• L73-180 crates/…/pending_actions.rs• L380-547 web/…/PermissionCard.tsx• L7-24 web/…/PermissionCard.tsx• L50-85 web/…/PermissionCard.tsx• L637-689 web/…/PermissionCard.render.test.tsx• L28-69 web/…/DebugChatPanel-components.tsx• L447-530 web/…/DebugChatPanel-components.tsx• L620-912 web/…/DebugChatPanel-components.tsx• L944-1207 web/…/DebugChatPanel-components.tsx• L1242-1311 web/…/DebugChatPanel-components.tsx• L1210-1239 web/…/DebugChatPanel-components.tsx• L1314-1426
AI-first workspaces
AI-first workspaces extend chat from a question-and-answer surface into a durable place to build, inspect, preview, and operate an application. They keep project files, compute, linked data services, and chat context connected while retaining normal platform authorization.
Application workspaces
An application groups one or more Temps projects under a user-owned workspace. Each linked project keeps its own deployment settings, while its source is placed in a project directory inside the shared persistent workspace. The workspace can expose linked data services on a private network, show file changes and diffs, run a development server, and create a short-lived preview link.
Application chat is restricted to registered workspace-ready development harnesses. The harness can work with files and platform tools through turn-scoped capabilities, but the workspace is not an authorization boundary: project access, platform permissions, and write approval are checked again while the turn runs. Chat can also create typed artifacts such as project collections, deployment views, forms, and execution plans. The console renders these as trusted UI from declarative data rather than model-supplied code.
The workspace view keeps the conversation, activity summary, generated output, files, preview, linked projects, and workspace settings in one product surface. It shows running, pending, finished, failed, stopped, and idle thread counts by harness, while historical harness aliases are grouped under one current identity. A persistent workspace can sleep or recover without losing files; settings expose its health, resource use, lifecycle actions, runtime compatibility, linked services, preview ports, and snapshot controls.
Workspace setup reuses a saved connection when it is ready. When the model list is only a bootstrap list or an old cache, the console can request current discovery before it offers model choices. The user can then choose a model, its thinking option when supported, and the harness permission mode. A mode that auto-approves tools is intended only for work the user trusts.
This diagram shows how an application conversation connects its working area to platform resources and the console.
flowchart LR
U[Application conversation] --> W[Persistent workspace]
W --> F[Project files and diffs]
W --> S[Managed sandbox]
W --> D[Linked data services]
S --> V[Short-lived preview]
U --> T[Scoped platform tools]
T --> P[Authorized project resources]
U --> A[Typed artifacts]
A --> C[Trusted console renderer]
References: crates/…/applications.rs• L132-145 crates/…/applications.rs• L451-510 crates/…/application.rs• L41-193 crates/…/application.rs• L195-301 crates/…/service.rs• L3516-3965 web/…/AiFirstWorkspace-components.tsx• L1636-2317 web/…/AiFirstWorkspace-components.tsx• L2464-2780 web/…/ApplicationWorkspaceSettingsPanel-components.tsx• L175-320 web/…/ApplicationWorkspaceSettingsPanel-components.tsx• L334-602 web/…/WorkspaceActivity-components.tsx• L11-155 web/…/WorkspaceActivity-shared.ts• L11-61 web/…/workspace-readiness.ts• L9-143 web/…/WorkspaceHarnessSetup.tsx• L31-260 web/…/ApplicationProjectsPanel.tsx• L39-109 web/…/ApplicationDataServicesPanel.tsx• L51-159 web/…/ApplicationPreviewPanel.tsx• L15-29 web/…/ArtifactRenderer.tsx• L219-334
Global workspaces
Global workspaces give one user a projectless operator space for cross-project work. The conversation starts without a project, then each platform operation must select a real project that the current user can access. The workspace is private and persistent, and its compute can sleep without removing its files.
Global and application threads share the workspace-ready harness model. The console shows workspace health, resource use, reachable data services, sandbox settings, and activity counts so a user can see whether the work area is ready before starting a turn.
References: crates/…/global.rs• L8-38 crates/…/plugin.rs• L131-228 web/…/GlobalWorkspaceStatusPanel.tsx• L19-131 web/…/AiFirstWorkspace-components.tsx• L347-417 web/…/AiFirstWorkspace-components.tsx• L852-926 web/…/AiFirstWorkspace-components.tsx• L2165-2179 web/…/AiFirstWorkspace-components.tsx• L2787-2811
Agent workflows
Agent workflows turn model use into durable background work. An agent has a project scope, prompt, provider settings, trigger rules, limits, and a desired delivery such as a pull request or report. The run record lets operators follow work after the original trigger ends.
Triggered runs
Triggers can come from issues and regressions, monitoring events, deploys, alarms, schedules, manual requests, autofixer actions, or authenticated webhooks. The trigger service identifies matching agents and then checks the agent rule, cooldown, daily budget, and project concurrency before it creates a run. Scheduled events retain the agent identity that fired them so one schedule does not start sibling agents.
The console can enable a workflow, show its provider and model, display its trigger set, and start a manual run with optional context. A workflow can be stored in the repository and synced on deploy, or run once from a local CLI file without being stored in service configuration. Webhooks keep the URL identifier separate from the secret header token, so logs and routing can identify an agent without exposing its credential.
References: crates/…/plugin.rs• L63-89 crates/…/plugin.rs• L169-307 crates/…/plugin.rs• L309-406 crates/…/trigger.rs• L123-236 crates/…/trigger.rs• L239-375 crates/…/run_service.rs• L15-31 crates/…/run_service.rs• L86-117 web/…/AutopilotPage.tsx• L121-230 web/…/AutopilotPage.tsx• L233-405 web/…/AutopilotPage.tsx• L408-573 web/…/AgentDetailPage.tsx• L158-405 web/…/AgentDetailPage.tsx• L408-525 web/…/AgentEditPage.tsx• L119-294 web/…/AgentEditPage.tsx• L400-483 web/…/AgentEditPage.tsx• L488-735
Workflow outcomes
An agent run works in an isolated repository area and can inspect source, make a change, run checks, and produce its configured result. A pull request workflow pushes a branch, opens a pull request, and can trigger a preview deployment. A report workflow returns analysis without a branch or pull request. The platform records status, logs, provider and model use, cost estimates, changed files, branch or pull-request links, preview links, and failure details.
The run view separates model conversation events from system logs and can follow active work as it streams. It presents provider output as assistant messages, tool calls, tool results, and usage summaries, while a debug view keeps event details available for inspection. Autofixer work can pause after analysis so an operator can add context, request a new analysis, generate a fix, review it, or create a pull request. A failed or rejected step does not silently advance the workflow.
Agent sandboxes can receive encrypted secrets as environment variables or mounted files. The console hides secret values and requires a new value to replace an existing one. Deleting a secret can break any workflow that still references it.
Provider settings can tune default turn caps for autofixer analysis, fix, and feedback phases when the selected harness supports them. Harnesses without a turn-cap control continue to run to completion.
Workflow memory can add project-and-agent facts to later prompts when a memory provider is available. Memory is supporting context, not a requirement for the main run; a missing or failed memory service does not stop the workflow.
References: crates/…/executor.rs• L104-153 crates/…/executor.rs• L187-277 crates/…/executor.rs• L372-389 crates/…/executor.rs• L816-857 crates/…/run_service.rs• L33-69 crates/…/run_service.rs• L409-485 crates/…/ai_providers.rs• L346-377 crates/…/ai_providers.rs• L1730-1837 web/…/AutopilotRunDetail.tsx• L127-151 web/…/AutopilotRunDetail.tsx• L171-537 web/…/AutopilotRunDetail.tsx• L539-625 web/…/AutopilotRunDetail.tsx• L975-1120 web/…/AutopilotRunDetail.tsx• L1246-1455 web/…/AutopilotRunDetail.tsx• L1297-1437 web/…/ProjectSecrets.tsx• L54-105 web/…/ProjectSecrets.tsx• L214-237 web/…/ProjectSecrets.tsx• L244-377 web/…/AutopilotStatusBadge.tsx• L8-100 web/…/AgentDetailPage.tsx• L533-603 web/…/AgentEditPage.tsx• L400-483 web/…/AgentEditPage.tsx• L738-807 web/…/AgentEditPage.tsx• L811-829 web/…/AiWorkflowsOverview.tsx• L21-26
Extensible AI integrations
Temps extends AI work through MCP, skills, custom tools, and plugin-owned services. These integrations add platform actions or reusable knowledge to a common provider and conversation flow. Their scope can be instance-wide, project-specific, agent-specific, or limited to one turn.
MCP and plugin integrations
MCP, or Model Context Protocol, is the tool interface for connecting an AI client or sandbox harness to platform capabilities. An external client can discover project-scoped Temps tools. An agent run can resolve project definitions for MCP servers, skills, and custom tools and make them available in its sandbox. Missing definitions are skipped and recorded rather than treated as a new authority source.
External plugins extend the same platform through verified, running plugin processes. Their manifests declare host permissions and AI use, while the host reports whether an AI provider is configured and the limits that apply to plugin calls. Plugin AI therefore depends on the shared AI service and remains subject to host grants and bounded prompt, output, and daily-call limits. Plugin installation, grant changes, and lifecycle changes are administrative actions with audit records.
MCP write access is separate from read access. It requires explicit write mode and the required platform permission, then follows the same proposal and confirmation rule as chat writes. A managed application harness instead receives a short-lived turn capability whose executor already captures the user's authority and workspace scope; it is not a reusable Temps token.
See MCP and plugin integrations for the integration model and client-facing details.
References: crates/…/service.rs• L421-463 crates/…/service.rs• L1219-1330 crates/…/executor.rs• L1029-1058 crates/…/executor.rs• L1154-1221 crates/…/plugin.rs• L69-128 crates/…/handler.rs• L114-229 crates/…/manager.rs• L336-400 crates/…/manager.rs• L953-992 crates/…/service.rs• L827-976
Agent runtime
The agent runtime is the execution layer for long-running AI work. It joins a repository or persistent workspace to a sandbox, supplies the selected harness and scoped extensions, runs the model client, and reports the result to the platform. It keeps background execution separate from interactive chat so a run can continue after its initiating request ends.
See AI agent runtime for the sandbox lifecycle, run states, workspace controls, and runtime-specific behavior.
References: crates/…/dispatch.rs• L55-68 crates/…/executor.rs• L372-389 crates/…/run_service.rs• L15-31 crates/…/service.rs• L612-650
Change checklist
When these files or sections are changed, remember to consider these:
- A provider or model change must keep the normalized capability contract, routing, credential readiness, model catalog source, summary defaults, and console selectors aligned.
- Gateway model policy changes must preserve project allow-lists, key defaults, structured output checks, usage attribution, and managed inference behavior.
- Provider setup changes must keep saved-credential status, host login status, workspace readiness, preflight and smoke semantics, model refresh permissions, self-hosted discovery binding, and diagnostic messages consistent.
- Native Responses, Files, or Batches changes must keep official SDK wire behavior aligned with OpenAI media types, model allow-lists, ownership records, credential scope, audit records, and background reconciliation.
- Native stateful or batch changes must preserve the boundary between shared system keys and caller-owned provider state, including release of stored BYOK credentials after accounting completes.
- Cloud AI Activity changes must keep the exact metadata allow-list, Cloud telemetry readiness check, new-span behavior, and telemetry settings link aligned without including conversation content.
- AI request and spend limit changes must preserve the distinction between inheritance, unlimited values, concrete caps, UTC monthly spend, and caller-owned keys that are excluded from operator-funded budgets.
- Credential import or verification changes must keep secrets server-side, invalidate old capability data, preserve concurrent replacement checks, and distinguish provider rejection from sandbox or relay failure.
- A chat transport or message-part change must keep HTTP submission, live events, durable snapshots, reconnect recovery, ordered text and tool parts, permission parts, and terminal turn status aligned.
- A chat capability change must keep provider readiness, saved-model tool support, new-chat provider selection, tool schema omission, and user-facing unavailable reasons aligned.
- A chat route or scope change must keep project conversations separate from user-owned workspace conversations, preserve URL selection, and refresh the list after lazy creation.
- A chat tool change must keep its schema, context scope, current-user authorization, live event, persisted message part, redaction, and client renderer aligned.
- A permission-bridge change must keep provider callbacks, pending permission state, decision types, resumed turns, and settled cards aligned.
- Rich artifact changes must keep server-validated identifiers, live platform status, secret filtering, and links to trusted platform views aligned.
- Failure handling changes must keep safe error envelopes, retry rules, local credential refresh rules, provider switching, and raw diagnostic suppression consistent.
- Managed process changes must keep workspace-relative paths, bounded results, idempotent calls, approval rules, live authorization refresh, and redacted errors aligned.
- A write operation must preserve the proposal, confirmation, permission, encryption, plan ordering, and audit boundaries across chat and MCP entry points.
- Application workspace changes must keep project topology, persistent file paths, data-service links, sandbox reachability, preview grants, artifact rendering, activity counts, and workspace settings consistent.
- A harness change must keep host readiness separate from workspace readiness, and must keep provider credentials behind the sandbox relay or private sandbox area.
- A workspace lifecycle or runtime change must keep persistent files safe across sleep, recovery, rebuild, snapshot, and runtime compatibility failure.
- A trigger or workflow editor change must preserve enabled state, trigger omission, provider and model selection, deliverable semantics, source-of-truth sync, and limit validation.
- A trigger change must preserve source identity, cooldown, budget, concurrency, run status, and delivery-result updates.
- Autofixer phase changes must keep live status, feedback, fix generation, PR creation, retry rules, and streamed log views consistent.
- MCP, skill, custom-tool, or plugin AI changes must keep definition lookup, secret masking, provider availability, grant limits, actor identity, and unresolved-definition reporting aligned.
- External plugin lifecycle changes must preserve signed source identity, startup verification, authenticated channels, proxy routes, event delivery, and the previous healthy version during candidate failure.
- Sandbox network changes must preserve host isolation, controlled egress, turn-scoped capability routes, and safe recovery of existing workspaces.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No active provider credential or no policy-allowed model | A completion or chat turn cannot start | Provider readiness, model resolution, and capability checks fail before dispatch |
| A self-hosted provider URL or key changes after model discovery | The saved model choice no longer proves that the current server can serve it | The form invalidates discovery when connection inputs change and requires a current discovered model |
| A workspace harness is installed but its workspace credential or secure relay is not ready | Application or global workspace chat cannot run | Host readiness and workspace readiness are separate checks |
| A preflight succeeds but no saved credential exists | The billable smoke test still fails and the workspace cannot use the connection | Preflight checks infrastructure; smoke checks the saved credential and requires consent |
| A model list is only bootstrap or stale | The UI can show a choice that is not verified for the account | Explicit model discovery refresh returns the current or cached account-aware inventory and reports its source |
| The saved chat model cannot call tools | The turn cannot safely receive tool schemas or use model-driven tools | Model-aware capability checks omit tool schemas and explain the reduced turn when needed |
| A shared system key is used for provider-stored response state | One caller could read or continue state owned by another caller | Stateful Responses fields require BYOK; shared-key requests reject provider-account state |
| A batch file is malformed, too large, or exceeds upload capacity | The batch is not submitted, or a concurrent upload is rejected | Incremental JSONL validation, size limits, bounded upload slots, and temporary spooling run before the provider call |
| A native file or batch object is not owned by the caller | The object cannot be read, changed, or deleted through the gateway | Owner and credential-scope records are checked before every object operation |
| A batch finishes without usable token evidence | Usage can remain pending and the batch can be retried instead of being falsely counted as zero | Terminal reconciliation requires provider usage or valid result-file evidence and records it once |
| Cloud telemetry does not include the full AI metadata allow-list | New spans do not show complete model-call or token data in AI Activity, and old omissions remain unavailable | Project telemetry settings detect missing metadata and direct the user to enable it |
| A project or instance limit is saved as a blank value when unlimited was intended | The request or budget cap inherits a higher-level value | The limit form states that blank means inherit and zero means unlimited |
| A monthly budget is treated as a general token counter | Operator-funded spend is shown or enforced incorrectly | The gateway uses the UTC calendar month and excludes caller-supplied provider keys |
| A model requests a platform write and the user does not confirm it | No platform mutation occurs | Writes remain protected proposals until confirmation |
| A permission bridge is unavailable for the selected harness | Native questions or approvals cannot appear as local inline cards | The console reports the provider permission mode and offers only supported modes |
| A user's role, session, key, or project membership changes during a turn | Later tool or harness work is stopped | The service refreshes authorization before protected work |
| A tool result or model output contains credential-like data | Sensitive values could reach a transcript or browser | Tool results, persisted parts, and streamed harness output are redacted or bounded |
| A live chat connection drops while a turn is running | The browser can show incomplete activity or miss the final result | The durable turn state is authoritative and a disconnected running turn can be resynchronized |
| A provider or harness returns an unsafe or unknown failure payload | Internal paths or credential-shaped diagnostics could reach the user | Chat failure parsing accepts only bounded safe fields and uses a generic failure otherwise |
| A user confirms a write plan after an earlier step fails or is rejected | Later mutations could run out of order | Each step is gated in order and a failed or rejected step halts the plan |
| A workspace is sleeping, failed, or runtime-incompatible | File inspection or new turns cannot start normally | Readiness reports the state, automatic wake is bounded, and settings provide recovery or runtime update actions |
| Agent cooldown, budget, or project concurrency blocks a trigger | No background run is created | Trigger evaluation rejects the event before run creation |
| A workflow is disabled or its configured trigger is absent | Its event does not create a run | The workflow editor sends only enabled trigger blocks and the run action checks enabled state |
| An autofixer run is waiting for feedback or a fix decision | A generic retry could discard useful analysis | The run view exposes phase-specific actions and limits retry to terminal states |
| A plugin has no configured host AI provider or exceeds its grant limits | Plugin AI calls are unavailable or rejected | Plugin status reports provider readiness and the host applies daily-call, prompt-size, and output-size limits |
| An external plugin install, handshake, or authenticated channel fails | The plugin is not activated, and an existing active version can remain in service | Signed identity checks, staged startup verification, authenticated channels, and candidate promotion protect activation |
| Docker is unavailable without explicit local execution opt-in | Agent startup fails rather than running code on the host | Local sandbox use requires TEMPS_ALLOW_LOCAL_SANDBOX |
| A referenced MCP server or skill definition is missing | The run continues without that extension | Definition resolution records the missing reference in the run log |
| A sandbox has an old or weaker network policy | The sandbox is not reused for the new turn | Network policy is checked during sandbox recovery |
| A required agent secret is deleted or replaced incorrectly | A workflow or sandbox cannot resolve the referenced environment variable or file | Secret values stay hidden, edits require a new value, and deletion warns about dependent references |
Key files
| File | Why to read it |
|---|---|
| crates/…/lib.rs | Defines the provider-agnostic AI foundation, typed output role, and best-effort boundary. |
| crates/…/service.rs | Defines the shared completion, model-aware chat readiness, provider selection, streaming, tool, and interaction contract. |
| crates/…/preflight.rs | Defines stable harness readiness, smoke-test, and update reports. |
| crates/…/Cargo.toml | Describes the provider-neutral AI foundation and its structured-output schema role. |
| crates/…/provider.rs | Defines normalized provider capabilities and model-catalog trust levels. |
| crates/…/dispatch.rs | Shows gateway-versus-harness routing and explicit provider selection. |
| crates/…/plugin.rs | Shows how the gateway registers AI services, provider adapters, authenticated routes, and sandbox relays. |
| crates/…/gateway_service.rs | Shows the common provider, credential, model discovery, and streaming boundary. |
| crates/…/native_api_service.rs | Shows the OpenAI-native Responses, Files, Batches, ownership, and reconciliation flow. |
| crates/…/native_types.rs | Defines the OpenAI-native wire model and pass-through fields. |
| crates/…/openai_native.rs | Defines the native provider transport and bounded forwarding behavior. |
| crates/…/ai_service.rs | Shows model policy, structured output, chat tools, managed inference, and streamed tool calls. |
| crates/…/provider_key_service.rs | Shows encrypted provider credentials, model selection, and key retention rules. |
| crates/…/usage_service.rs | Defines usage records, request context, and reporting views. |
| crates/…/sse_usage.rs | Defines bounded token extraction from streamed provider events. |
| web/…/ai-gateway-limits.ts | Defines limit inheritance, unlimited values, budget units, validation, and wire conversion. |
| web/…/AiLimitDialog.tsx | Shows the shared operator form for request and monthly spend limits. |
| web/…/AiGatewayLimitsPage.tsx | Shows project overrides, instance defaults, and budget use in the console. |
| crates/…/service.rs | Coordinates durable turns, live authorization, tools, workspaces, managed processes, and streamed events. |
| crates/…/pending_actions.rs | Shows protected write proposals, approval, plan ordering, and terminal outcomes. |
| crates/…/application.rs | Shows the multi-project application context and typed artifact capability. |
| crates/…/applications.rs | Shows the durable application workspace boundary and linked-project model. |
| crates/…/ai_providers.rs | Shows provider setup, credential verification, readiness diagnostics, and model discovery. |
| crates/…/plugin.rs | Shows trigger gates, sandbox selection, and background agent service wiring. |
| crates/…/executor.rs | Shows the high-level agent workspace setup and extension preparation path. |
| crates/…/run_service.rs | Defines durable agent run states, logs, limits, and outcomes. |
| crates/…/catalog.rs | Defines harness providers, credentials, permission modes, and workspace support. |
| crates/…/model_relay.rs | Defines the short-lived model capability for sandboxed harnesses. |
| crates/…/handler.rs | Exposes plugin AI capability status, grant limits, lifecycle controls, and security audit boundaries. |
| crates/…/manager.rs | Connects the shared AI service to verified plugin channels and manages plugin process readiness. |
| crates/…/service.rs | Coordinates signed plugin selection, staged activation, actor identity, and runtime surface refresh. |
| web/…/AiAssistantDock.tsx | Shows project chat continuity, full-page chat routing, responsive conversation lists, and lazy chat creation. |
| web/…/AiAssistantDock.phone.test.tsx | Protects phone chat-list behavior, focus return, and responsive layout changes. |
| web/…/AiAssistantContext-shared.ts | Defines page context and project context that can shape assistant turns without changing stored history. |
| web/…/CloudAiMetadataNotice.tsx | Shows the project warning and settings path for incomplete Cloud AI Activity metadata. |
| web/…/cloud-ai-metadata.ts | Defines the metadata used to identify AI calls and token usage without conversation content. |
| web/…/DebugChatPanel-shared.ts | Defines live event handling, durable turn recovery, safe failure parsing, permission state, and transport state. |
| web/…/chat-page-state.ts | Defines project versus user-owned chat scope, route resolution, lazy creation, and composer behavior. |
| web/…/chat-page-state.test.ts | Protects the chat scope, URL selection, lazy-list refresh, and interruption contract. |
| web/…/chat-message-parts.ts | Defines the ordered text, tool, permission, attachment, and action-recovery message model. |
| web/…/PermissionCard.tsx | Shows user resolution of questions, plans, and tool approvals from a harness. |
| web/…/PermissionCard.render.test.tsx | Protects rich approval rendering and secret filtering for platform writes. |
| web/…/ProviderKeyProviderPicker.tsx | Presents supported provider choices before a key is saved. |
| web/…/ProviderKeyProviderPicker.test.tsx | Protects provider choice coverage, selection state, and disabled saves. |
| web/…/provider-key-form.ts | Defines vendor and self-hosted key validation, model discovery binding, and request mapping. |
| web/…/provider-key-form.test.ts | Protects key validation, discovery invalidation, provider switching, and request shape. |
| web/…/GeneratedDeploymentCard.tsx | Shows how an approved deployment action becomes live platform status and a trusted link. |
| web/…/GeneratedProjectCollection.tsx | Shows live access checks for model-generated service collections. |
| web/…/GeneratedServiceProposal.tsx | Shows secret-safe service proposals and post-creation links. |
| web/…/SessionDiagnostics.tsx | Shows the opt-in, redacted snapshot of stored chat and native session state. |
| web/…/ContextWindow-components.tsx | Shows how context use is presented without treating it as billing usage. |
| web/…/ChatFailureActions.tsx | Shows safe recovery choices after a provider-backed chat failure. |
| web/…/chat-failure-recovery.ts | Defines which failures support retry or local credential refresh. |
| web/…/AgentDetailPage.tsx | Shows workflow settings, triggers, manual runs, and run summaries. |
| web/…/AgentEditPage.tsx | Shows workflow provider, model, deliverable, trigger, skill, MCP, and limit choices. |
| web/…/AutopilotPage.tsx | Shows workflow setup, repository and ephemeral CLI paths, provider readiness, and recent runs. |
| web/…/AutopilotRunDetail.tsx | Shows streamed run logs, normalized provider conversations, autofixer phases, feedback, fixes, and pull requests. |
| web/…/ProjectSecrets.tsx | Shows encrypted agent secret inputs and their environment-variable or file delivery choices. |
| web/…/AutopilotStatusBadge.tsx | Defines the user-facing run and autofixer status groups. |
| web/…/AiFirstWorkspace-components.tsx | Shows the AI-first application and global workspace experience. |
| web/…/ApplicationWorkspaceSettingsPanel-components.tsx | Shows persistent workspace health, lifecycle, runtime, resource, and snapshot controls. |
| web/…/WorkspaceActivity-components.tsx | Shows workspace-level thread activity and running indicators. |
| web/…/WorkspaceActivity-shared.ts | Defines activity states and harness identity grouping. |
| web/…/workspace-readiness.ts | Defines which workspace and harness states are ready for use. |
| web/…/WorkspaceHarnessSetup.tsx | Shows workspace connection readiness, model discovery, thinking choices, and tool permission selection. |
| web/…/ApplicationProjectsPanel.tsx | Shows linked project selection inside an application workspace. |
| web/…/ApplicationDataServicesPanel.tsx | Shows data-service links available to an application workspace. |
| web/…/ApplicationPreviewPanel.tsx | Shows short-lived application preview access. |
| web/…/ArtifactRenderer.tsx | Shows trusted rendering for typed artifacts produced by AI work. |
| web/…/AiGateway.tsx | Shows provider administration, model inventory, summary defaults, and usage views. |