Skip to content

Commit

Permalink
Merge pull request #236 from muham-2002/improve-cursorrules
Browse files Browse the repository at this point in the history
Update .cursorrules to add instructions for shared state in Agency Swarm
  • Loading branch information
bonk1t authored Feb 21, 2025
2 parents e08b66c + 2925c26 commit 2a799c9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ load_dotenv() # always load the environment variables

#### 2. Define Your Tool Class and Docstring

Create a new class that inherits from `BaseTool`. Write a clear docstring describing the tools purpose. This docstring is crucial as it helps agents understand how to use the tool. `BaseTool` extends `BaseModel` from pydantic.
Create a new class that inherits from `BaseTool`. Write a clear docstring describing the tool's purpose. This docstring is crucial as it helps agents understand how to use the tool. `BaseTool` extends `BaseModel` from pydantic.

```python
class MyCustomTool(BaseTool):
Expand Down Expand Up @@ -198,6 +198,27 @@ if __name__ == "__main__":

Remember, each tool code snippet you create must be fully ready to use. It must not contain any mocks, placeholders or hypothetical examples. Ask user for clarification if needed.

### Shared State in Tools

Tools can access and modify a global state across the agency to store and share data without using extra tokens in conversations.

```python
def run(self):
self._shared_state.set("my_key", "my_value") # Store data
data = self._shared_state.get("my_key", "default_value") # Retrieve data with a default
```

Use this for:
- Large data structures expensive to pass between agents
- Maintaining state across multiple tool calls
- Sharing data among tools and agents

Best Practices
- Use descriptive keys to avoid conflicts
- Provide default values when retrieving
- Clean up unneeded data


# Step 4: Agent Creation

Each agent has it's own unique role and functionality and is designed to perform specific tasks. To create an agent:
Expand Down

0 comments on commit 2a799c9

Please sign in to comment.