Skip to content

Commit 3f31654

Browse files
updated agent workspace logic
1 parent 51c5b42 commit 3f31654

File tree

4 files changed

+17
-27
lines changed

4 files changed

+17
-27
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ Brewfile.lock.json
1616

1717
.DS_Store
1818

19-
examples/**/uv.lock
19+
examples/**/uv.lock
20+
21+
# Claude workspace directories
22+
.claude-workspace/

examples/tutorials/10_async/10_temporal/090_claude_agents_sdk_mvp/project/run_worker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import os
1313
import asyncio
1414

15-
# Import workflow and workspace activity
16-
from project.workflow import ClaudeMvpWorkflow, create_workspace_directory
15+
# Import workflow
16+
from project.workflow import ClaudeMvpWorkflow
1717

1818
from agentex.lib.utils.logging import make_logger
1919
from agentex.lib.environment_variables import EnvironmentVariables
@@ -24,6 +24,7 @@
2424
from agentex.lib.core.temporal.plugins.claude_agents import (
2525
ContextInterceptor, # Reuse from OpenAI!
2626
run_claude_agent_activity,
27+
create_workspace_directory,
2728
)
2829

2930
logger = make_logger(__name__)

examples/tutorials/10_async/10_temporal/090_claude_agents_sdk_mvp/project/workflow.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
from __future__ import annotations
2020

2121
import os
22-
from pathlib import Path
2322
from datetime import timedelta
2423

25-
from temporalio import activity, workflow
24+
from temporalio import workflow
2625
from temporalio.common import RetryPolicy
2726
from claude_agent_sdk.types import AgentDefinition
2827

@@ -35,8 +34,11 @@
3534
from agentex.lib.core.temporal.types.workflow import SignalName
3635
from agentex.lib.core.temporal.workflows.workflow import BaseWorkflow
3736

38-
# Import Claude activity
39-
from agentex.lib.core.temporal.plugins.claude_agents import run_claude_agent_activity
37+
# Import Claude activities
38+
from agentex.lib.core.temporal.plugins.claude_agents import (
39+
run_claude_agent_activity,
40+
create_workspace_directory,
41+
)
4042

4143
environment_variables = EnvironmentVariables.refresh()
4244

@@ -59,21 +61,6 @@ class StateModel(BaseModel):
5961
turn_number: int = 0
6062

6163

62-
# Activity for workspace creation (avoids determinism issues)
63-
@activity.defn
64-
async def create_workspace_directory(task_id: str, workspace_root: str | None = None) -> str:
65-
"""Create workspace directory for task - runs as Temporal activity"""
66-
if workspace_root is None:
67-
# Use project-relative workspace for local development
68-
project_dir = Path(__file__).parent.parent
69-
workspace_root = str(project_dir / "workspace")
70-
71-
workspace_path = os.path.join(workspace_root, task_id)
72-
os.makedirs(workspace_path, exist_ok=True)
73-
logger.info(f"Created workspace: {workspace_path}")
74-
return workspace_path
75-
76-
7764
@workflow.defn(name=environment_variables.WORKFLOW_NAME)
7865
class ClaudeMvpWorkflow(BaseWorkflow):
7966
"""Minimal Claude agent workflow - MVP v0

src/agentex/lib/core/temporal/plugins/claude_agents/activities.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import os
66
from typing import Any
7-
from pathlib import Path
87

98
from temporalio import activity
109
from claude_agent_sdk import AgentDefinition, ClaudeSDKClient, ClaudeAgentOptions
@@ -27,15 +26,15 @@ async def create_workspace_directory(task_id: str, workspace_root: str | None =
2726
2827
Args:
2928
task_id: Task ID for workspace directory name
30-
workspace_root: Root directory for workspaces (defaults to project/workspace)
29+
workspace_root: Root directory for workspaces (defaults to .claude-workspace/ in cwd)
3130
3231
Returns:
3332
Absolute path to created workspace
3433
"""
3534
if workspace_root is None:
36-
# Use project-relative workspace for local development
37-
project_dir = Path(__file__).parent.parent.parent.parent.parent.parent.parent
38-
workspace_root = str(project_dir / "examples" / "tutorials" / "10_async" / "10_temporal" / "090_claude_agents_sdk_mvp" / "workspace")
35+
# Default to .claude-workspace in current directory
36+
# Follows Claude SDK's .claude/ convention
37+
workspace_root = os.path.join(os.getcwd(), ".claude-workspace")
3938

4039
workspace_path = os.path.join(workspace_root, task_id)
4140
os.makedirs(workspace_path, exist_ok=True)

0 commit comments

Comments
 (0)