:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
perf(tasks): move routine debug lines out of the run log (#120512)
Jonathan Mielood33aafbd0296
diff --git a/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py b/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.pyindex 45a923c2a8d8..60adb4544b53 100644--- a/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py+++ b/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py@@ -1010,7 +1010,7 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskPro# be mid-cancel/delete. Retry rather than fail fatally so the transient window recovers.raise TaskRunNotReadyError(f"TaskRun {run_id} not found", {"run_id": run_id})- emit_agent_log(run_id, "debug", "Fetching task details")+ log_with_activity_context("Fetching task details", run_id=run_id)task: Task = task_run.taskif not task_run.matches_task_ownership(task):@@ -1087,16 +1087,13 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProallowed_domains = sandbox_environment.get_effective_domains()if allowed_domains is not None:- emit_agent_log(- run_id,- "debug",+ log_with_activity_context(f"Resolved sandbox environment '{sandbox_environment.name}' with agentsh allowlist: {format_allowed_domains_for_log(allowed_domains)}",+ run_id=run_id,)else:- emit_agent_log(- run_id,- "debug",- f"Resolved sandbox environment '{sandbox_environment.name}' with full network access",+ log_with_activity_context(+ f"Resolved sandbox environment '{sandbox_environment.name}' with full network access", run_id=run_id)# A per-run image (picked at task start) wins over the environment's image.@@ -1146,7 +1143,7 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskPro)or False) # Ensure we get a boolean value even if the flag is missing- emit_agent_log(run_id, "debug", f"pr_loop_enabled: {pr_loop_enabled} for this task run")+ log_with_activity_context(f"pr_loop_enabled: {pr_loop_enabled} for this task run", run_id=run_id)state_updates: dict[str, Any] = {PR_LOOP_ENABLED_STATE_KEY: pr_loop_enabled}include_live_context = state.get("include_live_context") is not False# The sandbox agent renders these into its skill roots at session start. Resolved here so the@@ -1200,10 +1197,8 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProsandbox_event_ingest_enabled = model_access.kind == "own-subscription" or _is_sandbox_event_ingest_enabled(run_id=run_id, state=state)- emit_agent_log(- run_id,- "debug",- f"sandbox_event_ingest_enabled: {sandbox_event_ingest_enabled} for this task run",+ log_with_activity_context(+ f"sandbox_event_ingest_enabled: {sandbox_event_ingest_enabled} for this task run", run_id=run_id)agent_otel_telemetry_enabled = not trial_origin and (settings.DEBUG or state.get(AGENT_OTEL_TELEMETRY_STATE_KEY) is not False@@ -1253,16 +1248,12 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProstate=state,)use_modal_vm_sandbox = vm_sandbox_decision.use_vm_sandbox- emit_agent_log(- run_id,- "debug",- f"use_modal_vm_sandbox: {use_modal_vm_sandbox} for this task run",- )+ log_with_activity_context(f"use_modal_vm_sandbox: {use_modal_vm_sandbox} for this task run", run_id=run_id)custom_image_name: str | None = Noneif environment_custom_image_name:if use_modal_vm_sandbox:custom_image_name = environment_custom_image_name- emit_agent_log(run_id, "debug", f"Using custom base image: {custom_image_name}")+ log_with_activity_context(f"Using custom base image: {custom_image_name}", run_id=run_id)else:emit_agent_log(run_id,@@ -1275,15 +1266,15 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskPro# the VM runtime — provisioning falls back to the plain VM base automatically if# this image is missing or unloadable.custom_image_name = vm_sandbox_decision.default_custom_image- emit_agent_log(run_id, "debug", f"Using the organization's default custom base image: {custom_image_name}")+ log_with_activity_context(+ f"Using the organization's default custom base image: {custom_image_name}", run_id=run_id+ )burstable_sandbox_resources_enabled = _is_burstable_sandbox_resources_enabled(run_id=run_id,state=state,)- emit_agent_log(- run_id,- "debug",- f"burstable_sandbox_resources_enabled: {burstable_sandbox_resources_enabled} for this task run",+ log_with_activity_context(+ f"burstable_sandbox_resources_enabled: {burstable_sandbox_resources_enabled} for this task run", run_id=run_id)overlap_clone_boot_enabled = _is_overlap_clone_boot_enabled(distinct_id=distinct_id,@@ -1291,20 +1282,16 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProrun_id=run_id,state=state,)- emit_agent_log(- run_id,- "debug",- f"overlap_clone_boot_enabled: {overlap_clone_boot_enabled} for this task run",+ log_with_activity_context(+ f"overlap_clone_boot_enabled: {overlap_clone_boot_enabled} for this task run", run_id=run_id)desktop_workspace_warm_enabled = _is_desktop_workspace_warm_enabled(distinct_id=distinct_id,organization_id=organization_id,run_id=run_id,)- emit_agent_log(- run_id,- "debug",- f"desktop_workspace_warm_enabled: {desktop_workspace_warm_enabled} for this task run",+ log_with_activity_context(+ f"desktop_workspace_warm_enabled: {desktop_workspace_warm_enabled} for this task run", run_id=run_id)rtk_enabled = _is_rtk_enabled(distinct_id=distinct_id,@@ -1319,10 +1306,8 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProorigin_product=task.origin_product,state=state,)- emit_agent_log(- run_id,- "debug",- f"rtk_enabled: {rtk_enabled}, benjamin_enabled: {benjamin_enabled} for this task run",+ log_with_activity_context(+ f"rtk_enabled: {rtk_enabled}, benjamin_enabled: {benjamin_enabled} for this task run", run_id=run_id)# The same test that mints the token's interactive-run marker: user-started signals runs get# a finite wall-clock ceiling because their inference is unbilled and the generic interactive@@ -1369,11 +1354,7 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProuse_modal_vm_sandbox = Falseuse_modal_network_allowlist = Falsecustom_image_name = None- emit_agent_log(- run_id,- "debug",- f"sandbox_backend: {sandbox_backend} for this task run",- )+ log_with_activity_context(f"sandbox_backend: {sandbox_backend} for this task run", run_id=run_id)# Pluggable-memory golden: only meaningful on hogland, and org-scoped like the# backend flag itself. Fails closed to the fixed-size golden on any error.use_hogland_hotplug_golden = False@@ -1392,10 +1373,8 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProexcept Exception as e:log_with_activity_context("hogland_hotplug_golden_flag_check_failed", run_id=run_id, error=str(e))use_hogland_hotplug_golden = False- emit_agent_log(- run_id,- "debug",- f"use_hogland_hotplug_golden: {use_hogland_hotplug_golden} for this task run",+ log_with_activity_context(+ f"use_hogland_hotplug_golden: {use_hogland_hotplug_golden} for this task run", run_id=run_id)dev_stack_preview_enabled = _is_dev_stack_preview_enabled(@@ -1407,10 +1386,8 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProcustom_image_name=custom_image_name,repository=run_repository,)- emit_agent_log(- run_id,- "debug",- f"dev_stack_preview_enabled: {dev_stack_preview_enabled} for this task run",+ log_with_activity_context(+ f"dev_stack_preview_enabled: {dev_stack_preview_enabled} for this task run", run_id=run_id)pr_authorship_mode = get_pr_authorship_mode(task, state)user_github_integration_id = Nonediff --git a/products/tasks/backend/temporal/process_task/activities/materialize_context_layer.py b/products/tasks/backend/temporal/process_task/activities/materialize_context_layer.pyindex e482d0d9a8a4..b3b5e062d6d9 100644--- a/products/tasks/backend/temporal/process_task/activities/materialize_context_layer.py+++ b/products/tasks/backend/temporal/process_task/activities/materialize_context_layer.py@@ -14,7 +14,11 @@ from posthog.temporal.common.utils import asyncifyfrom products.context_layer.backend.facade import api as context_layer_facadefrom products.tasks.backend.logic.services.sandbox import get_sandbox_class_for_sandbox_id-from products.tasks.backend.temporal.observability import emit_agent_log, log_activity_execution+from products.tasks.backend.temporal.observability import (+ emit_agent_log,+ log_activity_execution,+ log_with_activity_context,+)from products.tasks.backend.temporal.process_task.activities.get_task_processing_context import TaskProcessingContextMOUNT_TIMEOUT_SECONDS = 120@@ -113,9 +117,8 @@ def materialize_context_layer_in_sandbox(input: MaterializeContextLayerInput) ->f"Could not mount the context wiki; continuing without it: {result.stderr}",)return MaterializeContextLayerOutput(mounted=False)- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Mounted the context wiki at {context_layer_facade.SANDBOX_MOUNT_PATH} ({mount.head_sha[:12]})",+ run_id=ctx.run_id,)return MaterializeContextLayerOutput(mounted=True)diff --git a/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py b/products/tasks/backend/temporal/process_task/activities/provision_sandbox.pyindex fb02a77d7baf..9e4ac689a67e 100644--- a/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py+++ b/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py@@ -79,7 +79,11 @@ from products.tasks.backend.temporal.metrics import (sandbox_runtime_label,)from products.tasks.backend.temporal.oauth import create_oauth_access_token_for_run, create_wizard_oauth_access_token-from products.tasks.backend.temporal.observability import emit_agent_log, log_activity_execution+from products.tasks.backend.temporal.observability import (+ emit_agent_log,+ log_activity_execution,+ log_with_activity_context,+)from products.tasks.backend.temporal.process_task.activities.get_pr_context import (DEFAULT_GITHUB_RATE_LIMIT_BACKOFF_SECONDS,)@@ -247,7 +251,7 @@ def _prepare_posthog_desktop_cloud_task(ctx: TaskProcessingContext, sandbox: Sanlogger.warning("desktop_bootstrap_launch_failed", extra={"run_id": ctx.run_id, "error": str(e)})returnif result.exit_code == 3:- emit_agent_log(ctx.run_id, "debug", "Skipped Desktop workspace preparation: branch has no wait script")+ log_with_activity_context("Skipped Desktop workspace preparation: branch has no wait script", run_id=ctx.run_id)returnif result.exit_code != 0:logger.warning(@@ -255,7 +259,7 @@ def _prepare_posthog_desktop_cloud_task(ctx: TaskProcessingContext, sandbox: Sanextra={"run_id": ctx.run_id, "exit_code": result.exit_code, "stderr": result.stderr[-500:]},)return- emit_agent_log(ctx.run_id, "debug", "Started Desktop workspace preparation in the background")+ log_with_activity_context("Started Desktop workspace preparation in the background", run_id=ctx.run_id)@dataclass@@ -420,13 +424,10 @@ def _resolve_sandbox_github_token("""if ctx.github_read_access:github_token = get_readonly_github_token(ctx.team_id, repositories=ctx.repositories) or ""- emit_agent_log(- ctx.run_id,- "debug",- "Read-only GitHub token minted for evidence gathering"- if github_token- else "Read-only GitHub token unavailable, continuing without GitHub access",- )+ if github_token:+ log_with_activity_context("Read-only GitHub token minted for evidence gathering", run_id=ctx.run_id)+ else:+ emit_agent_log(ctx.run_id, "debug", "Read-only GitHub token unavailable, continuing without GitHub access")return github_tokenshould_inject_github_token = ctx.has_github_credentials and (@@ -555,10 +556,9 @@ def _build_environment_variables(safe_vars, skipped_keys = filter_user_sandbox_env_vars(sandbox_environment.environment_variables)environment_variables.update(safe_vars)- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Applied {len(safe_vars)} sandbox environment variable(s) from '{sandbox_environment.name}'",+ run_id=ctx.run_id,)if skipped_keys:emit_agent_log(@@ -620,15 +620,15 @@ def _build_environment_variables(def _emit_image_source_log(ctx: TaskProcessingContext, prepared: PrepareSandboxForRepositoryOutput) -> None:if prepared.image_source == "resume_snapshot":- emit_agent_log(ctx.run_id, "debug", f"Resuming environment from snapshot for {prepared.repository}")+ log_with_activity_context(f"Resuming environment from snapshot for {prepared.repository}", run_id=ctx.run_id)elif prepared.image_source == "repository_snapshot":- emit_agent_log(ctx.run_id, "debug", f"Found existing environment for {prepared.repository}")+ log_with_activity_context(f"Found existing environment for {prepared.repository}", run_id=ctx.run_id)elif prepared.repository:- emit_agent_log(- ctx.run_id, "debug", f"Creating environment from {prepared.image_source_label} for {prepared.repository}"+ log_with_activity_context(+ f"Creating environment from {prepared.image_source_label} for {prepared.repository}", run_id=ctx.run_id)else:- emit_agent_log(ctx.run_id, "debug", f"Creating environment from {prepared.image_source_label}")+ log_with_activity_context(f"Creating environment from {prepared.image_source_label}", run_id=ctx.run_id)def _build_sandbox_tags(@@ -726,7 +726,7 @@ def prepare_sandbox_for_repository(input: PrepareSandboxForRepositoryInput) -> Psnapshot_kind = snapshot_metadata.kindsnapshot_mount_path = snapshot_metadata.mount_pathelif not has_repo:- emit_agent_log(ctx.run_id, "debug", "Creating environment without repository")+ log_with_activity_context("Creating environment without repository", run_id=ctx.run_id)task = _load_task(ctx)shallow_clone = not needs_full_history(task.origin_product)@@ -795,13 +795,12 @@ def prepare_sandbox_for_repository(input: PrepareSandboxForRepositoryInput) -> P},)if is_resume:- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Resume mode: same_run_resume={run_state.same_run_resume}, "f"resume_idle={run_state.same_run_resume_idle}, "f"resume_from_run_id={run_state.resume_from_run_id}, "f"using_modal_snapshot={resume_snapshot_external_id is not None}",+ run_id=ctx.run_id,)increment_resume_mode(resume_mode, origin_product=ctx.origin_product)@@ -900,10 +899,9 @@ def _create_sandbox_for_repository(input: CreateSandboxForRepositoryInput) -> Cr{"team_id": ctx.team_id, "task_id": ctx.task_id, "run_id": ctx.run_id}, reason)_emit_image_source_log(ctx, prepared)- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Provisioning sandbox from {prepared.image_source_label} (image build may take a few minutes on first run)",+ run_id=ctx.run_id,)# The VM template bakes in Docker (and forces the VM runtime), so the agent@@ -941,22 +939,20 @@ def _create_sandbox_for_repository(input: CreateSandboxForRepositoryInput) -> Cr# floor would misprice its reserved capacity 8-16x in the usage ledger.if ctx.burstable_sandbox_resources_enabled and ctx.sandbox_backend != "hogland":config.burstable_resources = True- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Burstable resources enabled: requesting {config.effective_cpu_request_cores} CPU / "f"{config.effective_memory_request_mb} MiB, bursting up to {config.cpu_cores} CPU / "f"{int(config.memory_gb * 1024)} MiB",+ run_id=ctx.run_id,)runtime = sandbox_runtime_label(use_vm_sandbox)sandbox_backend = ctx.sandbox_backend if ctx.sandbox_backend != "modal" else modal_sandbox_backend_label()_apply_modal_network_policy(config, ctx, use_vm_sandbox=use_vm_sandbox)if config.outbound_domain_allowlist is not None:- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Requesting Modal network enforcement for {len(config.outbound_domain_allowlist)} domains",+ run_id=ctx.run_id,)sandbox_class = get_sandbox_class_for_run_backend(ctx.sandbox_backend)@@ -1011,7 +1007,7 @@ def _create_sandbox_for_repository(input: CreateSandboxForRepositoryInput) -> Cr)try:if config.outbound_domain_allowlist is not None:- emit_agent_log(ctx.run_id, "debug", "Modal sandbox created with network policy requested")+ log_with_activity_context("Modal sandbox created with network policy requested", run_id=ctx.run_id)record_network_enforcement("sandbox_creation_with_policy_request", runtime, "modal_requested", "success")@@ -1027,10 +1023,9 @@ def _create_sandbox_for_repository(input: CreateSandboxForRepositoryInput) -> Crf"Sandbox image downgraded: {sandbox.config.image_fallback}",)if sandbox.launch_dev_stack_bootstrap():- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context("Warming the prebaked dev stack in the background (compose host aliases + dockerd)",+ run_id=ctx.run_id,)create_ms = sandbox_creation_timer.elapsed_mssnapshot_outcome = (@@ -1079,7 +1074,7 @@ def _create_sandbox_for_repository(input: CreateSandboxForRepositoryInput) -> CrTaskRun.clear_sandbox_connection_state_atomic(ctx.run_id, sandbox.id)raise- emit_agent_log(ctx.run_id, "debug", f"Sandbox provisioned: {sandbox.id}")+ log_with_activity_context(f"Sandbox provisioned: {sandbox.id}", run_id=ctx.run_id)activity.logger.info(f"Created sandbox {sandbox.id} (used_snapshot={actual_used_snapshot})")return CreateSandboxForRepositoryOutput(@@ -1166,7 +1161,7 @@ def clone_repository_in_sandbox(input: CloneRepositoryInSandboxInput) -> CloneReblobless_clone=blobless_clone,**ctx.to_log_context(),):- emit_agent_log(ctx.run_id, "debug", f"Cloning {input.repository} into sandbox")+ log_with_activity_context(f"Cloning {input.repository} into sandbox", run_id=ctx.run_id)sandbox = get_sandbox_class_for_sandbox_id(input.sandbox_id).get_by_id(input.sandbox_id)state = parse_run_state(ctx.state)@@ -1249,7 +1244,7 @@ def checkout_branch_in_sandbox(input: CheckoutBranchInSandboxInput) -> CheckoutBbranch=input.branch,**ctx.to_log_context(),):- emit_agent_log(ctx.run_id, "debug", f"Checking out branch {input.branch}")+ log_with_activity_context(f"Checking out branch {input.branch}", run_id=ctx.run_id)sandbox = get_sandbox_class_for_sandbox_id(input.sandbox_id).get_by_id(input.sandbox_id)org, repo = input.repository.lower().split("/")@@ -1427,7 +1422,7 @@ def inject_fresh_tokens_on_resume(input: InjectFreshTokensOnResumeInput) -> Noneif not replace_sandbox_credentials(sandbox, github_token or None, access_token or None):raise RuntimeError("Failed to replace resumed sandbox credentials")- emit_agent_log(ctx.run_id, "debug", "Refreshed sandbox credentials after resume")+ log_with_activity_context("Refreshed sandbox credentials after resume", run_id=ctx.run_id)@activity.defndiff --git a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py b/products/tasks/backend/temporal/process_task/activities/start_agent_server.pyindex 7a76a91bc235..586b0ba1d1d5 100644--- a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py+++ b/products/tasks/backend/temporal/process_task/activities/start_agent_server.py@@ -60,7 +60,11 @@ from products.tasks.backend.temporal.metrics import (sandbox_runtime_label,)from products.tasks.backend.temporal.oauth import create_oauth_access_token_for_run-from products.tasks.backend.temporal.observability import emit_agent_log, log_activity_execution+from products.tasks.backend.temporal.observability import (+ emit_agent_log,+ log_activity_execution,+ log_with_activity_context,+)from products.tasks.backend.temporal.process_task.organization import guard_organization_executionfrom products.tasks.backend.temporal.process_task.utils import (McpServerConfig,@@ -162,11 +166,10 @@ def _resolve_protected_base_branch(ctx: TaskProcessingContext) -> str | None:return branchif pr_base and pr_base != branch:- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Working branch '{branch}' heads an open PR; protecting its base '{pr_base}' so commits to "f"'{branch}' are allowed",+ run_id=ctx.run_id,)return pr_basereturn branch@@ -552,17 +555,15 @@ def _prepare_launch(ctx: TaskProcessingContext, scopes: PosthogMcpScopes, sandborelayed_names = get_relayed_mcp_server_names(task_run, {config.name for config in mcp_configs})if relayed_names:- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Resolved {len(relayed_names)} relayed MCP server name(s) for agent server: {', '.join(relayed_names)}",+ run_id=ctx.run_id,)if mcp_configs:- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Resolved {len(mcp_configs)} MCP config(s) for agent server: {', '.join(config.name for config in mcp_configs)}",+ run_id=ctx.run_id,)else:emit_agent_log(@@ -574,24 +575,20 @@ def _prepare_launch(ctx: TaskProcessingContext, scopes: PosthogMcpScopes, sandboagentsh_domains = _agentsh_domains_for(ctx)if ctx.use_modal_network_allowlist and ctx.allowed_domains is not None:environment_name = ctx.sandbox_environment_name or ctx.sandbox_environment_id or "selected environment"- emit_agent_log(- ctx.run_id,- "debug",- f"Enforcing network allowlist for '{environment_name}' via Modal and agentsh",+ log_with_activity_context(+ f"Enforcing network allowlist for '{environment_name}' via Modal and agentsh", run_id=ctx.run_id)elif agentsh_domains is not None:environment_name = ctx.sandbox_environment_name or ctx.sandbox_environment_id or "selected environment"- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Applying agentsh network policy for '{environment_name}' with allowlist: {format_allowed_domains_for_log(agentsh_domains)}",+ run_id=ctx.run_id,)elif ctx.sandbox_environment_id:environment_name = ctx.sandbox_environment_name or ctx.sandbox_environment_id- emit_agent_log(- ctx.run_id,- "debug",+ log_with_activity_context(f"Sandbox environment '{environment_name}' grants full network access; starting without agentsh restrictions",+ run_id=ctx.run_id,)protected_base_branch = _join_protected_base_branch_lookup(ctx, protected_base_branch_lookup)@@ -807,7 +804,7 @@ def start_agent_server(input: StartAgentServerInput) -> StartAgentServerOutput:),guard_organization_execution(ctx.team_id),):- emit_agent_log(ctx.run_id, "debug", "Starting agent server")+ log_with_activity_context("Starting agent server", run_id=ctx.run_id)with StepTimer("sandbox_lookup"):sandbox = get_sandbox_class_for_sandbox_id(input.sandbox_id).get_by_id(input.sandbox_id)@@ -900,7 +897,7 @@ def start_agent_server(input: StartAgentServerInput) -> StartAgentServerOutput:_record_network_enforcement_observation(ctx)- emit_agent_log(ctx.run_id, "debug", f"Agent server started at {input.sandbox_url}")+ log_with_activity_context(f"Agent server started at {input.sandbox_url}", run_id=ctx.run_id)activity.logger.info(f"Agent server started at {input.sandbox_url} for task {ctx.task_id}")session_init_ms, boot_phases_ms = _read_agent_boot_metrics(sandbox, input)@@ -944,7 +941,7 @@ def launch_agent_server(input: StartAgentServerInput) -> StartAgentServerOutput:),guard_organization_execution(ctx.team_id),):- emit_agent_log(ctx.run_id, "debug", "Launching agent server (deferred readiness)")+ log_with_activity_context("Launching agent server (deferred readiness)", run_id=ctx.run_id)with StepTimer("sandbox_lookup"):sandbox = get_sandbox_class_for_sandbox_id(input.sandbox_id).get_by_id(input.sandbox_id)@@ -999,7 +996,7 @@ def mark_repo_ready(input: MarkRepoReadyInput) -> None:f"Repository clone failed; {action} empty workspace for: {', '.join(input.failed_repositories)}",)elif input.release_barrier:- emit_agent_log(input.run_id, "debug", "Repo ready; released agent-server session barrier")+ log_with_activity_context("Repo ready; released agent-server session barrier", run_id=input.run_id)@activity.defn@@ -1109,7 +1106,7 @@ def await_agent_server_ready(input: StartAgentServerInput) -> StartAgentServerOu_record_network_enforcement_observation(ctx)- emit_agent_log(ctx.run_id, "debug", f"Agent server ready at {input.sandbox_url}")+ log_with_activity_context(f"Agent server ready at {input.sandbox_url}", run_id=ctx.run_id)activity.logger.info(f"Agent server ready at {input.sandbox_url} for task {ctx.task_id}")session_init_ms, boot_phases_ms = _read_agent_boot_metrics(sandbox, input)