Skip to content

Commit 8bbaf31

Browse files
updated agent workspace logic
1 parent 51c5b42 commit 8bbaf31

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
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: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@
3535
from agentex.lib.core.temporal.types.workflow import SignalName
3636
from agentex.lib.core.temporal.workflows.workflow import BaseWorkflow
3737

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

4144
environment_variables = EnvironmentVariables.refresh()
4245

@@ -59,21 +62,6 @@ class StateModel(BaseModel):
5962
turn_number: int = 0
6063

6164

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-
7765
@workflow.defn(name=environment_variables.WORKFLOW_NAME)
7866
class ClaudeMvpWorkflow(BaseWorkflow):
7967
"""Minimal Claude agent workflow - MVP v0

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ async def create_workspace_directory(task_id: str, workspace_root: str | None =
2727
2828
Args:
2929
task_id: Task ID for workspace directory name
30-
workspace_root: Root directory for workspaces (defaults to project/workspace)
30+
workspace_root: Root directory for workspaces (defaults to .claude-workspace/ in cwd)
3131
3232
Returns:
3333
Absolute path to created workspace
3434
"""
3535
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")
36+
# Default to .claude-workspace in current directory
37+
# Follows Claude SDK's .claude/ convention
38+
workspace_root = os.path.join(os.getcwd(), ".claude-workspace")
3939

4040
workspace_path = os.path.join(workspace_root, task_id)
4141
os.makedirs(workspace_path, exist_ok=True)

0 commit comments

Comments
 (0)