Skip to content

Commit 79e5737

Browse files
committed
refactor: UI improvements and swarm agent simplification
- Add /tool autocomplete and redesign tools dropdown (Popover → Dialog) - Simplify swarm agent implementation and remove deprecated swarm_agents.py
1 parent e6c43c2 commit 79e5737

64 files changed

Lines changed: 2570 additions & 2811 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agent-blueprint/agentcore-gateway-stack/lambda-functions/weather/lambda_function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def get_today_weather(event: Dict[str, Any]) -> Dict[str, Any]:
174174
}
175175

176176
url = f"{WEATHER_API}?{urlencode(params)}"
177-
logger.info(f"Weather request for location: lat={lat}, lon={lon}")
177+
logger.info(f"Weather request for location: lat={location['latitude']}, lon={location['longitude']}")
178178

179179
with urlopen(url, timeout=10) as response:
180180
weather_data = json.loads(response.read().decode('utf-8'))
@@ -280,7 +280,7 @@ def get_weather_forecast(event: Dict[str, Any]) -> Dict[str, Any]:
280280
}
281281

282282
url = f"{WEATHER_API}?{urlencode(params)}"
283-
logger.info(f"Forecast request for location: lat={lat}, lon={lon}, days={days}")
283+
logger.info(f"Forecast request for location: lat={location['latitude']}, lon={location['longitude']}, days={days}")
284284

285285
with urlopen(url, timeout=10) as response:
286286
forecast_data = json.loads(response.read().decode('utf-8'))

chatbot-app/agentcore/src/a2a_tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ async def send_a2a_message(
513513
elif artifact_name.startswith('browser_step_'):
514514
# Skip browser_step_N (UI-only, not for LLM context)
515515
logger.info(f"Skipping {artifact_name} (UI-only artifact)")
516+
elif artifact_name.startswith('research_step_'):
517+
# Skip research_step_N (UI-only progress, not for LLM context)
518+
logger.info(f"Skipping {artifact_name} (UI-only artifact)")
516519
else:
517520
# Include other artifacts (agent_response, browser_result, etc.) in LLM context
518521
response_text += artifact_text

chatbot-app/agentcore/src/agent/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
Usage:
1212
from agent.agent import ChatbotAgent, get_global_stream_processor
1313
from agent.voice_agent import VoiceAgent
14-
from agent.swarm_agents import create_chatbot_swarm
1514
from agent.stop_signal import get_stop_signal_provider
1615
1716
from agent.config.constants import DEFAULT_AGENT_ID

chatbot-app/agentcore/src/agent/config/prompt_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class SystemContentBlock(TypedDict, total=False):
5252
5353
<tool_usage>
5454
- Use available tools when they genuinely enhance your response
55-
- You can ONLY use tools that are explicitly provided to you
55+
- You can ONLY use tools that are explicitly provided to you — available tools may change between turns within the same conversation, so always refer to the current set of tools
5656
- Select the most appropriate tool for the task - avoid redundant tool calls
5757
- If you don't have the right tool for a task, clearly inform the user
5858
</tool_usage>

chatbot-app/agentcore/src/agent/config/swarm_config.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"weather_agent": "Current weather and forecast information",
2424
"finance_agent": "Stock quotes, price history, and financial analysis",
2525
"maps_agent": "Place search, directions, and map display",
26+
"google_workspace_agent": "Gmail email and Google Calendar management (requires OAuth)",
27+
"notion_agent": "Notion pages, databases, and content management (requires OAuth)",
2628
"responder": "Final response and simple interactive charts (bar, line, pie)",
2729
}
2830

@@ -45,12 +47,14 @@
4547
"modify_word_document",
4648
"list_my_word_documents",
4749
"read_word_document",
50+
"preview_word_page",
4851
],
4952
"excel_agent": [
5053
"create_excel_spreadsheet",
5154
"modify_excel_spreadsheet",
5255
"list_my_excel_spreadsheets",
5356
"read_excel_spreadsheet",
57+
"preview_excel_sheets",
5458
],
5559
"powerpoint_agent": [
5660
"list_my_powerpoint_presentations",
@@ -63,6 +67,8 @@
6367
"move_slide",
6468
"duplicate_slide",
6569
"update_slide_notes",
70+
"get_slide_code_examples",
71+
"preview_presentation_slides",
6672
],
6773
"data_analyst": [
6874
"generate_diagram_and_validate",
@@ -92,6 +98,36 @@
9298
"gateway_get_directions",
9399
"gateway_show_on_map",
94100
],
101+
"google_workspace_agent": [
102+
"mcp_list_labels",
103+
"mcp_list_emails",
104+
"mcp_search_emails",
105+
"mcp_read_email",
106+
"mcp_send_email",
107+
"mcp_draft_email",
108+
"mcp_delete_email",
109+
"mcp_bulk_delete_emails",
110+
"mcp_modify_email",
111+
"mcp_get_email_thread",
112+
"mcp_list_calendars",
113+
"mcp_list_events",
114+
"mcp_get_event",
115+
"mcp_create_event",
116+
"mcp_update_event",
117+
"mcp_delete_event",
118+
"mcp_quick_add_event",
119+
"mcp_check_availability",
120+
],
121+
"notion_agent": [
122+
"mcp_notion_search",
123+
"mcp_notion_list_databases",
124+
"mcp_notion_query_database",
125+
"mcp_notion_get_page",
126+
"mcp_notion_create_page",
127+
"mcp_notion_update_page",
128+
"mcp_notion_get_block_children",
129+
"mcp_notion_append_blocks",
130+
],
95131
"responder": [
96132
"create_visualization",
97133
],
@@ -121,7 +157,7 @@
121157
122158
Check conversation history for context. For follow-ups, infer intent from history.
123159
124-
Routing: greetings/chat → responder | weather → weather_agent | stocks → finance_agent | maps → maps_agent | web search → web_researcher | papers → academic_researcher | simple charts → responder | diagrams/calculations → data_analyst | browser → browser_agent | word → word_agent | excel → excel_agent | powerpoint → powerpoint_agent""",
160+
Routing: greetings/chat → responder | weather → weather_agent | stocks → finance_agent | maps → maps_agent | web search → web_researcher | papers → academic_researcher | simple charts → responder | diagrams/calculations → data_analyst | browser → browser_agent | word → word_agent | excel → excel_agent | powerpoint → powerpoint_agent | email/gmail/calendar/schedule → google_workspace_agent | notion/notes/wiki/database(notion) → notion_agent""",
125161

126162
"web_researcher": """Web Researcher - search and extract web content.
127163
@@ -155,6 +191,19 @@
155191

156192
"maps_agent": """Maps Agent - places and directions.""",
157193

194+
"google_workspace_agent": """Google Workspace Agent - Gmail and Google Calendar.
195+
196+
Gmail: search, read, send, draft, delete, modify emails, manage labels and threads.
197+
Calendar: list calendars, create/update/delete events, check availability, quick-add.
198+
199+
Context format: {"emails": [{"subject": "...", "from": "..."}], "events": [{"summary": "...", "start": "..."}]}""",
200+
201+
"notion_agent": """Notion Agent - pages, databases, and content management.
202+
203+
Search pages, query databases with filters, read/create/update pages, manage content blocks.
204+
205+
Context format: {"pages": [{"title": "...", "id": "..."}], "databases": [{"title": "...", "id": "..."}]}""",
206+
158207
"responder": """Responder - write the final user-facing response.
159208
160209
Use create_visualization tool for simple charts if needed.

chatbot-app/agentcore/src/agent/session/swarm_message_store.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
from typing import Any, Dict, List, Optional
1414

15-
from strands.types.session import Session, SessionAgent, SessionMessage
15+
from strands.types.session import Session, SessionAgent, SessionMessage, SessionType
1616
from strands.types.exceptions import SessionException
1717

1818
logger = logging.getLogger(__name__)
@@ -95,7 +95,7 @@ def _create_session_manager(self):
9595
# Local mode: Use FileSessionManager
9696
from strands.session.file_session_manager import FileSessionManager
9797

98-
sessions_dir = Path(__file__).parent.parent.parent / "sessions"
98+
sessions_dir = Path(__file__).parent.parent.parent.parent / "sessions"
9999
sessions_dir.mkdir(exist_ok=True)
100100

101101
manager = FileSessionManager(
@@ -132,7 +132,7 @@ def _ensure_session_and_agent_exist(self) -> None:
132132
try:
133133
existing_session = repo.read_session(self.session_id)
134134
if existing_session is None:
135-
session = Session(session_id=self.session_id)
135+
session = Session(session_id=self.session_id, session_type=SessionType.AGENT)
136136
repo.create_session(session)
137137
logger.debug(f"[Swarm] Created session: {self.session_id}")
138138
except Exception as e:
@@ -142,12 +142,27 @@ def _ensure_session_and_agent_exist(self) -> None:
142142
try:
143143
existing_agent = repo.read_agent(self.session_id, SWARM_AGENT_ID)
144144
if existing_agent is None:
145-
agent = SessionAgent(agent_id=SWARM_AGENT_ID)
145+
agent = SessionAgent(agent_id=SWARM_AGENT_ID, state={}, conversation_manager_state={})
146146
repo.create_agent(self.session_id, agent)
147147
logger.debug(f"[Swarm] Created agent: {SWARM_AGENT_ID}")
148148
except Exception as e:
149149
logger.debug(f"[Swarm] Agent check/create: {e}")
150150

151+
def save_artifacts(self, artifacts: Dict[str, Any]) -> None:
152+
"""Save artifacts to agent state for history reload."""
153+
try:
154+
self._ensure_session_and_agent_exist()
155+
156+
agent = self._repo.read_agent(self.session_id, SWARM_AGENT_ID)
157+
if agent:
158+
if not hasattr(agent, 'state') or agent.state is None:
159+
agent.state = {}
160+
agent.state['artifacts'] = artifacts
161+
self._repo.update_agent(self.session_id, agent)
162+
logger.info(f"[Swarm] Saved {len(artifacts)} artifacts")
163+
except Exception as e:
164+
logger.error(f"[Swarm] Failed to save artifacts: {e}")
165+
151166
def save_turn(
152167
self,
153168
user_message: str,

0 commit comments

Comments
 (0)