Repository navigation
Description
What are you really trying to do?
Run a Deep Agent whose file and shell tools act on a remote sandbox (Daytona), with
serverless workers (temporalio.contrib.aws.lambda_worker). We looked at TemporalBackend
to wrap our sandbox backend.
Describe the bug
TemporalBackend registers the wrapped backend in a process-local registry, under a key
the workflow generates (_tools.py:540-545). deepagents.backend_op looks the key up in
its own process and otherwise raises a non-retryable error (_activity.py:346): Backend 'backend:<hex>' is not registered on this worker.
Temporal can dispatch the activity to any worker on the task queue, so the agent's file and
shell operations fail whenever backend_op runs in a process that did not run the workflow
code: several workers on one queue, or serverless workers, where each execution
environment is its own process. tool_as_activity has the same limit for tools that are not
registered at import on every worker.
Minimal Reproduction
Two processes on one task queue. Process A handles workflow tasks only
(no_remote_activities=True), so backend_op always runs in process B.
import asyncio, sys, uuid
from datetime import timedelta
from temporalio import workflow
from temporalio.client import Client
from temporalio.contrib.deepagents import DeepAgentsPlugin, TemporalBackend
from temporalio.worker import Worker
with workflow.unsafe.imports_passed_through():
from deepagents.backends import FilesystemBackend
QUEUE = "deepagents-backend-repro"
@workflow.defn
class ListFiles:
@workflow.run
async def run(self) -> str:
backend = TemporalBackend(
FilesystemBackend(root_dir="/tmp", virtual_mode=True),
activity_options={"start_to_close_timeout": timedelta(seconds=30)},
)
return str(await backend.als("/"))[:200]
async def main(role: str) -> None:
client = await Client.connect("localhost:7233", plugins=[DeepAgentsPlugin()])
if role == "activities": # process B
async with Worker(client, task_queue=QUEUE):
await asyncio.Event().wait()
async with Worker(client, task_queue=QUEUE, workflows=[ListFiles],
no_remote_activities=True): # process A
await client.execute_workflow(ListFiles.run, id=f"repro-{uuid.uuid4()}",
task_queue=QUEUE)
asyncio.run(main(sys.argv[1]))With temporal server start-dev running: python repro.py activities, then python repro.py workflow. The workflow fails with: DeepAgentsUnknownBackend: Backend 'backend:04e7f1341a334eb39999128a19337fbc' is not registered on this worker.
Environment/Versions
- OS and processor: macOS (Apple silicon) locally. AWS Lambda in production
- Temporal Version: Temporal Cloud;
temporalio[deepagents]==1.32.0,deepagents0.6.12,
Python 3.14.
Additional context
Suggestion: let the activity rebuild the backend from data in its input, e.g. a backend
factory registered by name at worker start, plus serializable arguments such as a sandbox id.
Activity