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

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-here

Basic 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-IT for complex reasoning and tool-calling

  • Use aisingapore/Gemma-SEA-LION-v3-9B-IT for 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.messages property

  • To handle long-context conversations, SlidingWindowConversationManager can be configured

  • More 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:

  1. Tool not being called: Ensure your system prompt mentions the tool and its use cases

  2. API connection errors: Verify your API_KEY and API_BASE_URL in the .env file

  3. Timeout issues: Adjust the timeout parameters in your tools

  4. 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

  • Configuring specialised agents as tools allows for them to do focused singular tasks. For using agents in a workflow or loop, consider other multi-agents systems in Strands SDK like Workflow or Graph

Last updated