Skip to content

Commit fdc471f

Browse files
authored
udpate agent system_prompt reference (#35)
1 parent cf2ebaf commit fdc471f

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/strands_agents_builder/strands.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ def main():
112112
welcome_text = ""
113113

114114
if welcome_result["status"] == "success":
115+
# Combine welcome text with base system prompt
115116
welcome_text = welcome_result["content"][0]["text"]
117+
agent.system_prompt = f"{base_system_prompt}\n\nWelcome Text Reference:\n{welcome_text}"
118+
else:
119+
agent.system_prompt = base_system_prompt
116120

117-
# Combine welcome text with base system prompt
118-
combined_system_prompt = f"{base_system_prompt}\n\nWelcome Text Reference:\n{welcome_text}"
119-
response = agent(user_input, system_prompt=combined_system_prompt)
121+
response = agent(user_input)
120122

121123
if knowledge_base_id:
122124
# Store conversation in knowledge base

tests/test_strands.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_interactive_mode(
4545
mock_user_input.assert_called_with("\n~ ", default="", keyboard_interrupt_return_default=False)
4646

4747
# Verify user input was processed
48-
mock_agent.assert_called_with("test query", system_prompt=mock.ANY)
48+
mock_agent.assert_called_with("test query")
4949

5050
# Verify goodbye message was rendered
5151
mock_goodbye_message.assert_called_once()
@@ -395,13 +395,9 @@ def test_welcome_message_with_kb(
395395
with mock.patch.object(strands, "render_welcome_message"), mock.patch.object(strands, "render_goodbye_message"):
396396
strands.main()
397397

398-
# Extract the system_prompt from the agent call
399-
call_args, call_kwargs = mock_agent.call_args
400-
system_prompt = call_kwargs.get("system_prompt")
401-
402398
# Verify system prompt includes both base prompt and welcome text
403-
assert base_system_prompt in system_prompt
404-
assert "Custom welcome text" in system_prompt
399+
assert base_system_prompt in mock_agent.system_prompt
400+
assert "Custom welcome text" in mock_agent.system_prompt
405401

406402
def test_welcome_message_failure(
407403
self,
@@ -430,10 +426,5 @@ def test_welcome_message_failure(
430426
with mock.patch.object(strands, "render_welcome_message"), mock.patch.object(strands, "render_goodbye_message"):
431427
strands.main()
432428

433-
# Verify agent was called with system prompt that includes welcome text reference
434-
# Even with error status, the code adds a "Welcome Text Reference:" section (just empty)
435-
expected_system_prompt = f"{base_system_prompt}\n\nWelcome Text Reference:\n"
436-
call_args, call_kwargs = mock_agent.call_args
437-
system_prompt = call_kwargs.get("system_prompt")
438-
439-
assert system_prompt == expected_system_prompt
429+
# Verify agent was called with system prompt that excludes welcome text reference
430+
assert mock_agent.system_prompt == base_system_prompt

0 commit comments

Comments
 (0)