Skip to content

Commit a7eec5d

Browse files
committed
feat: Add workspace_plugin parameter to agents for improved workspace management
1 parent 2c40705 commit a7eec5d

4 files changed

Lines changed: 38 additions & 16 deletions

File tree

src/agents/agents/action_planner_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ def __init__(
5959
action_planner_plugin: Optional[ActionPlannerPlugin] = None,
6060
test_planner_plugin: Optional[TestPlannerPlugin] = None,
6161
troubleshooting_plugin: Optional[TroubleshootingPlugin] = None,
62+
workspace_plugin: Optional[WorkspacePlugin] = None,
6263
) -> None:
6364
action_planner = action_planner_plugin or ActionPlannerPlugin()
6465
test_planner = test_planner_plugin or TestPlannerPlugin()
65-
workspace_plugin = WorkspacePlugin(workspace_store)
66+
ws_plugin = workspace_plugin or WorkspacePlugin(workspace_store)
6667
troubleshooting = troubleshooting_plugin or TroubleshootingPlugin(workspace_store)
6768

6869
super().__init__(
@@ -73,7 +74,7 @@ def __init__(
7374
),
7475
kernel=kernel,
7576
instructions=ACTION_PLANNER_AGENT_SYSTEM_PROMPT,
76-
plugins=[action_planner, test_planner, workspace_plugin, troubleshooting],
77+
plugins=[action_planner, test_planner, ws_plugin, troubleshooting],
7778
)
7879

7980
self.workspace_store: WorkspaceStore = workspace_store

src/agents/agents/base.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,31 @@ def create_default_agent_registry(kernel: Optional[Kernel] = None) -> "AgentRegi
246246

247247
registry = AgentRegistry()
248248
registry.register(EchoAgentSK(kernel=kernel))
249-
registry.register(TestAdvisorAgentSK(kernel=kernel, workspace_store=workspace_store))
249+
registry.register(
250+
TestAdvisorAgentSK(
251+
kernel=kernel,
252+
workspace_store=workspace_store,
253+
workspace_plugin=workspace_plugin,
254+
)
255+
)
250256
registry.register(
251257
ActionPlannerAgentSK(
252258
kernel=kernel,
253259
workspace_store=workspace_store,
260+
workspace_plugin=workspace_plugin,
254261
troubleshooting_plugin=TroubleshootingPlugin(
255262
workspace_store=workspace_store,
256263
execution_plugin=execution_plugin,
257264
),
258265
)
259266
)
260-
registry.register(SystemContextAgentSK(kernel=kernel, workspace_store=workspace_store))
267+
registry.register(
268+
SystemContextAgentSK(
269+
kernel=kernel,
270+
workspace_store=workspace_store,
271+
workspace_plugin=workspace_plugin,
272+
)
273+
)
261274
registry.register(
262275
ActionExecutorAgent(
263276
kernel=kernel,

src/agents/agents/system_context_agent.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
66
This agent uses Semantic Kernel for agentic workspace management
77
with function calling, replacing the custom tool loop.
8-
9-
NOTE: This agent has NO hardcoded methods - all workspace operations
10-
are performed by the LLM autonomously calling WorkspacePlugin tools.
118
"""
129

10+
from typing import Optional
1311
from semantic_kernel import Kernel
14-
1512
from src.agents.agents.base import SAPAutomationAgent
1613
from src.agents.workspace.workspace_store import WorkspaceStore
1714
from src.agents.plugins.workspace import WorkspacePlugin
@@ -35,15 +32,22 @@ class SystemContextAgentSK(SAPAutomationAgent):
3532
- create_workspace(): Create new workspace
3633
"""
3734

38-
def __init__(self, kernel: Kernel, workspace_store: WorkspaceStore) -> None:
35+
def __init__(
36+
self,
37+
kernel: Kernel,
38+
workspace_store: WorkspaceStore,
39+
workspace_plugin: Optional[WorkspacePlugin] = None,
40+
) -> None:
3941
"""Initialize SystemContextAgent with Semantic Kernel.
4042
4143
:param kernel: Configured Semantic Kernel instance
4244
:type kernel: Kernel
4345
:param workspace_store: WorkspaceStore instance for managing workspaces
4446
:type workspace_store: WorkspaceStore
47+
:param workspace_plugin: Optional shared WorkspacePlugin (with KeyVault)
48+
:type workspace_plugin: Optional[WorkspacePlugin]
4549
"""
46-
workspace_plugin = WorkspacePlugin(workspace_store)
50+
ws_plugin = workspace_plugin or WorkspacePlugin(workspace_store)
4751
super().__init__(
4852
name="system_context",
4953
description=(
@@ -53,7 +57,7 @@ def __init__(self, kernel: Kernel, workspace_store: WorkspaceStore) -> None:
5357
),
5458
kernel=kernel,
5559
instructions=SYSTEM_CONTEXT_AGENT_SYSTEM_PROMPT,
56-
plugins=[workspace_plugin],
60+
plugins=[ws_plugin],
5761
)
5862

5963
self.workspace_store: WorkspaceStore = workspace_store

src/agents/agents/test_advisor_agent.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
"""
88

99
from __future__ import annotations
10-
10+
from typing import Optional
1111
from semantic_kernel import Kernel
12-
1312
from src.agents.agents.base import SAPAutomationAgent
1413
from src.agents.observability import get_logger
1514
from src.agents.plugins.test import TestPlannerPlugin
@@ -28,9 +27,14 @@ class TestAdvisorAgentSK(SAPAutomationAgent):
2827
- WorkspacePlugin: Resolve SIDs, read workspace configuration (hosts.yaml, sap-parameters.yaml)
2928
"""
3029

31-
def __init__(self, kernel: Kernel, workspace_store: WorkspaceStore):
30+
def __init__(
31+
self,
32+
kernel: Kernel,
33+
workspace_store: WorkspaceStore,
34+
workspace_plugin: Optional[WorkspacePlugin] = None,
35+
):
3236
test_plugin = TestPlannerPlugin()
33-
workspace_plugin = WorkspacePlugin(workspace_store)
37+
ws_plugin = workspace_plugin or WorkspacePlugin(workspace_store)
3438

3539
super().__init__(
3640
name="test_advisor",
@@ -40,7 +44,7 @@ def __init__(self, kernel: Kernel, workspace_store: WorkspaceStore):
4044
),
4145
kernel=kernel,
4246
instructions=TEST_ADVISOR_AGENT_SYSTEM_PROMPT,
43-
plugins=[test_plugin, workspace_plugin],
47+
plugins=[test_plugin, ws_plugin],
4448
)
4549

4650
self.workspace_store: WorkspaceStore = workspace_store

0 commit comments

Comments
 (0)