Strands Agents SDK
This guide demonstrates how to use SEA-LION models as intelligent agents using AWS's Strands Agent SDK. The examples show how to build both general-purpose agents with multiple tools and specialized single-purpose agents.
Prerequisites
Python 3.10+
AWS Strands Agents SDK installed (Quickstart)
SEA-LION API or Bedrock access
Environment variables configured
The sample code in this guide will be configuring the model via SEA-LION API, which follows an OpenAI-compatible format. Strands Agent ADK is also compatible with other model providers. For configuring SEA-LION in Strands SDK via Bedrock, you may refer to this page. For setting up of SEA-LION in Bedrock, refer to this link.
Environment Setup
Create a .env file with your configuration:
API_KEY=your-api-key-here
API_BASE_URL=https://api.sea-lion.ai/v1
MODEL=aisingapore/Llama-SEA-LION-v3-70B-IT
# Environment variable for custom tool
SEARXNG_URL=https://your-searxng-instance-url-hereBasic Agent Setup
Here's how to create a basic SEA-LION agent with tool-calling capabilities:
agent.py
Refer to the documentation for more examples of in-built tools.
Custom Tool Development
You can create custom tools for your agents. Here's an example of custom web search tool using a locally-deployed SearXNG search engine:
tools.py
Agent as a Tool
Create a specialized agent that can be used as a tool by other agents:
translate_agent.py
Multi-Tool Agent Example
Combine multiple tools for a comprehensive agent, making use of Strands tools, custom tools and agents as tools:
agent_multi.py
Best Practices
Model Selection
Use
aisingapore/Llama-SEA-LION-v3-70B-ITfor complex reasoning and tool-callingUse
aisingapore/Gemma-SEA-LION-v3-9B-ITfor specialized, single-purpose agents
Agent Configuration
Use clear, descriptive names for your agents
Provide specific instructions about tool usage guidelines
Include examples when tools have specific parameter formats
Clearly define the agent's role and capabilities
Session Management
Agent conversation history can be accessed via the
agent.messagespropertyTo handle long-context conversations,
SlidingWindowConversationManagercan be configuredMore information and examples on conversation/state/session management available here
Tool Documentation
Always provide clear docstrings for custom tools, including:
Purpose and functionality
Parameter descriptions with types
Return value format
Usage examples
Exception handling
Troubleshooting
Common Issues:
Tool not being called: Ensure your system prompt mentions the tool and its use cases
API connection errors: Verify your API_KEY and API_BASE_URL in the
.envfileTimeout issues: Adjust the timeout parameters in your tools
Memory usage: Use streaming responses for better performance with large outputs
Performance Tips:
Use appropriate model sizes for your use case
Implement proper error handling and fallbacks
Monitor token usage to optimize costs
Strands Agents SDK Specific
Last updated