Isolate plan and task runtime per session
This commit is contained in:
@@ -199,10 +199,15 @@ class AgentContextTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
workspace = Path(tmp_dir) / 'repo'
|
||||
workspace.mkdir(parents=True)
|
||||
runtime = TaskRuntime.from_workspace(workspace)
|
||||
scratchpad = workspace / '.port_sessions' / 'accounts' / 'alice' / 'sessions' / 's1' / 'scratchpad'
|
||||
scratchpad.mkdir(parents=True)
|
||||
runtime = TaskRuntime.from_storage_path(scratchpad / 'task_runtime.json')
|
||||
runtime.create_task(title='Review task runtime')
|
||||
|
||||
snapshot = build_context_snapshot(AgentRuntimeConfig(cwd=workspace))
|
||||
snapshot = build_context_snapshot(
|
||||
AgentRuntimeConfig(cwd=workspace),
|
||||
scratchpad_directory=scratchpad,
|
||||
)
|
||||
|
||||
self.assertIn('taskRuntime', snapshot.user_context)
|
||||
self.assertIn('Total tasks: 1', snapshot.user_context['taskRuntime'])
|
||||
@@ -211,17 +216,42 @@ class AgentContextTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
workspace = Path(tmp_dir) / 'repo'
|
||||
workspace.mkdir(parents=True)
|
||||
plan_runtime = PlanRuntime.from_workspace(workspace)
|
||||
scratchpad = workspace / '.port_sessions' / 'accounts' / 'alice' / 'sessions' / 's1' / 'scratchpad'
|
||||
scratchpad.mkdir(parents=True)
|
||||
plan_runtime = PlanRuntime.from_storage_path(scratchpad / 'plan_runtime.json')
|
||||
plan_runtime.update_plan(
|
||||
[{'step': 'Inspect the runtime', 'status': 'in_progress'}],
|
||||
explanation='Use a stored plan.',
|
||||
)
|
||||
|
||||
snapshot = build_context_snapshot(AgentRuntimeConfig(cwd=workspace))
|
||||
snapshot = build_context_snapshot(
|
||||
AgentRuntimeConfig(cwd=workspace),
|
||||
scratchpad_directory=scratchpad,
|
||||
)
|
||||
|
||||
self.assertIn('planRuntime', snapshot.user_context)
|
||||
self.assertIn('Total plan steps: 1', snapshot.user_context['planRuntime'])
|
||||
|
||||
def test_user_context_ignores_workspace_plan_task_when_session_scratchpad_is_set(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
workspace = Path(tmp_dir) / 'repo'
|
||||
workspace.mkdir(parents=True)
|
||||
TaskRuntime.from_workspace(workspace).create_task(title='Global task')
|
||||
PlanRuntime.from_workspace(workspace).update_plan(
|
||||
[{'step': 'Global plan', 'status': 'in_progress'}],
|
||||
explanation='This must not leak into a session.',
|
||||
)
|
||||
scratchpad = workspace / '.port_sessions' / 'accounts' / 'alice' / 'sessions' / 's1' / 'scratchpad'
|
||||
scratchpad.mkdir(parents=True)
|
||||
|
||||
snapshot = build_context_snapshot(
|
||||
AgentRuntimeConfig(cwd=workspace),
|
||||
scratchpad_directory=scratchpad,
|
||||
)
|
||||
|
||||
self.assertNotIn('taskRuntime', snapshot.user_context)
|
||||
self.assertNotIn('planRuntime', snapshot.user_context)
|
||||
|
||||
def test_user_context_loads_team_runtime_summary(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
workspace = Path(tmp_dir) / 'repo'
|
||||
|
||||
Reference in New Issue
Block a user