Skip to content

Conversation

@strands-agent
Copy link
Contributor

Description

The Slack tool was overwriting the agent's system_prompt with only the SLACK_SYSTEM_PROMPT constant, ignoring any custom system prompts provided by the parent agent.

This fix ensures the parent agent's system_prompt is preserved and prepended to the Slack-specific context in:

  • _process_message: Both agent creation and system_prompt refresh
  • _process_interactive: Both agent creation and system_prompt refresh

The Problem

When a user creates an agent with a custom system prompt:

agent = Agent(
    tools=[slack_send_message],
    system_prompt="It will bark Bow! at first"  # This was being ignored!
)
slack(action="start_socket_mode", agent=agent)

The custom system prompt was lost because the code overwrote it with:

agent.system_prompt = f"{SLACK_SYSTEM_PROMPT}\n\nEvent Context:..."  # Missing parent prompt!

The Fix

Now preserves the parent agent's system prompt:

agent.system_prompt = (
    f"{self.agent.system_prompt}\n{SLACK_SYSTEM_PROMPT}\n\n"
    f"Event Context:..."
)

This follows the pattern already established in agent creation at line 359, now consistently applied across all locations.

Related Issues

Fixes #302

Type of Change

Bug fix

Testing

  • Added unit tests for system prompt preservation in test_slack_socket.py
  • All existing Slack tests pass
  • Verified the fix matches the proposed solution from the issue author

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • My changes generate no new warnings

🤖 This is an experimental AI agent response from the Strands team, powered by Strands Agents. We're exploring how AI agents can help with community support and development. Your feedback helps us improve! If you'd prefer human assistance, please let us know.

The Slack tool was overwriting the agent's system_prompt with only the
SLACK_SYSTEM_PROMPT constant, ignoring any custom system prompts provided
by the parent agent.

This fix ensures the parent agent's system_prompt is preserved and
prepended to the Slack-specific context in:
- _process_message: Both agent creation and system_prompt refresh
- _process_interactive: Both agent creation and system_prompt refresh

The fix follows the pattern already established in agent creation at
line 359, now consistently applied across all locations.

Fixes strands-agents#302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The agent's prompts are ignored in the Slack tool.

1 participant