Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/agent-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ the Daytona adapter normalizes the provider's structured `503` response to an in
then the lifecycle verifies the active-run lease and canonical volume mount before replacing the
stopped container on the same isolated workspace-volume subpath. This preserves user files while
avoiding an indefinite dependency on one unhealthy runner.
Project materialization publishes its durable project-created event immediately after the database
commit, before waiting on Daytona workspace preparation. The workspace directory operation is
itself the sandbox readiness boundary; app-builder preparation does not issue a second synthetic
code-execution probe after that operation succeeds.
Provider output-length termination is nonterminal: the Workflow checkpoints the partial model turn,
adds an internal continuation message, and resumes from that durable state. A tool-free turn completes
the run only when the model reports an actual stop; content filtering, provider errors, and invalid
Expand Down
19 changes: 2 additions & 17 deletions apps/agent-worker/src/durable-objects/agent-run-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
projectLocalSourceDir,
} from "./project-sandbox-package-runtime";

export type ProjectSandboxStub = CodeRuntimeContext["sandbox"];
export type AgentRunLogger = ReturnType<typeof createLogger>;
type ProjectSandboxStub = CodeRuntimeContext["sandbox"];
type AgentRunLogger = ReturnType<typeof createLogger>;

interface AgentRunAppBuilderEnv extends AnalyticsBindings {
HYPERDRIVE: Hyperdrive;
Expand Down Expand Up @@ -491,21 +491,6 @@ function repoImportError(message: string): APIError {
});
}

export async function warmSandbox(
sandbox: ProjectSandboxStub,
logger: AgentRunLogger,
): Promise<void> {
const result = await sandbox.runCode({
code: "print('ready')",
language: "python",
});
const stdout = result.stdout;
logger.info("sandbox_warmed", {
success: result.success,
stdoutBytes: stdout.length,
});
}

async function startExpoDevServer(
sandbox: ProjectSandboxStub,
logger: AgentRunLogger,
Expand Down
3 changes: 1 addition & 2 deletions apps/agent-worker/src/durable-objects/agent-run-path.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { createLogger } from "@cheatcode/observability";
import type { CodeRuntimeContext, WorkspaceResolver } from "@cheatcode/sandbox-contracts";
import type { UIMessageChunk } from "ai";
import { runAppBuilder, warmSandbox } from "./agent-run-app-builder";
import { runAppBuilder } from "./agent-run-app-builder";
import type { AgentRunEnv } from "./agent-run-env";
import type { StartRunInput } from "./agent-run-schemas";

Expand Down Expand Up @@ -43,7 +43,6 @@ export async function prepareAppBuilderRun(
options.input.projectMode = appBuilderMode;
await options.workspaceResolver();
const boundOptions = { ...options, input: requireProjectBinding(options.input) };
await warmSandbox(boundOptions.sandbox, boundOptions.logger);
if (boundOptions.isCanceled()) {
return { options: boundOptions, usesManagedPreview: false, waitsForGeneratedPreview: false };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ async function resolveWorkspace(input: WorkspaceResolverInput): Promise<Workspac
const project = result.project;
input.input.projectId = project.id;
input.input.workspaceSlug = project.workspaceSlug;
await ensureWorkspaceDirectory(input, project.workspaceSlug);
if (result.kind === "created") {
await input.append({
data: { projectId: project.id, projectName: project.name, v: 1 },
type: "data-project-created",
});
}
await ensureWorkspaceDirectory(input, project.workspaceSlug);
input.logger.info("agent_workspace_materialized", {
projectId: project.id,
workspaceSlug: project.workspaceSlug,
Expand Down