Goals
- Understand what toolsets are and why they’re useful
- Use pre-built toolsets for common tasks (PDF, Excel, Word, PowerPoint)
- Create custom toolsets for your specific needs
- Compose multiple toolsets in a single environment
Prerequisites
- An OpenReward account
- An OpenReward API key
- Completion of the Your First Environment tutorial
- Completion of the Building Agentic Environments tutorial
Installation
Pre-built toolsets run in sandbox environments, which means your Docker image must include the required dependencies. You need theopenreward package with the tools extra dependency:
- pdfplumber, pypdf, reportlab, pdf2image - for PDFToolset
- python-docx - for WordToolset
- openpyxl - for ExcelToolset
- python-pptx - for PowerPointToolset
generalreasoning/knowledge-worker image which has them pre-installed.
Introduction
When building multiple environments, you’ll often find yourself copying the same tool definitions across different environment classes. For example, if you have three environments that all need to read PDF files, you’d typically copy the same PDF reading tools into each environment. Toolsets solve this problem by letting you define reusable collections of tools that can be declared with a simpletoolsets = [PDFToolset, ExcelToolset] statement. Instead of inheritance-based code reuse, toolsets provide a composition-based approach that follows the DRY (Don’t Repeat Yourself) principle.
The key benefits:
- Reusability: Define tools once, use them in multiple environments
- Composition: Mix and match toolsets as needed
- Maintainability: Update tools in one place
- Clean separation: Keep environment-specific logic separate from general-purpose tools
Using Pre-Built Toolsets
OpenReward provides production-ready toolsets for common tasks. We’ll start with these before showing you how to create custom toolsets.Available Toolsets
The openreward library includes four pre-built toolsets:- PDFToolset - PDF creation, reading, searching, merging (11 tools)
- ExcelToolset - Spreadsheet manipulation, charts, data reading (10 tools)
- WordToolset - Document creation, formatting, content manipulation (12 tools)
- PowerPointToolset - Presentation creation and editing
openreward[tools] dependencies. When creating sandboxes for toolset usage, we recommend using the generalreasoning/knowledge-worker image which includes all required dependencies pre-installed. Alternatively, ensure your custom image includes the necessary libraries listed in the Installation section above.
Example: Using PDFToolset
Let’s create an environment that uses PDFToolset to analyze PDF documents. Here’s a complete working example:| Tool Name | Description |
|---|---|
pdfs_read_pdf_pages | Extract text content from PDF pages with optional layout information |
pdfs_search_pdf | Search for text within PDF pages with context |
pdfs_get_metadata | Get PDF document metadata and properties |
pdfs_get_document_overview | Quick overview of PDF structure (page count, text preview, metadata) |
pdfs_merge_pdfs | Combine multiple PDF files into one |
pdfs_extract_pages | Extract specific pages from a PDF to a new file |
pdfs_create_pdf | Create a new PDF file with optional metadata |
pdfs_add_content | Add text content to an existing PDF page or create a new page |
pdfs_read_image | Extract embedded images metadata from PDF pages |
pdfs_read_page_as_image | Convert PDF page to image (PNG/JPEG) |
pdfs_delete_pdf | Delete a PDF file from the sandbox |
pdfs_get_document_overview first to understand the document structure, then pdfs_read_pdf_pages to extract specific content, and finally pdfs_search_pdf to find key terms before submitting an answer.
Example: Using ExcelToolset
Similarly, you can use ExcelToolset for spreadsheet manipulation:| Tool Name | Description |
|---|---|
excel_create_spreadsheet | Create a new Excel workbook with initial worksheet |
excel_list_tabs_in_spreadsheet | List all worksheet/tab names in the workbook |
excel_add_tab | Add a new worksheet to existing workbook |
excel_read_tab | Read data from a specific worksheet |
excel_read_csv | Read CSV file and convert to Excel format data structure |
excel_edit_spreadsheet | Modify existing cell value in a worksheet |
excel_add_content_text | Write data to a range of cells (batch operation) |
excel_delete_content_cell | Clear cell content (sets to None) |
excel_create_chart | Create a chart in the worksheet (bar, column, line, pie, scatter, area) |
excel_delete_tab | Remove a worksheet from workbook |
excel_delete_spreadsheet | Delete an Excel spreadsheet file from sandbox |
Example: Composing Multiple Toolsets
You can use multiple toolsets together in a single environment. All tools from all toolsets become available:- All tools from all toolsets are discovered automatically
- Tools can be called without knowing which toolset they came from
- The framework detects and prevents tool name collisions
WordToolset and PowerPointToolset
WordToolset provides 12 tools for Word document manipulation:word_create_document- Create new documentword_get_document_overview- Get structure overviewword_read_document_content- Extract textword_add_content_text- Add paragraphs/headingsword_edit_content_text- Modify paragraphsword_delete_content_text- Remove paragraphsword_add_image- Insert imagesword_apply_formatting- Bold, italic, fonts, colors- And more…
openreward.toolsets, declare in your environment’s toolsets list, and ensure your environment has a self.sandbox attribute.
Creating Custom Toolsets
While pre-built toolsets cover common scenarios, you can create custom toolsets for your specific needs.Simple Toolset (No Dependencies)
For tools that don’t need sandbox access or other dependencies, you can create a simple toolset without extending any base class:Sandbox-Based Toolset
For tools that need sandbox access, extend theToolset base class:
Toolset base class:
- Receives the environment instance in its constructor
- Extracts
self.sandboxautomatically (viasandbox_attrparameter) - Makes the sandbox available to all tool methods
- Supports custom sandbox attribute names if needed
Key Concepts
Collision Detection
The framework prevents duplicate tool names. If your environment defines a tool with the same name as a toolset tool, an error is raised. This ensures clarity about which tool is being called and prevents subtle bugs. Example of a collision:ValueError: Tool name collision: 'pdfs_read_pdf_pages' is defined in both the environment and toolset 'PDFToolset'. Please rename one of them to avoid conflicts.
Dependency Injection
When a toolset extends theToolset base class, it automatically receives the environment instance and extracts dependencies like self.sandbox. You don’t need to manually pass these dependencies - the framework handles this through lazy instantiation.
Best Practices
When to use pre-built toolsets:- You’re working with common file formats (PDF, Excel, Word, PowerPoint)
- You need standard operations (read, write, search, merge)
- You want battle-tested, production-ready tools
- You have domain-specific tools used across multiple environments
- You’re building tools for file formats not covered by pre-built toolsets
- You need specialized operations not available in pre-built toolsets
- Prefix toolset tools to avoid collisions:
pdf_,excel_,math_ - Use descriptive toolset class names:
PDFToolset, notDocumentToolset - Match parameter model names to tools:
MathParamsfor bothaddandsubtractwhen they share parameters
- Toolsets: Reusable tools used across 3+ environments, logical groups with shared dependencies
- Environment tools: Task-specific logic, environment-specific state, one-off operations
- Keep toolsets in a separate
toolsets/directory - One file per toolset:
toolsets/math.py,toolsets/file.py - Import and declare:
from toolsets.math import MathToolset
Troubleshooting
“AttributeError: ‘MyEnv’ object has no attribute ‘sandbox’” Solution: Ensure you initializeself.sandbox in your environment’s __init__ method before any tools are called. Toolsets extending Toolset look for this attribute.
Next Steps
Now that you understand toolsets, you can build more sophisticated environments:Building Agentic Environments
Learn advanced sandbox patterns that work great with toolsets
Using LLM Graders
Combine toolsets with intelligent grading for complex evaluations
Evaluation
Use toolsets in evaluation environments to test model capabilities

